52int main(
int argc,
char *argv[])
56 const char * db_name =
nullptr;
57 const char * object_id =
nullptr;
58 const char * query =
"";
59 std::string class_name;
60 bool init_children =
false;
62 for(
int i = 1; i < argc; i++) {
63 const char * cp = argv[i];
64 if(!strcmp(cp,
"-h") || !strcmp(cp,
"--help")) {
68 if(!strcmp(cp,
"-t") || !strcmp(cp,
"--init-children")) {
71 else if(!strcmp(cp,
"-d") || !strcmp(cp,
"--data")) {
72 if(++i == argc || argv[i][0] ==
'-') {
no_param(cp); }
else { db_name = argv[i]; }
74 else if(!strcmp(cp,
"-c") || !strcmp(cp,
"--class-name")) {
75 if(++i == argc || argv[i][0] ==
'-') {
no_param(cp); }
else { class_name = argv[i]; }
77 else if(!strcmp(cp,
"-i") || !strcmp(cp,
"--object-id")) {
78 if(++i == argc || argv[i][0] ==
'-') {
no_param(cp); }
else { object_id = argv[i]; }
80 else if(!strcmp(cp,
"-q") || !strcmp(cp,
"--query")) {
81 if(++i == argc || argv[i][0] ==
'-') {
no_param(cp); }
else { query = argv[i]; }
84 std::cerr <<
"ERROR: bad parameter " << cp << std::endl;
86 return (EXIT_FAILURE);
90 if(db_name ==
nullptr) {
91 std::cerr <<
"ERROR: no database name provided\n";
92 return (EXIT_FAILURE);
95 if(class_name.empty()) {
96 std::cerr <<
"ERROR: no class name provided\n";
97 return (EXIT_FAILURE);
100 if(*query != 0 && object_id !=
nullptr) {
101 std::cerr <<
"ERROR: only one parameter -i or -q can be provided\n";
102 return (EXIT_FAILURE);
106std::cout << std::boolalpha;
112 std::cerr <<
"Can not load database: " << db_name << std::endl;
113 return (EXIT_FAILURE);
116 std::vector< dunedaq::conffwk::ConfigObject > objects;
121 conf.
get(class_name, object_id, obj, 1);
124 std::cerr <<
"Can not get object \'" << object_id <<
"\' of class \'" << class_name <<
"\':\n" << ex << std::endl;
125 return (EXIT_FAILURE);
127 objects.push_back(obj);
131 conf.
get(class_name, objects, query, 1);
134 std::cerr <<
"Can not get objects of class \'" << class_name <<
"\':\n" << ex << std::endl;
135 return (EXIT_FAILURE);
141 return (o1->
UID() < o2->
UID());
145 std::set< dunedaq::conffwk::ConfigObject *, SortByUId > sorted_objects;
147 for(
auto& i : objects)
148 sorted_objects.insert(&i);
150 for(
auto& i : sorted_objects) {
151 if(class_name ==
"EndpointLocation") {
154 else if(class_name ==
"TimingController") {
157 else if(class_name ==
"TimingControllerConf") {
160 else if(class_name ==
"TimingEndpointController") {
163 else if(class_name ==
"TimingEndpointControllerBase") {
166 else if(class_name ==
"TimingEndpointControllerConf") {
169 else if(class_name ==
"TimingFanoutController") {
172 else if(class_name ==
"TimingFanoutControllerConf") {
175 else if(class_name ==
"TimingFanoutDevice") {
178 else if(class_name ==
"TimingHardwareInterface") {
181 else if(class_name ==
"TimingHardwareInterfaceConf") {
184 else if(class_name ==
"TimingHardwareManagerBase") {
187 else if(class_name ==
"TimingHardwareManagerConf") {
190 else if(class_name ==
"TimingHardwareManagerPDII") {
193 else if(class_name ==
"TimingMasterControllerBase") {
196 else if(class_name ==
"TimingMasterControllerConf") {
199 else if(class_name ==
"TimingMasterControllerPDII") {
202 else if(class_name ==
"TimingMasterEndpointScanPayload") {
206 std::cerr <<
"ERROR: do not know how to dump object of " << class_name <<
" class\n";
207 return (EXIT_FAILURE);
211 catch (dunedaq::conffwk::Exception & ex) {
212 std::cerr <<
"Caught " << ex << std::endl;
213 return (EXIT_FAILURE);
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).