DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dump_dunedaq__confmodel.cpp
Go to the documentation of this file.
1 // *** this file is generated by oksdalgen ***
2
5
36#include "confmodel/GeoId.hpp"
47#include "confmodel/Queue.hpp"
56#include "confmodel/Segment.hpp"
57#include "confmodel/Service.hpp"
58#include "confmodel/Session.hpp"
64
65
66static void usage(const char * s)
67{
68 std::cout << s << " -d db-name -c class-name [-q query | -i object-id] [-t]\n"
69 "\n"
70 "Options/Arguments:\n"
71 " -d | --data db-name mandatory name of the database\n"
72 " -c | --class-name class-name mandatory name of class\n"
73 " -q | --query query optional query to select class objects\n"
74 " -i | --object-id object-id optional identity to select one object\n"
75 " -t | --init-children all referenced objects are initialized (is used\n"
76 " for debug purposes and performance measurements)\n"
77 " -h | --help print this message\n"
78 "\n"
79 "Description:\n"
80 " The program prints out object(s) of given class.\n"
81 " If no query or object id is provided, all objects of the class are printed.\n"
82 " It is automatically generated by oksdalgen utility.\n"
83 "\n";
84}
85
86static void no_param(const char * s)
87{
88 std::cerr << "ERROR: the required argument for option \'" << s << "\' is missing\n\n";
89 exit (EXIT_FAILURE);
90}
91
92int main(int argc, char *argv[])
93{
94 // parse parameters
95
96 const char * db_name = nullptr;
97 const char * object_id = nullptr;
98 const char * query = "";
99 std::string class_name;
100 bool init_children = false;
101
102 for(int i = 1; i < argc; i++) {
103 const char * cp = argv[i];
104 if(!strcmp(cp, "-h") || !strcmp(cp, "--help")) {
105 usage(argv[0]);
106 return 0;
107 }
108 if(!strcmp(cp, "-t") || !strcmp(cp, "--init-children")) {
109 init_children = true;
110 }
111 else if(!strcmp(cp, "-d") || !strcmp(cp, "--data")) {
112 if(++i == argc || argv[i][0] == '-') { no_param(cp); } else { db_name = argv[i]; }
113 }
114 else if(!strcmp(cp, "-c") || !strcmp(cp, "--class-name")) {
115 if(++i == argc || argv[i][0] == '-') { no_param(cp); } else { class_name = argv[i]; }
116 }
117 else if(!strcmp(cp, "-i") || !strcmp(cp, "--object-id")) {
118 if(++i == argc || argv[i][0] == '-') { no_param(cp); } else { object_id = argv[i]; }
119 }
120 else if(!strcmp(cp, "-q") || !strcmp(cp, "--query")) {
121 if(++i == argc || argv[i][0] == '-') { no_param(cp); } else { query = argv[i]; }
122 }
123 else {
124 std::cerr << "ERROR: bad parameter " << cp << std::endl;
125 usage(argv[0]);
126 return (EXIT_FAILURE);
127 }
128 }
129
130 if(db_name == nullptr) {
131 std::cerr << "ERROR: no database name provided\n";
132 return (EXIT_FAILURE);
133 }
134
135 if(class_name.empty()) {
136 std::cerr << "ERROR: no class name provided\n";
137 return (EXIT_FAILURE);
138 }
139
140 if(*query != 0 && object_id != nullptr) {
141 std::cerr << "ERROR: only one parameter -i or -q can be provided\n";
142 return (EXIT_FAILURE);
143 }
144
145
146std::cout << std::boolalpha;
147
148 try {
150
151 if(!conf.loaded()) {
152 std::cerr << "Can not load database: " << db_name << std::endl;
153 return (EXIT_FAILURE);
154 }
155
156 std::vector< dunedaq::conffwk::ConfigObject > objects;
157
158 if(object_id) {
160 try {
161 conf.get(class_name, object_id, obj, 1);
162 }
163 catch (dunedaq::conffwk::NotFound & ex) {
164 std::cerr << "Can not get object \'" << object_id << "\' of class \'" << class_name << "\':\n" << ex << std::endl;
165 return (EXIT_FAILURE);
166 }
167 objects.push_back(obj);
168 }
169 else {
170 try {
171 conf.get(class_name, objects, query, 1);
172 }
173 catch (dunedaq::conffwk::NotFound & ex) {
174 std::cerr << "Can not get objects of class \'" << class_name << "\':\n" << ex << std::endl;
175 return (EXIT_FAILURE);
176 }
177 }
178
179 struct SortByUId {
180 bool operator() (const dunedaq::conffwk::ConfigObject * o1, const dunedaq::conffwk::ConfigObject * o2) const {
181 return (o1->UID() < o2->UID());
182 };
183 };
184
185 std::set< dunedaq::conffwk::ConfigObject *, SortByUId > sorted_objects;
186
187 for(auto& i : objects)
188 sorted_objects.insert(&i);
189
190 for(auto& i : sorted_objects) {
191 if(class_name == "ActionPlan") {
192 std::cout << *conf.get<dunedaq::confmodel::ActionPlan>(*i, init_children) << std::endl;
193 }
194 else if(class_name == "Application") {
195 std::cout << *conf.get<dunedaq::confmodel::Application>(*i, init_children) << std::endl;
196 }
197 else if(class_name == "Connection") {
198 std::cout << *conf.get<dunedaq::confmodel::Connection>(*i, init_children) << std::endl;
199 }
200 else if(class_name == "ConnectionService") {
201 std::cout << *conf.get<dunedaq::confmodel::ConnectionService>(*i, init_children) << std::endl;
202 }
203 else if(class_name == "ConnectivityService") {
204 std::cout << *conf.get<dunedaq::confmodel::ConnectivityService>(*i, init_children) << std::endl;
205 }
206 else if(class_name == "DaqApplication") {
207 std::cout << *conf.get<dunedaq::confmodel::DaqApplication>(*i, init_children) << std::endl;
208 }
209 else if(class_name == "DaqModule") {
210 std::cout << *conf.get<dunedaq::confmodel::DaqModule>(*i, init_children) << std::endl;
211 }
212 else if(class_name == "DaqModulesGroup") {
213 std::cout << *conf.get<dunedaq::confmodel::DaqModulesGroup>(*i, init_children) << std::endl;
214 }
215 else if(class_name == "DaqModulesGroupById") {
216 std::cout << *conf.get<dunedaq::confmodel::DaqModulesGroupById>(*i, init_children) << std::endl;
217 }
218 else if(class_name == "DaqModulesGroupByType") {
219 std::cout << *conf.get<dunedaq::confmodel::DaqModulesGroupByType>(*i, init_children) << std::endl;
220 }
221 else if(class_name == "DetDataReceiver") {
222 std::cout << *conf.get<dunedaq::confmodel::DetDataReceiver>(*i, init_children) << std::endl;
223 }
224 else if(class_name == "DetDataSender") {
225 std::cout << *conf.get<dunedaq::confmodel::DetDataSender>(*i, init_children) << std::endl;
226 }
227 else if(class_name == "DetectorConfig") {
228 std::cout << *conf.get<dunedaq::confmodel::DetectorConfig>(*i, init_children) << std::endl;
229 }
230 else if(class_name == "DetectorStream") {
231 std::cout << *conf.get<dunedaq::confmodel::DetectorStream>(*i, init_children) << std::endl;
232 }
233 else if(class_name == "DetectorToDaqConnection") {
234 std::cout << *conf.get<dunedaq::confmodel::DetectorToDaqConnection>(*i, init_children) << std::endl;
235 }
236 else if(class_name == "DummyApplication") {
237 std::cout << *conf.get<dunedaq::confmodel::DummyApplication>(*i, init_children) << std::endl;
238 }
239 else if(class_name == "DummyD2D") {
240 std::cout << *conf.get<dunedaq::confmodel::DummyD2D>(*i, init_children) << std::endl;
241 }
242 else if(class_name == "DummyReceiver") {
243 std::cout << *conf.get<dunedaq::confmodel::DummyReceiver>(*i, init_children) << std::endl;
244 }
245 else if(class_name == "DummyResource") {
246 std::cout << *conf.get<dunedaq::confmodel::DummyResource>(*i, init_children) << std::endl;
247 }
248 else if(class_name == "DummyResourceSet") {
249 std::cout << *conf.get<dunedaq::confmodel::DummyResourceSet>(*i, init_children) << std::endl;
250 }
251 else if(class_name == "DummyResourceSetAND") {
252 std::cout << *conf.get<dunedaq::confmodel::DummyResourceSetAND>(*i, init_children) << std::endl;
253 }
254 else if(class_name == "DummySender") {
255 std::cout << *conf.get<dunedaq::confmodel::DummySender>(*i, init_children) << std::endl;
256 }
257 else if(class_name == "DummySmartResource") {
258 std::cout << *conf.get<dunedaq::confmodel::DummySmartResource>(*i, init_children) << std::endl;
259 }
260 else if(class_name == "DummyStream") {
261 std::cout << *conf.get<dunedaq::confmodel::DummyStream>(*i, init_children) << std::endl;
262 }
263 else if(class_name == "FSMCommand") {
264 std::cout << *conf.get<dunedaq::confmodel::FSMCommand>(*i, init_children) << std::endl;
265 }
266 else if(class_name == "FSMaction") {
267 std::cout << *conf.get<dunedaq::confmodel::FSMaction>(*i, init_children) << std::endl;
268 }
269 else if(class_name == "FSMconfiguration") {
270 std::cout << *conf.get<dunedaq::confmodel::FSMconfiguration>(*i, init_children) << std::endl;
271 }
272 else if(class_name == "FSMsequence") {
273 std::cout << *conf.get<dunedaq::confmodel::FSMsequence>(*i, init_children) << std::endl;
274 }
275 else if(class_name == "FSMtransition") {
276 std::cout << *conf.get<dunedaq::confmodel::FSMtransition>(*i, init_children) << std::endl;
277 }
278 else if(class_name == "FSMxTransition") {
279 std::cout << *conf.get<dunedaq::confmodel::FSMxTransition>(*i, init_children) << std::endl;
280 }
281 else if(class_name == "GeoId") {
282 std::cout << *conf.get<dunedaq::confmodel::GeoId>(*i, init_children) << std::endl;
283 }
284 else if(class_name == "HostComponent") {
285 std::cout << *conf.get<dunedaq::confmodel::HostComponent>(*i, init_children) << std::endl;
286 }
287 else if(class_name == "Jsonable") {
288 std::cout << *conf.get<dunedaq::confmodel::Jsonable>(*i, init_children) << std::endl;
289 }
290 else if(class_name == "JsonableTest") {
291 std::cout << *conf.get<dunedaq::confmodel::JsonableTest>(*i, init_children) << std::endl;
292 }
293 else if(class_name == "NetworkConnection") {
294 std::cout << *conf.get<dunedaq::confmodel::NetworkConnection>(*i, init_children) << std::endl;
295 }
296 else if(class_name == "NetworkDevice") {
297 std::cout << *conf.get<dunedaq::confmodel::NetworkDevice>(*i, init_children) << std::endl;
298 }
299 else if(class_name == "NetworkInterface") {
300 std::cout << *conf.get<dunedaq::confmodel::NetworkInterface>(*i, init_children) << std::endl;
301 }
302 else if(class_name == "OpMonConf") {
303 std::cout << *conf.get<dunedaq::confmodel::OpMonConf>(*i, init_children) << std::endl;
304 }
305 else if(class_name == "OpMonURI") {
306 std::cout << *conf.get<dunedaq::confmodel::OpMonURI>(*i, init_children) << std::endl;
307 }
308 else if(class_name == "PhysicalHost") {
309 std::cout << *conf.get<dunedaq::confmodel::PhysicalHost>(*i, init_children) << std::endl;
310 }
311 else if(class_name == "ProcessingResource") {
312 std::cout << *conf.get<dunedaq::confmodel::ProcessingResource>(*i, init_children) << std::endl;
313 }
314 else if(class_name == "Queue") {
315 std::cout << *conf.get<dunedaq::confmodel::Queue>(*i, init_children) << std::endl;
316 }
317 else if(class_name == "QueueWithSourceId") {
318 std::cout << *conf.get<dunedaq::confmodel::QueueWithSourceId>(*i, init_children) << std::endl;
319 }
320 else if(class_name == "RCApplication") {
321 std::cout << *conf.get<dunedaq::confmodel::RCApplication>(*i, init_children) << std::endl;
322 }
323 else if(class_name == "RCBroadcaster") {
324 std::cout << *conf.get<dunedaq::confmodel::RCBroadcaster>(*i, init_children) << std::endl;
325 }
326 else if(class_name == "Resource") {
327 std::cout << *conf.get<dunedaq::confmodel::Resource>(*i, init_children) << std::endl;
328 }
329 else if(class_name == "ResourceSet") {
330 std::cout << *conf.get<dunedaq::confmodel::ResourceSet>(*i, init_children) << std::endl;
331 }
332 else if(class_name == "ResourceSetDisableAND") {
333 std::cout << *conf.get<dunedaq::confmodel::ResourceSetDisableAND>(*i, init_children) << std::endl;
334 }
335 else if(class_name == "ResourceSetDisableOR") {
336 std::cout << *conf.get<dunedaq::confmodel::ResourceSetDisableOR>(*i, init_children) << std::endl;
337 }
338 else if(class_name == "ResourceTree") {
339 std::cout << *conf.get<dunedaq::confmodel::ResourceTree>(*i, init_children) << std::endl;
340 }
341 else if(class_name == "Segment") {
342 std::cout << *conf.get<dunedaq::confmodel::Segment>(*i, init_children) << std::endl;
343 }
344 else if(class_name == "Service") {
345 std::cout << *conf.get<dunedaq::confmodel::Service>(*i, init_children) << std::endl;
346 }
347 else if(class_name == "Session") {
348 std::cout << *conf.get<dunedaq::confmodel::Session>(*i, init_children) << std::endl;
349 }
350 else if(class_name == "StorageDevice") {
351 std::cout << *conf.get<dunedaq::confmodel::StorageDevice>(*i, init_children) << std::endl;
352 }
353 else if(class_name == "Variable") {
354 std::cout << *conf.get<dunedaq::confmodel::Variable>(*i, init_children) << std::endl;
355 }
356 else if(class_name == "VariableBase") {
357 std::cout << *conf.get<dunedaq::confmodel::VariableBase>(*i, init_children) << std::endl;
358 }
359 else if(class_name == "VariableSet") {
360 std::cout << *conf.get<dunedaq::confmodel::VariableSet>(*i, init_children) << std::endl;
361 }
362 else if(class_name == "VirtualHost") {
363 std::cout << *conf.get<dunedaq::confmodel::VirtualHost>(*i, init_children) << std::endl;
364 }
365 else {
366 std::cerr << "ERROR: do not know how to dump object of " << class_name << " class\n";
367 return (EXIT_FAILURE);
368 }
369 }
370 }
371 catch (dunedaq::conffwk::Exception & ex) {
372 std::cerr << "Caught " << ex << std::endl;
373 return (EXIT_FAILURE);
374 }
375
376 return 0;
377}
Represents database objects.
const std::string & UID() const noexcept
Return object identity.
Defines base class for cache of template objects.
void get(const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
Get object by class name and object id (multi-thread safe).
bool loaded() const noexcept
Check if database is correctly loaded.
conffwk entry point
int main(int argc, char *argv[])
static void no_param(const char *s)
static void usage()