#include <gtool.hpp>
Definition at line 33 of file gtool.hpp.
◆ t_edge
◆ t_graph
◆ t_lookup_ret
◆ t_objects
◆ t_registry
◆ t_vertex
◆ gtool()
dbe::tool::graph::gtool::gtool |
( |
std::string const & | rl, |
|
|
dbinfo | dbtype ) |
Construct gtool object from string a resource location and db information type Resulting object loads a database from the resource location of the designated type
- Parameters
-
fn | is a string designating the resource location of the database |
dbtype | is the type (dbinfo) of the database access method (e.g. oks, rdb ... ) |
Definition at line 32 of file gtool.cpp.
33 :
35{
36 QFileInfo DatabaseFile ( QString::fromStdString ( rl ) );
37
38 if ( DatabaseFile.exists() )
39 {
40 QString path_to_database = QString ( DatabaseFile.absoluteFilePath() );
41 {
43 INFO (
"Database location set",
"Program execution control success" );
44
46 {
47 INFO (
"Database initialized",
"User request" );
48 }
49 else
50 {
51 ERROR (
"Could not load database",
"OKS error ",
52 " Actions : check environment variables e.g. DUNEDAQ_DB_PATH" );
53 throw std::string ( "Could not load database" );
54 }
55 }
56 }
57 else
58 {
59 ERROR (
"Cannot open database",
"File error",
"for file", rl );
60 }
61}
static bool load(bool subscribeToChanges=true)
static void setdbinfo(QString const &location, dbinfo const itype=dbinfo::oks)
◆ add_object() [1/2]
Add an object to a graph without its relations
- Parameters
-
g | is a reference to the graph |
o | is a reference to the object |
uniqueness | only add the object if there is no vertex already abstracting it |
- Returns
- the newly added vertex or an already existent vertex if uniqueness is set and the object has already been added as a vertex
Definition at line 113 of file gtool.cpp.
114{
115 vertex_label xl
116 { x.UID(), x.class_name(), x.full_name() };
117
118 if ( not uniqueness )
119 {
120
121 return boost::add_vertex ( xl, g );
122 }
123 else
124 {
125 bool result;
126 boost::graph_traits<t_graph>::vertex_iterator viter;
127 std::tie ( result, viter ) =
lookup ( g, xl );
128
129 if ( result )
130 {
131 return *viter;
132 }
133 else
134 {
135 return boost::add_vertex ( xl, g );
136
137 }
138 }
139}
◆ add_object() [2/2]
Add an object to a graph without its relations if it is not found in the provided registry
- Parameters
-
g | is a reference to the graph |
o | is a reference to the object |
registry | is a set of tags already present , and implies adding the object only if its tag is not in the registry ( speed up lookups ) |
- Returns
- the newly added vertex or an already existent vertex if uniqueness is set and the object has already been added as a vertex
Definition at line 141 of file gtool.cpp.
143{
144 t_registry::iterator vat = registry.find ( x.full_name() );
145
146 if ( std::end ( registry ) == vat )
147 {
148 FULLDEBUG (
"Adding object",
"Program execution control", x.full_name() );
149
150 t_registry::iterator v;
151 std::tie ( v, std::ignore ) = registry.emplace ( x.full_name(),
add_object ( g, x,
152 false ) );
153 return v->second;
154 }
155 else
156 {
157 return vat->second;
158 }
159}
◆ add_object_and_friends()
Add an object to a graph along with all connected objects through any relation
- Parameters
-
a | reference to the graph |
a | registry of tags of objects already present in the graph |
Definition at line 161 of file gtool.cpp.
163{
164 DEBUG (
"Processing object",
"Program execution control", o.full_name() );
166
167 std::vector<tref> friends
169 DEBUG (
"Processing object",
"Program execution control", o.full_name(),
" # friends: ",
170 std::to_string ( friends.size() ) );
171
172 for (
tref const & x : friends )
173 {
175 boost::add_edge ( ov, xv, g );
176 FULLDEBUG (
"Add edge ",
"Program excecution control", o.full_name() ,
"->",
177 x.full_name() );
178 }
179
180 return ov;
181}
std::vector< T > object(tref const &item)
inner::configobject::tref tref
◆ create_graph()
void dbe::tool::graph::gtool::create_graph |
( |
| ) |
|
|
private |
Definition at line 100 of file gtool.cpp.
101{
102 INFO (
"Database graph generation initiated",
"Program execution control" );
104
106 {
108 }
109
110 INFO (
"Graph generation completed successfully",
"Program execution control success" );
111}
◆ getgraph()
Retrieve the graph as it currently is
- Returns
- a const reference to the t_graph
Definition at line 63 of file gtool.cpp.
◆ load_all()
void dbe::tool::graph::gtool::load_all |
( |
| ) |
|
|
private |
Definition at line 68 of file gtool.cpp.
69{
70 INFO (
"Start load objects into internal cache",
"Program execution control" );
71
72 std::vector<std::string> all_classes =
74
75 for ( auto const & x : all_classes )
76 {
78 }
79
80 INFO (
"All objects loaded into internal cache",
"Program execution control success",
82}
◆ load_all_class_objects()
void dbe::tool::graph::gtool::load_all_class_objects |
( |
std::string const & | cname | ) |
|
|
private |
Definition at line 84 of file gtool.cpp.
85{
87 false );
88
89 INFO (
"Class to load: ",
"Program execution control", cname );
90
92 {
94 }
95
96 INFO (
"Class load success: ",
"Program execution control", cname,
97 "#objects", std::to_string ( all_objects.size() ) );
98}
static std::vector< dbe::inner::configobject::tref > objects(std::string const &cname, bool const keep_inherited=true)
◆ load_and_run()
template<typename ALGO >
int dbe::tool::graph::gtool::load_and_run |
( |
ALGO const & | algo | ) |
|
|
inline |
Definition at line 177 of file gtool.hpp.
178{
181 return algo (
static_cast<gtool const &
> ( *
this ) );
182}
◆ lookup()
Lookup a vector in the graph , runs in O(N) worst case
- Parameters
-
g | is the graph |
l | is the graph label |
- Returns
- a pair <true, valid vertex iterator > if found , otherwise <false, end iter>
Definition at line 183 of file gtool.cpp.
184{
185 auto const & vertices = boost::vertices ( g );
186
187 for ( auto v = vertices.first; v != vertices.second; ++v )
188 {
190 {
192 }
193 }
194
196}
◆ already_processed
t_registry dbe::tool::graph::gtool::already_processed |
|
private |
◆ this_all_objects
t_objects dbe::tool::graph::gtool::this_all_objects |
|
private |
◆ this_graph
t_graph dbe::tool::graph::gtool::this_graph |
|
private |
◆ this_src
std::string dbe::tool::graph::gtool::this_src |
|
private |
The documentation for this class was generated from the following files:
- /github/workspace/dunedaq/sourcecode/dbe/include/dbe/gtool.hpp
- /github/workspace/dunedaq/sourcecode/dbe/apps/graphtool/gtool.cpp