DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
build
listrev
codegen
src
dump_dunedaq__listrev__dal.cpp
Go to the documentation of this file.
1
// *** this file is generated by oksdalgen ***
2
3
#include "
conffwk/ConfigObject.hpp
"
4
#include "
conffwk/Configuration.hpp
"
5
6
#include "
listrev/dal/ListRevModule.hpp
"
7
#include "
listrev/dal/ListReverser.hpp
"
8
#include "
listrev/dal/RandomDataListGenerator.hpp
"
9
#include "
listrev/dal/RandomListGeneratorSet.hpp
"
10
#include "
listrev/dal/ReversedListValidator.hpp
"
11
12
13
static
void
usage
(
const
char
* s)
14
{
15
std::cout << s <<
" -d db-name -c class-name [-q query | -i object-id] [-t]\n"
16
"\n"
17
"Options/Arguments:\n"
18
" -d | --data db-name mandatory name of the database\n"
19
" -c | --class-name class-name mandatory name of class\n"
20
" -q | --query query optional query to select class objects\n"
21
" -i | --object-id object-id optional identity to select one object\n"
22
" -t | --init-children all referenced objects are initialized (is used\n"
23
" for debug purposes and performance measurements)\n"
24
" -h | --help print this message\n"
25
"\n"
26
"Description:\n"
27
" The program prints out object(s) of given class.\n"
28
" If no query or object id is provided, all objects of the class are printed.\n"
29
" It is automatically generated by oksdalgen utility.\n"
30
"\n"
;
31
}
32
33
static
void
no_param
(
const
char
* s)
34
{
35
std::cerr <<
"ERROR: the required argument for option \'"
<< s <<
"\' is missing\n\n"
;
36
exit (EXIT_FAILURE);
37
}
38
39
int
main
(
int
argc,
char
*argv[])
40
{
41
// parse parameters
42
43
const
char
* db_name =
nullptr
;
44
const
char
* object_id =
nullptr
;
45
const
char
* query =
""
;
46
std::string class_name;
47
bool
init_children =
false
;
48
49
for
(
int
i = 1; i < argc; i++) {
50
const
char
* cp = argv[i];
51
if
(!strcmp(cp,
"-h"
) || !strcmp(cp,
"--help"
)) {
52
usage
(argv[0]);
53
return
0;
54
}
55
if
(!strcmp(cp,
"-t"
) || !strcmp(cp,
"--init-children"
)) {
56
init_children =
true
;
57
}
58
else
if
(!strcmp(cp,
"-d"
) || !strcmp(cp,
"--data"
)) {
59
if
(++i == argc || argv[i][0] ==
'-'
) {
no_param
(cp); }
else
{ db_name = argv[i]; }
60
}
61
else
if
(!strcmp(cp,
"-c"
) || !strcmp(cp,
"--class-name"
)) {
62
if
(++i == argc || argv[i][0] ==
'-'
) {
no_param
(cp); }
else
{ class_name = argv[i]; }
63
}
64
else
if
(!strcmp(cp,
"-i"
) || !strcmp(cp,
"--object-id"
)) {
65
if
(++i == argc || argv[i][0] ==
'-'
) {
no_param
(cp); }
else
{ object_id = argv[i]; }
66
}
67
else
if
(!strcmp(cp,
"-q"
) || !strcmp(cp,
"--query"
)) {
68
if
(++i == argc || argv[i][0] ==
'-'
) {
no_param
(cp); }
else
{ query = argv[i]; }
69
}
70
else
{
71
std::cerr <<
"ERROR: bad parameter "
<< cp << std::endl;
72
usage
(argv[0]);
73
return
(EXIT_FAILURE);
74
}
75
}
76
77
if
(db_name ==
nullptr
) {
78
std::cerr <<
"ERROR: no database name provided\n"
;
79
return
(EXIT_FAILURE);
80
}
81
82
if
(class_name.empty()) {
83
std::cerr <<
"ERROR: no class name provided\n"
;
84
return
(EXIT_FAILURE);
85
}
86
87
if
(*query != 0 && object_id !=
nullptr
) {
88
std::cerr <<
"ERROR: only one parameter -i or -q can be provided\n"
;
89
return
(EXIT_FAILURE);
90
}
91
92
93
std::cout << std::boolalpha;
94
95
try
{
96
dunedaq::conffwk::Configuration
conf(db_name);
97
98
if
(!conf.
loaded
()) {
99
std::cerr <<
"Can not load database: "
<< db_name << std::endl;
100
return
(EXIT_FAILURE);
101
}
102
103
std::vector< dunedaq::conffwk::ConfigObject > objects;
104
105
if
(object_id) {
106
dunedaq::conffwk::ConfigObject
obj;
107
try
{
108
conf.
get
(class_name, object_id, obj, 1);
109
}
110
catch
(dunedaq::conffwk::NotFound & ex) {
111
std::cerr <<
"Can not get object \'"
<< object_id <<
"\' of class \'"
<< class_name <<
"\':\n"
<< ex << std::endl;
112
return
(EXIT_FAILURE);
113
}
114
objects.push_back(obj);
115
}
116
else
{
117
try
{
118
conf.
get
(class_name, objects, query, 1);
119
}
120
catch
(dunedaq::conffwk::NotFound & ex) {
121
std::cerr <<
"Can not get objects of class \'"
<< class_name <<
"\':\n"
<< ex << std::endl;
122
return
(EXIT_FAILURE);
123
}
124
}
125
126
struct
SortByUId {
127
bool
operator() (
const
dunedaq::conffwk::ConfigObject
* o1,
const
dunedaq::conffwk::ConfigObject
* o2)
const
{
128
return
(o1->
UID
() < o2->
UID
());
129
};
130
};
131
132
std::set< dunedaq::conffwk::ConfigObject *, SortByUId > sorted_objects;
133
134
for
(
auto
& i : objects)
135
sorted_objects.insert(&i);
136
137
for
(
auto
& i : sorted_objects) {
138
if
(class_name ==
"ListRevModule"
) {
139
std::cout << *conf.
get
<
dunedaq::listrev::dal::ListRevModule
>(*i, init_children) << std::endl;
140
}
141
else
if
(class_name ==
"ListReverser"
) {
142
std::cout << *conf.
get
<
dunedaq::listrev::dal::ListReverser
>(*i, init_children) << std::endl;
143
}
144
else
if
(class_name ==
"RandomDataListGenerator"
) {
145
std::cout << *conf.
get
<
dunedaq::listrev::dal::RandomDataListGenerator
>(*i, init_children) << std::endl;
146
}
147
else
if
(class_name ==
"RandomListGeneratorSet"
) {
148
std::cout << *conf.
get
<
dunedaq::listrev::dal::RandomListGeneratorSet
>(*i, init_children) << std::endl;
149
}
150
else
if
(class_name ==
"ReversedListValidator"
) {
151
std::cout << *conf.
get
<
dunedaq::listrev::dal::ReversedListValidator
>(*i, init_children) << std::endl;
152
}
153
else
{
154
std::cerr <<
"ERROR: do not know how to dump object of "
<< class_name <<
" class\n"
;
155
return
(EXIT_FAILURE);
156
}
157
}
158
}
159
catch
(dunedaq::conffwk::Exception & ex) {
160
std::cerr <<
"Caught "
<< ex << std::endl;
161
return
(EXIT_FAILURE);
162
}
163
164
return
0;
165
}
ConfigObject.hpp
dunedaq::conffwk::ConfigObject
Represents database objects.
Definition
ConfigObject.hpp:53
dunedaq::conffwk::ConfigObject::UID
const std::string & UID() const noexcept
Return object identity.
Definition
ConfigObject.hpp:225
dunedaq::conffwk::Configuration
Defines base class for cache of template objects.
Definition
Configuration.hpp:228
dunedaq::conffwk::Configuration::get
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).
Definition
Configuration.cpp:247
dunedaq::conffwk::Configuration::loaded
bool loaded() const noexcept
Check if database is correctly loaded.
Definition
Configuration.cpp:305
dunedaq::listrev::dal::ListRevModule
Definition
ListRevModule.hpp:24
dunedaq::listrev::dal::ListReverser
Definition
ListReverser.hpp:24
dunedaq::listrev::dal::RandomDataListGenerator
Definition
RandomDataListGenerator.hpp:24
dunedaq::listrev::dal::RandomListGeneratorSet
Definition
RandomListGeneratorSet.hpp:32
dunedaq::listrev::dal::ReversedListValidator
Definition
ReversedListValidator.hpp:35
Configuration.hpp
conffwk entry point
main
int main(int argc, char *argv[])
Definition
dump_dunedaq__listrev__dal.cpp:39
no_param
static void no_param(const char *s)
Definition
dump_dunedaq__listrev__dal.cpp:33
ListRevModule.hpp
ListReverser.hpp
RandomDataListGenerator.hpp
RandomListGeneratorSet.hpp
ReversedListValidator.hpp
usage
static void usage()
Definition
oks_get_data.cxx:22
Generated on
for DUNE-DAQ by
1.17.0