Jpp  master_rocky-43-ge265d140c
the software that should make you happy
JSelectorSupportkit.hh
Go to the documentation of this file.
1 #ifndef __JDB_JSELECTORSUPPORTKIT__
2 #define __JDB_JSELECTORSUPPORTKIT__
3 
4 #include <string>
5 
6 #include "JLang/JConversion.hh"
7 
8 #include "JDB/JDBString.hh"
9 #include "JDB/JSelector.hh"
10 #include "JDB/JPBS_t.hh"
11 #include "JDB/JDBTypes.hh"
12 
13 
14 /**
15  * \author mdejong
16  */
17 
18 namespace JDATABASE {};
19 namespace JPP { using namespace JDATABASE; }
20 
21 namespace JDATABASE {
22 
23  namespace APIV2 {}
24 
25  using JLANG::JConversion;
26 
27  /**
28  * Template definition for getting table specific selector.\n
29  * Note that the template argument
30  * <tt>T</tt> refers to the targeted table and
31  * <tt>JTable_t</tt> to the actual table.\n
32  * This allows to use pointers to data members for column names rather than text strings.
33  */
34  template<class T, class JTable_t = T, bool is_same = JConversion<T, JTable_t>::is_same>
35  struct getSelector;
36 
37  /**
38  * Template specialisation for getting table specific selector.
39  */
40  template<class T>
41  struct getSelector<T, JPersons, true> :
42  public JSelector
43  {
44  /**
45  * Get selector for the given table based on the location identifier.
46  *
47  * \param locID location identifier
48  */
49  getSelector(const JDBString& locID)
50  {
51  this->add(&T::LOCATIONID, locID);
52  }
53 
54  /**
55  * Get selector for the given table based on the login name.
56  *
57  * \param login login string
58  */
59  getSelector(const std::string& login)
60  {
61  this->add(&T::LOGIN, login);
62  }
63  };
64 
65 
66  /**
67  * Template specialisation for getting table specific selector.
68  */
69  template<class T>
70  struct getSelector<T, JDetectors, true> :
71  public JSelector
72  {
73  /**
74  * Get selector for the given table based on the serial number.
75  *
76  * \param id serial number
77  */
78  getSelector(const int id)
79  {
80  this->add(&T::SERIALNUMBER, id);
81  }
82 
83 
84  /**
85  * Get selector for the given table based on the object identifier.
86  *
87  * \param detid detector identifier
88  */
89  getSelector(const std::string& detid)
90  {
91  this->add(&T::OID, detid);
92  }
93  };
94 
95 
96  /**
97  * Template specialisation for getting table specific selector.
98  */
99  template<class T>
100  struct getSelector<T, JRuns, true> :
101  public JSelector
102  {
103  /**
104  * Get selector for the given table based on the detector serial number.
105  *
106  * \param id detector serial number
107  */
108  getSelector(const int id)
109  {
110  this->add(&T::DETID, id);
111  }
112 
113 
114  /**
115  * Get selector for the given table based on the detector serial number and run number.
116  *
117  * \param id detector serial number
118  * \param run run number
119  */
120  getSelector(const int id,
121  const int run)
122  {
123  this->add(&T::DETID, id);
124  this->add(&T::RUN, run);
125  }
126 
127 
128  /**
129  * Get selector for the given table based on the detector serial number and run number.
130  *
131  * \param id detector serial number
132  * \param minrun minimal run number
133  * \param maxrun maximal run number
134  */
135  getSelector(const int id,
136  const int minrun,
137  const int maxrun)
138  {
139  this->add(&T::DETID, id);
140  this->add(&T::RUN, minrun, Selector::RelOp::GreaterEqual);
141  this->add(&T::RUN, maxrun, Selector::RelOp::LessEqual);
142  }
143  };
144 
145 
146  /**
147  * Template specialisation for getting table specific selector.
148  */
149  template<class T>
150  struct getSelector<T, JDatalogNumbers, true> :
151  public JSelector
152  {
153  /**
154  * Get selector for the given table based on the detector identifier and a run range.
155  *
156  * \param detid detector identifier
157  * \param minrun minimal run number
158  * \param maxrun maximal run number
159  */
160  getSelector(const std::string& detid,
161  const int minrun,
162  const int maxrun)
163  {
164  this->add(&T::DETID, detid);
165  this->add("MINRUN", minrun);
166  this->add("MAXRUN", maxrun);
167  }
168  };
169 
170 
171  /**
172  * Template specialisation for getting table specific selector.
173  */
174  template<class T>
175  struct getSelector<T, JAllParams, true> :
176  public JSelector
177  {
178  /**
179  * Get selector for the given table based on the sub-system identifier.
180  *
181  * \param ssid ssid
182  */
183  getSelector(const std::string& ssid)
184  {
185  this->add(&T::SUBSYSTEMID, ssid);
186  }
187  };
188 
189 
190  /**
191  * Template specialisation for getting table specific selector.
192  */
193  template<class T>
194  struct getSelector<T, JToAshort, true> :
195  public JSelector
196  {
197  /**
198  * Get selector for the given table based on the detector identifier and a run range.
199  *
200  * \param detid detector identifier
201  * \param minrun minimal run number
202  * \param maxrun maximal run number
203  */
204  getSelector(const std::string& detid,
205  const int minrun,
206  const int maxrun)
207  {
208  this->add(&T::DETID, detid);
209  this->add("MINRUN", minrun);
210  this->add("MAXRUN", maxrun);
211  }
212  };
213 
214 
215  /**
216  * Template specialisation for getting table specific selector.
217  */
218  template<class T>
219  struct getSelector<T, JCLBMap, true> :
220  public JSelector
221  {
222  /**
223  * Get selector for the given table based on the detector identifier.
224  *
225  * \param detoid detector identifier
226  */
227  getSelector(const std::string& detoid)
228  {
229  this->add(&T::DETOID, detoid);
230  }
231  };
232 
233 
234  /**
235  * Template specialisation for getting table specific selector.
236  */
237  template<class T>
239  public JSelector
240  {
241  /**
242  * Get selector for the given table based on the serial number.
243  *
244  * \param id serial number
245  */
246  getSelector(const int id)
247  {
248  this->add(&T::DETID, id);
249  }
250 
251 
252  /**
253  * Get selector for the given table based on the detector identifier and a run range.
254  *
255  * \param detoid detector identifier
256  */
257  getSelector(const std::string& detoid)
258  {
259  this->add(&T::DETOID, detoid);
260  }
261  };
262 
263 
264  /**
265  * Template specialisation for getting table specific selector.
266  */
267  template<class T>
268  struct getSelector<T, JRunSummaryNumbers, true> :
269  public JSelector
270  {
271  /**
272  * Get selector for the given table based on the detector identifier and a run range.
273  *
274  * \param detid detector identifier
275  * \param minrun minimal run number
276  * \param maxrun maximal run number
277  */
278  getSelector(const std::string& detid,
279  const int minrun,
280  const int maxrun)
281  {
282  this->add(&T::DETID, detid);
283  this->add("MINRUN", minrun);
284  this->add("MAXRUN", maxrun);
285  }
286  };
287 
288 
289  /**
290  * Template specialisation for getting table specific selector.
291  */
292  template<class T>
293  struct getSelector<T, JRunQuality, true> :
294  public getSelector<JRunSummaryNumbers>
295  {
296  /**
297  * Get selector for the given table based on the detector identifier and a run range.
298  *
299  * \param detid detector identifier
300  * \param minrun minimal run number
301  * \param maxrun maximal run number
302  */
303  getSelector(const std::string& detid,
304  const int minrun,
305  const int maxrun) :
306  getSelector<JRunSummaryNumbers>(detid, minrun, maxrun)
307  {}
308  };
309 
310 
311  /**
312  * Template specialisation for getting table specific selector.
313  */
314  template<class T>
315  struct getSelector<T, JRunsetupParams, true> :
316  public JSelector
317  {
318  /**
319  * Get selector for the given table based on the detector and run-setup identifier.
320  *
321  * \param detid detector identifier
322  * \param rs_oid runsetup identifier
323  */
324  getSelector(const std::string& detid,
325  const std::string& rs_oid)
326  {
327  this->add(&T::DETID, detid);
328  this->add(&T::RS_OID, rs_oid);
329  }
330  };
331 
332 
333  /**
334  * Template specialisation for getting table specific selector.
335  */
336  template<class T>
337  struct getSelector<T, JPMTHVSettings, true> :
338  public JSelector
339  {
340  /**
341  * Get selector for the given table based on the detector and run number.
342  *
343  * \param detoid detector identifier
344  * \param cg_name cg_name
345  */
346  getSelector(const std::string& detoid,
347  const std::string& cg_name)
348  {
349  this->add(&T::DETOID, detoid);
350  this->add(&T::CG_NAME, cg_name);
351  }
352  };
353 
354 
355  /**
356  * Template specialisation for getting table specific selector.
357  */
358  template<class T>
359  struct getSelector<T, JPMTHVRunSettings, true> :
360  public JSelector
361  {
362  /**
363  * Get selector for the given table based on the detector and run number.
364  *
365  * \param id detector identifier
366  * \param run run number
367  */
368  getSelector(const int id,
369  const int run)
370  {
371  this->add(&T::DETID, id);
372  this->add(&T::RUN, run);
373  }
374 
375  /**
376  * Get selector for the given table based on the detector and run number.
377  *
378  * \param detoid detector identifier
379  * \param run run number
380  */
381  getSelector(const std::string& detoid,
382  const int run)
383  {
384  this->add(&T::DETOID, detoid);
385  this->add(&T::RUN, run);
386  }
387  };
388 
389 
390  /**
391  * Template specialisation for getting table specific selector.
392  */
393  template<class T>
394  struct getSelector<T, JVendorHV, true> :
395  public JSelector
396  {
397  /**
398  * Get selector for the given table based on the detector identifier.
399  *
400  * \param detid detector identifier
401  */
402  getSelector(const int detid)
403  {
404  this->add(&T::DETID, detid);
405  }
406  };
407 
408 
409  /**
410  * Template specialisation for getting table specific selector.
411  */
412  template<class T>
413  struct getSelector<T, JCLBID, true> :
414  public JSelector
415  {
416  /**
417  * Get selector for the given table.
418  */
420  {
421  this->add(&T::CLBID, -1, Selector::RelOp::Different);
422  }
423  };
424 
425 
426  /**
427  * Template specialisation for getting table specific selector.
428  */
429  template<class T>
430  struct getSelector<T, JUPI, true> :
431  public JSelector
432  {
433  /**
434  * Get selector for the given table based on the detector identifier.
435  *
436  * \param pbs %PBS
437  */
438  getSelector(const JPBS_t pbs)
439  {
440  this->add(&T::PBS, pbs);
441  }
442  };
443 
444 
445  /**
446  * Template specialisation for getting table specific selector.
447  */
448  template<class T>
449  struct getSelector<T, JAHRS, true> :
450  public JSelector
451  {
452  /**
453  * Get selector for the given table based on the detector identifier and a run range.
454  *
455  * \param detid detector identifier
456  * \param minrun minimal run number
457  * \param maxrun maximal run number
458  */
459  getSelector(const int detid,
460  const int minrun,
461  const int maxrun)
462  {
463  this->add(&T::DETID, detid);
464  this->add("MINRUN", minrun);
465  this->add("MAXRUN", maxrun);
466  }
467  };
468 
469 
470  /**
471  * Template specialisation for getting table specific selector.
472  */
473  template<class T>
475  public JSelector
476  {
477  /**
478  * Get selector for the given table based on the detector and run number.
479  *
480  * \param detoid detector identifier
481  */
482  getSelector(const std::string& detoid)
483  {
484  this->add(&T::DETOID, detoid);
485  }
486  };
487 
488 
489  /**
490  * Template specialisation for getting table specific selector.
491  */
492  template<class T>
493  struct getSelector<T, JDetCalibrations, true> :
494  public JSelector
495  {
496  /**
497  * Get selector for the given table based on the detector and run number.
498  *
499  * \param detoid detector identifier
500  */
501  getSelector(const std::string& detoid)
502  {
503  this->add(&T::DETOID, detoid);
504  }
505  };
506 
507 
508  /**
509  * Template specialisation for getting table specific selector.
510  */
511  template<class T>
512  struct getSelector<T, APIV2::JCalibration_t, true> :
513  public JSelector
514  {
515  /**
516  * Get selector for the given table based on the detector and run number.
517  *
518  * \param detoid detector identifier
519  * \param operation operation identifier
520  */
521  getSelector(const std::string& detoid,
522  const std::string& operation)
523  {
524  this->add(&T::DetOID, detoid);
525  this->add(&T::OperationId, operation);
526  }
527  };
528 
529 
530  /**
531  * Template specialisation for getting table specific selector.
532  */
533  template<class T>
534  struct getSelector<T, APIV2::JRunCalibration, true> :
535  public JSelector
536  {
537  /**
538  * Get selector for the given table based on the detector and run number.
539  *
540  * \param detoid detector identifier
541  * \param run run number
542  */
543  getSelector(const std::string& detoid,
544  const int run)
545  {
546  this->add(&T::DetOID, detoid);
547  this->add(&T::Run, run);
548  }
549 
550  /**
551  * Get selector for the given table based on the detector and run number.
552  *
553  * \param detoid detector identifier
554  * \param run run number
555  * \param ranking ranking
556  */
557  getSelector(const std::string& detoid,
558  const int run,
559  const int ranking)
560  {
561  this->add(&T::DetOID, detoid);
562  this->add(&T::Run, run);
563  this->add(&T::Ranking, ranking);
564  }
565  };
566 }
567 
568 #endif
This file is automatically created by make.
Auxiliary class for specifying selection of database data.
Auxiliary classes and methods for database I/O.
Definition: JAHRS.hh:14
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Wrapper class to read string until end-of-line.
Definition: JDBString.hh:22
Product breakdown structure (PBS).
Definition: JPBS_t.hh:29
Auxiliary data structure for data quality.
Definition: JRunQuality.hh:36
getSelector(const std::string &detoid, const std::string &operation)
Get selector for the given table based on the detector and run number.
getSelector(const std::string &detoid, const int run)
Get selector for the given table based on the detector and run number.
getSelector(const std::string &detoid, const int run, const int ranking)
Get selector for the given table based on the detector and run number.
getSelector(const std::string &detoid)
Get selector for the given table based on the detector and run number.
getSelector(const int detid, const int minrun, const int maxrun)
Get selector for the given table based on the detector identifier and a run range.
getSelector(const std::string &ssid)
Get selector for the given table based on the sub-system identifier.
getSelector()
Get selector for the given table.
getSelector(const std::string &detoid)
Get selector for the given table based on the detector identifier.
getSelector(const std::string &detid, const int minrun, const int maxrun)
Get selector for the given table based on the detector identifier and a run range.
getSelector(const std::string &detoid)
Get selector for the given table based on the detector and run number.
getSelector(const int id)
Get selector for the given table based on the serial number.
getSelector(const std::string &detoid)
Get selector for the given table based on the detector identifier and a run range.
getSelector(const std::string &detid)
Get selector for the given table based on the object identifier.
getSelector(const int id)
Get selector for the given table based on the serial number.
getSelector(const int id, const int run)
Get selector for the given table based on the detector and run number.
getSelector(const std::string &detoid, const int run)
Get selector for the given table based on the detector and run number.
getSelector(const std::string &detoid, const std::string &cg_name)
Get selector for the given table based on the detector and run number.
getSelector(const std::string &login)
Get selector for the given table based on the login name.
getSelector(const JDBString &locID)
Get selector for the given table based on the location identifier.
getSelector(const std::string &detid, const int minrun, const int maxrun)
Get selector for the given table based on the detector identifier and a run range.
getSelector(const std::string &detid, const int minrun, const int maxrun)
Get selector for the given table based on the detector identifier and a run range.
getSelector(const int id, const int run)
Get selector for the given table based on the detector serial number and run number.
getSelector(const int id, const int minrun, const int maxrun)
Get selector for the given table based on the detector serial number and run number.
getSelector(const int id)
Get selector for the given table based on the detector serial number.
getSelector(const std::string &detid, const std::string &rs_oid)
Get selector for the given table based on the detector and run-setup identifier.
getSelector(const std::string &detid, const int minrun, const int maxrun)
Get selector for the given table based on the detector identifier and a run range.
getSelector(const JPBS_t pbs)
Get selector for the given table based on the detector identifier.
getSelector(const int detid)
Get selector for the given table based on the detector identifier.
Template definition for getting table specific selector.
Template class test for polymorphism.
Definition: JConversion.hh:22