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