53{
54
55
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;
61
62 for(int i = 1; i < argc; i++) {
63 const char * cp = argv[i];
64 if(!strcmp(cp, "-h") || !strcmp(cp, "--help")) {
66 return 0;
67 }
68 if(!strcmp(cp, "-t") || !strcmp(cp, "--init-children")) {
69 init_children = true;
70 }
71 else if(!strcmp(cp, "-d") || !strcmp(cp, "--data")) {
72 if(++i == argc || argv[i][0] ==
'-') {
no_param(cp); }
else { db_name = argv[i]; }
73 }
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]; }
76 }
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]; }
79 }
80 else if(!strcmp(cp, "-q") || !strcmp(cp, "--query")) {
81 if(++i == argc || argv[i][0] ==
'-') {
no_param(cp); }
else { query = argv[i]; }
82 }
83 else {
84 std::cerr << "ERROR: bad parameter " << cp << std::endl;
86 return (EXIT_FAILURE);
87 }
88 }
89
90 if(db_name == nullptr) {
91 std::cerr << "ERROR: no database name provided\n";
92 return (EXIT_FAILURE);
93 }
94
95 if(class_name.empty()) {
96 std::cerr << "ERROR: no class name provided\n";
97 return (EXIT_FAILURE);
98 }
99
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);
103 }
104
105
106std::cout << std::boolalpha;
107
108 try {
110
111 if(!conf.loaded()) {
112 std::cerr << "Can not load database: " << db_name << std::endl;
113 return (EXIT_FAILURE);
114 }
115
116 std::vector< dunedaq::conffwk::ConfigObject > objects;
117
118 if(object_id) {
120 try {
121 conf.get(class_name, object_id, obj, 1);
122 }
124 std::cerr << "Can not get object \'" << object_id << "\' of class \'" << class_name << "\':\n" << ex << std::endl;
125 return (EXIT_FAILURE);
126 }
127 objects.push_back(obj);
128 }
129 else {
130 try {
131 conf.get(class_name, objects, query, 1);
132 }
134 std::cerr << "Can not get objects of class \'" << class_name << "\':\n" << ex << std::endl;
135 return (EXIT_FAILURE);
136 }
137 }
138
139 struct SortByUId {
141 return (o1->
UID() < o2->
UID());
142 };
143 };
144
145 std::set< dunedaq::conffwk::ConfigObject *, SortByUId > sorted_objects;
146
147 for(auto& i : objects)
148 sorted_objects.insert(&i);
149
150 for(auto& i : sorted_objects) {
151 if(class_name == "EndpointLocation") {
153 }
154 else if(class_name == "TimingController") {
156 }
157 else if(class_name == "TimingControllerConf") {
159 }
160 else if(class_name == "TimingEndpointController") {
162 }
163 else if(class_name == "TimingEndpointControllerBase") {
165 }
166 else if(class_name == "TimingEndpointControllerConf") {
168 }
169 else if(class_name == "TimingFanoutController") {
171 }
172 else if(class_name == "TimingFanoutControllerConf") {
174 }
175 else if(class_name == "TimingFanoutDevice") {
177 }
178 else if(class_name == "TimingHardwareInterface") {
180 }
181 else if(class_name == "TimingHardwareInterfaceConf") {
183 }
184 else if(class_name == "TimingHardwareManagerBase") {
186 }
187 else if(class_name == "TimingHardwareManagerConf") {
189 }
190 else if(class_name == "TimingHardwareManagerPDII") {
192 }
193 else if(class_name == "TimingMasterControllerBase") {
195 }
196 else if(class_name == "TimingMasterControllerConf") {
198 }
199 else if(class_name == "TimingMasterControllerPDII") {
201 }
202 else if(class_name == "TimingMasterEndpointScanPayload") {
204 }
205 else {
206 std::cerr << "ERROR: do not know how to dump object of " << class_name << " class\n";
207 return (EXIT_FAILURE);
208 }
209 }
210 }
211 catch (dunedaq::conffwk::Exception & ex) {
212 std::cerr << "Caught " << ex << std::endl;
213 return (EXIT_FAILURE);
214 }
215
216 return 0;
217}
Represents database objects.
const std::string & UID() const noexcept
Return object identity.
Defines base class for cache of template objects.
Try to access non-existent object or class.
static void no_param(const char *s)