DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
config_ui_info.cpp
Go to the documentation of this file.
1/*
2 * configuration.cpp
3 *
4 * Created on: Mar 22, 2016
5 * Author: Leonidas Georgopoulos
6 */
7
11#include "dbe/messenger.hpp"
12#include "dbe/Conversion.hpp"
13
16
17#include <QStringList>
18
19#include <map>
20#include <vector>
21
22using namespace dunedaq::conffwk;
23
24dbe::ui::config::info::info ( std::vector<std::string> const & full_file_name )
25 : this_full_filenames ( full_file_name )
26{
27 parse();
28}
29
30dbe::GraphicalClass dbe::ui::config::info::graphical ( std::string const & name ) const
31{
32 std::map<std::string, GraphicalClass>::const_iterator it = this_graphical.find ( name );
33
34 if ( it != this_graphical.end() )
35 {
36 return it->second;
37 }
38 else
39 {
40 return
41 {};
42 }
43}
44
45dbe::ViewConfiguration dbe::ui::config::info::view ( std::string const & name ) const
46{
47 std::map<std::string, ViewConfiguration>::const_iterator it = this_views.find ( name );
48
49 if ( it != this_views.end() )
50 {
51 return it->second;
52 }
53 else
54 {
55 return
56 {};
57 }
58}
59
60dbe::Window dbe::ui::config::info::window ( std::string const & name ) const
61{
62 std::map<std::string, Window>::const_iterator it = this_windows.find ( name );
63
64 if ( it != this_windows.end() )
65 {
66 return it->second;
67 }
68 else
69 {
70 return
71 {};
72 }
73}
74
76{
77 for ( std::string const & fname : this_full_filenames )
78 {
79 std::string Implementation = "oksconflibs:" + fname;
80
81 try
82 {
83 std::shared_ptr<Configuration> ConfigFile ( new Configuration ( Implementation ) );
84 std::vector<ConfigObject> objects;
85
86 ConfigFile->get ( "Class", objects );
87
88 for ( ConfigObject & aclass : objects )
89 {
90 parse_graphical ( ConfigFile, aclass );
91 }
92
93 objects.clear();
94 ConfigFile->get ( "Window", objects );
95
96 for ( ConfigObject & awindow : objects )
97 {
98 parse_window ( ConfigFile, awindow );
99 }
100 }
101 catch ( dunedaq::conffwk::Exception const & ex )
102 {
103 ERROR ( "Configuration database load did not succeed",
104 dbe::config::errors::parse ( ex ).c_str() );
105 }
106 }
107}
108
109void dbe::ui::config::info::parse_graphical ( std::shared_ptr<Configuration> ConfigFile,
110 ConfigObject & Object )
111{
112 GraphicalClass GraphicalClassObject;
113
114 GraphicalClassObject.GraphicalUID = QString ( Object.UID().c_str() );
115 dunedaq::conffwk::class_t cinfo = ConfigFile->get_class_info ( Object.class_name(), false );
116
117 std::vector<dunedaq::conffwk::attribute_t> const & attributes = cinfo.p_attributes;
118 std::vector<dunedaq::conffwk::relationship_t> const & relations = cinfo.p_relationships;
119
120 for ( dunedaq::conffwk::attribute_t const & attr : attributes )
121 {
122 QStringList data = dbe::config::api::get::direct::attribute<QStringList> ( Object, attr );
123
124 if ( attr.p_name == "Name" )
125 {
126 GraphicalClassObject.DatabaseClassName = data.at ( 0 );
127 }
128 else if ( attr.p_name == "Generic Pixmap File" )
129 {
130 GraphicalClassObject.GenericPixmapFile = data.at ( 0 );
131 }
132 else if ( attr.p_name == "Used Pixmap File" )
133 {
134 GraphicalClassObject.UsedPixmapFile = data.at ( 0 );
135 }
136 else if ( attr.p_name == "Icon Bitmap File" )
137 {
138 GraphicalClassObject.BitmapFile = data.at ( 0 );
139 }
140 else if ( attr.p_name == "Icon Mask Bitmap File" )
141 {
142 GraphicalClassObject.BitmapMaskFile = data.at ( 0 );
143 }
144 else if ( attr.p_name == "Show All Attributes" )
145 {
146 GraphicalClassObject.ShowAllAttributes = convert::to<bool> (
147 data, attr.p_int_format );
148 }
149 else if ( attr.p_name == "Attributes" )
150 {
151 GraphicalClassObject.Attributes = data;
152 }
153 else if ( attr.p_name == "Show All Relationships" )
154 {
155 GraphicalClassObject.ShowAllRelationships = convert::to<bool> (
156 data, attr.p_int_format );
157 }
158 else if ( attr.p_name == "Relationships" )
159 {
160 GraphicalClassObject.Relationships = data;
161
162 }
163 else if ( attr.p_name == "Icon Title" )
164 {
165 GraphicalClassObject.IconTitle = data.at ( 0 );
166 }
167 }
168
169 for ( dunedaq::conffwk::relationship_t const & relation : relations )
170 {
171 QStringList data;
172 std::vector<ConfigObject> neighboring
173 { };
174
176 {
177 neighboring.push_back (
179 }
180 else
181 {
182 std::vector<ConfigObject> objects = dbe::config::api::graph::direct::linked <
183 std::vector<ConfigObject >> ( Object, relation );
184 neighboring.insert ( std::end ( neighboring ), std::begin ( objects ),
185 std::end ( objects ) );
186 }
187
188 for ( ConfigObject & RelObject : neighboring )
189 {
190 dunedaq::conffwk::class_t RelClassInfo = ConfigFile->get_class_info ( RelObject.class_name(),
191 false );
192 std::vector<dunedaq::conffwk::attribute_t> AttributeRelList = RelClassInfo.p_attributes;
193
194 if ( RelObject.class_name() == "Dual Relationship" )
195 {
196 DualRelationship DRel;
197
198 for ( dunedaq::conffwk::attribute_t & Attribute : AttributeRelList )
199 {
201 Attribute );
202
203 if ( Attribute.p_name == "Direct" )
204 {
205 DRel.Direct = data.at ( 0 );
206 }
207 else if ( Attribute.p_name == "Reverse" )
208 {
209 DRel.Reverse = data.at ( 0 );
210 }
211 }
212
213 GraphicalClassObject.DualRelationships.push_back ( DRel );
214 }
215 else if ( RelObject.class_name() == "Init Attribute Value" )
216 {
218
219 for ( dunedaq::conffwk::attribute_t & Attribute : AttributeRelList )
220 {
222 Attribute );
223
224 if ( Attribute.p_name == "Attribute Name" )
225 {
226 IRel.AttributeName = data.at ( 0 );
227 }
228 else if ( Attribute.p_name == "Environment Variables" )
229 {
230 IRel.EnvNames = data;
231 }
232 }
233
234 GraphicalClassObject.NeedToInitialize.push_back ( IRel );
235 }
236 }
237 }
238
239 this_graphical.emplace ( GraphicalClassObject.GraphicalUID.toStdString(),
240 GraphicalClassObject );
241
242}
243
244void dbe::ui::config::info::parse_window ( std::shared_ptr<Configuration> database,
245 ConfigObject & object )
246{
247 Window WindowObject;
248 dunedaq::conffwk::class_t ClassInfo = database->get_class_info ( object.class_name(), false );
249 std::vector<dunedaq::conffwk::attribute_t> const & attributes = ClassInfo.p_attributes;
250 std::vector<dunedaq::conffwk::relationship_t> const & relations = ClassInfo.p_relationships;
251
252 for ( dunedaq::conffwk::attribute_t const & attribute : attributes )
253 {
254 if ( attribute.p_name == "Title" )
255 {
257 attribute ).at (
258 0 );
259 }
260 }
261
262 for ( dunedaq::conffwk::relationship_t const & relation : relations )
263 {
264 std::vector<ConfigObject> linkedobjects;
265
267 {
268 linkedobjects.push_back (
270 }
271 else
272 {
273 std::vector<ConfigObject> voisins = dbe::config::api::graph::direct::linked <
274 std::vector<ConfigObject >> ( object, relation );
275
276 if ( not voisins.empty() )
277 {
278 linkedobjects.insert ( std::end ( linkedobjects ), std::begin ( voisins ),
279 std::end ( voisins ) );
280 }
281 }
282
283 for ( ConfigObject & neighbor : linkedobjects )
284 {
285 dunedaq::conffwk::class_t classinfo = database->get_class_info ( neighbor.class_name(),
286 false );
287 std::vector<dunedaq::conffwk::attribute_t> const & AttributeRelList = classinfo
289 std::vector<dunedaq::conffwk::relationship_t> const & RelationshipRelList = classinfo
291
292 if ( neighbor.class_name() != "Window Separator" )
293 {
294 for ( dunedaq::conffwk::attribute_t const & Attribute : AttributeRelList )
295 {
296 if ( Attribute.p_name == "Shown with children" )
297 {
298 QStringList neighbor_names
300
301 if ( neighbor_names.at ( 0 ) != "none" )
302 {
303 WindowObject.ShowChildren = true;
304 }
305 else
306 {
307 WindowObject.ShowChildren = false;
308 }
309 }
310 }
311
312 for ( dunedaq::conffwk::relationship_t const & RelationshipRel : RelationshipRelList )
313 {
314 QStringList RelDataList;
315 std::vector<ConfigObject> neighboring_nodes;
316
317 if ( dbe::config::api::info::relation::is_simple ( RelationshipRel ) )
318 {
319 neighboring_nodes.push_back (
321 RelationshipRel ) );
322 }
323 else
324 {
325
326 std::vector<ConfigObject> neighbors = dbe::config::api::graph::direct::linked <
327 std::vector<ConfigObject >> ( neighbor, RelationshipRel );
328
329 neighboring_nodes.insert ( std::end ( neighboring_nodes ), std::begin ( neighbors ),
330 std::end ( neighbors ) );
331 }
332
333 for ( ConfigObject & RelDataObject : neighboring_nodes )
334 {
335 RelDataList.push_back ( QString ( RelDataObject.UID().c_str() ) );
336 }
337
338 WindowObject.GraphicalClassesList.push_back ( RelDataList.at ( 0 ) );
339 }
340 }
341 }
342 }
343
344 this_windows.emplace ( WindowObject.Title.toStdString(), WindowObject );
345}
346
347std::vector<dbe::Window> dbe::ui::config::info::windows() const
348{
349 std::vector<dbe::Window> windows;
350
351 for ( auto const & x : this_windows )
352 {
353 windows.push_back ( x.second );
354 }
355
356 return windows;
357}
358
359std::vector<dbe::ViewConfiguration> dbe::ui::config::info::views() const
360{
361 std::vector<dbe::ViewConfiguration> views;
362
363 for ( auto const & x : this_views )
364 {
365 views.push_back ( x.second );
366 }
367
368 return views;
369}
370
371std::vector<dbe::GraphicalClass> dbe::ui::config::info::graphicals() const
372{
373 std::vector<dbe::GraphicalClass> the_graphicals;
374
375 for ( auto const & x : this_graphical )
376 {
377 the_graphicals.push_back ( x.second );
378 }
379
380 return the_graphicals;
381}
382
friend class dbe::config::api::get::attribute
static T linked(dunedaq::conffwk::ConfigObject &item, dunedaq::conffwk::relationship_t const &relation)
void parse_graphical(std::shared_ptr< dunedaq::conffwk::Configuration >, dunedaq::conffwk::ConfigObject &)
std::vector< Window > windows() const
Window window(std::string const &) const
void parse_window(std::shared_ptr< dunedaq::conffwk::Configuration >, dunedaq::conffwk::ConfigObject &)
GraphicalClass graphical(std::string const &) const
std::vector< GraphicalClass > graphicals() const
ViewConfiguration view(std::string const &) const
info(std::vector< std::string > const &file)
std::vector< ViewConfiguration > views() const
Represents database objects.
const std::string & UID() const noexcept
Return object identity.
const std::string & class_name() const noexcept
Return object's class name.
Defines base class for cache of template objects.
#define ERROR(...)
Definition messenger.hpp:88
bool is_simple(dunedaq::conffwk::relationship_t const &)
std::string const parse(ers::Issue const &)
bool to< bool >(QStringList const &DataList, dunedaq::conffwk::int_format_t Format)
QList< DualRelationship > DualRelationships
QList< InitAttributeFromEnv > NeedToInitialize
QStringList GraphicalClassesList
const std::vector< attribute_t > p_attributes
Definition Schema.hpp:163
const std::vector< relationship_t > p_relationships
Definition Schema.hpp:164