Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBORptrs.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DBORptrs.h
4 // Created: Tue Apr 26 14:52:22 EDT 2016
5 // Creator: davidl (on Darwin harriet.jlab.org 13.4.0 i386)
6 //
7 
8 // This is used to keep a list of pointers to various BOR config
9 // objects. These are kept globally so all events get copies of
10 // of the pointers. The DBORptrs objects are kept in the
11 // JEventSource_EVIOpp object.
12 
13 #ifndef _DBORptrs_
14 #define _DBORptrs_
15 
16 #include <DAQ/Df250BORConfig.h>
17 #include <DAQ/Df125BORConfig.h>
18 #include <DAQ/DF1TDCBORConfig.h>
20 #include <DAQ/DTSGBORConfig.h>
21 
22 #define MyBORTypes(X) \
23  X(Df250BORConfig) \
24  X(Df125BORConfig) \
25  X(DF1TDCBORConfig) \
26  X(DCAEN1290TDCBORConfig) \
27  X(DTSGBORConfig)
28 
29 
30 #include <JANA/jerror.h>
31 
32 #include <DAQ/LinkAssociations.h>
33 
35 
36 class DBORptrs{
37  public:
38  DBORptrs(void){}
39  virtual ~DBORptrs(){ Delete(); }
40 
41 
42  // For each type defined in "MyTypes" above, define a vector of
43  // pointers to it with a name made by prepending a "v" to the classname
44  // The following expands to things like e.g.
45  //
46  // vector<Df250BORConfig*> vDf250BORConfig;
47  //
48  #define makevector(A) vector<A*> v##A;
50  #undef makevector
51 
52  // Method to delete all objects in all vectors. This should
53  // usually only be called from the destructor
54  #define deletevector(A) for(auto p : v##A) delete p;
55  #define clearvectors(A) v##A.clear();
56  void Delete(void){
59  }
60  #undef deletevector
61  #undef clearvectors
62 
63 
64  // Sort all vectors by rocid then slot (use sort from LinkAssociations.h)
65  #define sortvector(A) if( v##A.size()>1 ) sort(v##A.begin(), v##A.end(), SortByModule<A>);
66  void Sort(void){ MyBORTypes(sortvector) }
67  #undef sortvector
68 };
69 
70 #endif // _DBORptrs_
71 
#define MyBORTypes(X)
Definition: DBORptrs.h:22
#define sortvector(A)
Definition: DBORptrs.h:65
#define deletevector(A)
Definition: DBORptrs.h:54
How this Event Source Works
DBORptrs(void)
Definition: DBORptrs.h:38
void Sort(void)
Definition: DBORptrs.h:66
#define makevector(A)
Definition: DBORptrs.h:48
void Delete(void)
Definition: DBORptrs.h:56
#define clearvectors(A)
Definition: DBORptrs.h:55
virtual ~DBORptrs()
Definition: DBORptrs.h:39