CMS 3D CMS Logo

traits.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_traits_h
2 #define DataFormats_Common_traits_h
3 
4 /*----------------------------------------------------------------------
5 
6 Definition of traits templates used in the EDM.
7 
8 
9 ----------------------------------------------------------------------*/
10 
11 #include <deque>
12 #include <limits>
13 #include <list>
14 #include <set>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 namespace edm
20 {
21  //------------------------------------------------------------
22  //
23  // The trait struct template key_traits<K> is used to carry
24  // information relevant to the type K when used as a 'key' in
25  // RefVector and its related classes and templates.
26  //
27  // The general case works only for integral types K; for more
28  // 'esoteric' types, one must introduce an explicit specialization.
29  // That specialization must initialize the static data member
30  // 'value'.
31 
32  template <class K>
33  struct key_traits
34  {
35  typedef K key_type;
36  static const key_type value;
37  };
38 
39  template <class K>
40  typename key_traits<K>::key_type const
42  std::numeric_limits<typename key_traits<K>::key_type>::max();
43 
44  // Partial specialization for std::pair
45 
46  template <class U, class V>
47  struct key_traits<std::pair<U,V> >
48  {
49  typedef std::pair<U,V> key_type;
50  static const key_type value;
51  };
52 
53  template <class U, class V>
57 
58  // If we ever need to support instantiations of std::basic_string
59  // other than std::string, this is the place to do it.
60 
61  // For value, we make a 1-character long string that contains an
62  // unprintable character; we are hoping nobody ever uses such a
63  // string as a legal key.
64  template <>
66  {
68  static const key_type value;
69  };
70 
71 
72  //------------------------------------------------------------
73  //
74  // DoNotSortUponInsertion is a base class. Derive your own class X
75  // from DoNotSortUponInsertion when:
76  //
77  // 1. You want to use DetSetVector<X> as an EDProduct, but
78  //
79  // 2. You do *not* want the Event::put member template to cause the
80  // DetSet<X> instances within the DetSetVector<X> to be sorted.
81  //
82  // DoNotSortUponInsertion has no behavior; it is used at compile
83  // time to influence the behavior of Event::put.
84  //
85  // Usage:
86  // class MyClass : public edm::DoNotSortUponInsertion { ... }
87  //
89 
90  //------------------------------------------------------------
91  //
92  // DoNotRecordParents is a base class. Derive your own (EDProduct)
93  // class X from DoNotRecordParents when your class already keeps all
94  // data that are relevant to parentage internally, and the
95  // information kept by the event model would thus be redundant.
96  //
97  // DoNotRecordParents has no behavior; it is used at compile time to
98  // influence the behavior of Event::put.
99  //
100  // Usage:
101  // class MyClass : public edm::DoNotRecordParents { ... }
102  struct DoNotRecordParents { };
103 
104  // Other is a base class. NEVER USE IT. It is for the
105  // core of the event model only.
106  struct Other { };
107 
108  //------------------------------------------------------------
109  //
110  // The trait struct template has_fillView<T> is used to
111  // indicate whether or not the type T has a member function
112  //
113  // void T::fillView(std::vector<void const*>&) const
114  //
115  // We assume the 'general case' for T is to not support fillView.
116  // Classes which do support fillView must specialize this trait.
117  //
118  //------------------------------------------------------------
119 
120  template <class T>
122  {
123  static bool const value = false;
124  };
125 
126  template <class T, class A>
127  struct has_fillView<std::vector<T,A> >
128  {
129  static bool const value = true;
130  };
131 
132  template <class A>
133  struct has_fillView<std::vector<bool,A> >
134  {
135  static bool const value = false;
136  };
137 
138  template <class T, class A>
139  struct has_fillView<std::list<T,A> >
140  {
141  static bool const value = true;
142  };
143 
144  template <class T, class A>
145  struct has_fillView<std::deque<T,A> >
146  {
147  static bool const value = true;
148  };
149 
150  template <class T, class A>
151  struct has_fillView<std::set<T,A> >
152  {
153  static bool const value = true;
154  };
155 
156 
157  //------------------------------------------------------------
158  //
159  // The trait struct template has_setPtr<T> is used to
160  // indicate whether or not the type T has a member function
161  //
162  // void T::setPtr(const std::type_info&, void const*&) const
163  //
164  // We assume the 'general case' for T is to not support setPtr.
165  // Classes which do support setPtr must specialize this trait.
166  //
167  //------------------------------------------------------------
168 
169  template <class T>
170  struct has_setPtr
171  {
172  static bool const value = false;
173  };
174 
175  template <class T, class A>
176  struct has_setPtr<std::vector<T,A> >
177  {
178  static bool const value = true;
179  };
180 
181  template <class A>
182  struct has_setPtr<std::vector<bool,A> >
183  {
184  static bool const value = false;
185  };
186 
187  template <class T, class A>
188  struct has_setPtr<std::list<T,A> >
189  {
190  static bool const value = true;
191  };
192 
193  template <class T, class A>
194  struct has_setPtr<std::deque<T,A> >
195  {
196  static bool const value = true;
197  };
198 
199  template <class T, class A>
200  struct has_setPtr<std::set<T,A> >
201  {
202  static bool const value = true;
203  };
204 }
205 
206 #endif
static const key_type value
Definition: traits.h:36
static const key_type value
Definition: traits.h:50
Definition: value.py:1
HLT enums.
static const key_type value
Definition: traits.h:68
std::pair< U, V > key_type
Definition: traits.h:49
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:142