CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 $Id: traits.h,v 1.20 2008/05/16 01:07:23 wmtan Exp $
9 
10 ----------------------------------------------------------------------*/
11 
12 #include <deque>
13 #include <limits>
14 #include <list>
15 #include <map>
16 #include <set>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
21 namespace edm
22 {
23  //------------------------------------------------------------
24  //
25  // The trait struct template key_traits<K> is used to carry
26  // information relevant to the type K when used as a 'key' in
27  // RefVector and its related classes and templates.
28  //
29  // The general case works only for integral types K; for more
30  // 'esoteric' types, one must introduce an explicit specialization.
31  // That specialization must initialize the static data member
32  // 'value'.
33 
34  template <class K>
35  struct key_traits
36  {
37  typedef K key_type;
38  static const key_type value;
39  };
40 
41  template <class K>
42  typename key_traits<K>::key_type const
44  std::numeric_limits<typename key_traits<K>::key_type>::max();
45 
46  // Partial specialization for std::pair
47 
48  template <class U, class V>
49  struct key_traits<std::pair<U,V> >
50  {
51  typedef std::pair<U,V> key_type;
52  static const key_type value;
53  };
54 
55  template <class U, class V>
56  typename key_traits<std::pair<U,V> >::key_type const
59 
60  // If we ever need to support instantiations of std::basic_string
61  // other than std::string, this is the place to do it.
62 
63  // For value, we make a 1-character long string that contains an
64  // unprintable character; we are hoping nobody ever uses such a
65  // string as a legal key.
66  template <>
67  struct key_traits<std::string>
68  {
70  static const key_type value;
71  };
72 
73 
74  //------------------------------------------------------------
75  //
76  // DoNotSortUponInsertion is a base class. Derive your own class X
77  // from DoNotSortUponInsertion when:
78  //
79  // 1. You want to use DetSetVector<X> as an EDProduct, but
80  //
81  // 2. You do *not* want the Event::put member template to cause the
82  // DetSet<X> instances within the DetSetVector<X> to be sorted.
83  //
84  // DoNotSortUponInsertion has no behavior; it is used at compile
85  // time to influence the behavior of Event::put.
86  //
87  // Usage:
88  // class MyClass : public edm::DoNotSortUponInsertion { ... }
89  //
91 
92  //------------------------------------------------------------
93  //
94  // DoNotRecordParents is a base class. Derive your own (EDProduct)
95  // class X from DoNotRecordParents when your class already keeps all
96  // data that are relevant to parentage internally, and the
97  // information kept by the event model would thus be redundant.
98  //
99  // DoNotRecordParents has no behavior; it is used at compile time to
100  // influence the behavior of Event::put.
101  //
102  // Usage:
103  // class MyClass : public edm::DoNotRecordParents { ... }
104  struct DoNotRecordParents { };
105 
106  // Other is a base class. NEVER USE IT. It is for the
107  // core of the event model only.
108  struct Other { };
109 
110  //------------------------------------------------------------
111  //
112  // The trait struct template has_fillView<T> is used to
113  // indicate whether or not the type T has a member function
114  //
115  // void T::fillView(std::vector<void const*>&) const
116  //
117  // We assume the 'general case' for T is to not support fillView.
118  // Classes which do support fillView must specialize this trait.
119  //
120  //------------------------------------------------------------
121 
122  template <class T>
124  {
125  static bool const value = false;
126  };
127 
128  template <class T, class A>
129  struct has_fillView<std::vector<T,A> >
130  {
131  static bool const value = true;
132  };
133 
134  template <class A>
135  struct has_fillView<std::vector<bool,A> >
136  {
137  static bool const value = false;
138  };
139 
140  template <class T, class A>
141  struct has_fillView<std::list<T,A> >
142  {
143  static bool const value = true;
144  };
145 
146  template <class T, class A>
147  struct has_fillView<std::deque<T,A> >
148  {
149  static bool const value = true;
150  };
151 
152  template <class T, class A>
153  struct has_fillView<std::set<T,A> >
154  {
155  static bool const value = true;
156  };
157 
158 
159  //------------------------------------------------------------
160  //
161  // The trait struct template has_setPtr<T> is used to
162  // indicate whether or not the type T has a member function
163  //
164  // void T::setPtr(const std::type_info&, void const*&) const
165  //
166  // We assume the 'general case' for T is to not support setPtr.
167  // Classes which do support setPtr must specialize this trait.
168  //
169  //------------------------------------------------------------
170 
171  template <class T>
172  struct has_setPtr
173  {
174  static bool const value = false;
175  };
176 
177  template <class T, class A>
178  struct has_setPtr<std::vector<T,A> >
179  {
180  static bool const value = true;
181  };
182 
183  template <class A>
184  struct has_setPtr<std::vector<bool,A> >
185  {
186  static bool const value = false;
187  };
188 
189  template <class T, class A>
190  struct has_setPtr<std::list<T,A> >
191  {
192  static bool const value = true;
193  };
194 
195  template <class T, class A>
196  struct has_setPtr<std::deque<T,A> >
197  {
198  static bool const value = true;
199  };
200 
201  template <class T, class A>
202  struct has_setPtr<std::set<T,A> >
203  {
204  static bool const value = true;
205  };
206 }
207 
208 #endif
static bool const value
Definition: traits.h:174
static const key_type value
Definition: traits.h:38
static const key_type value
Definition: traits.h:52
static const key_type value
Definition: traits.h:70
static bool const value
Definition: traits.h:125
std::pair< U, V > key_type
Definition: traits.h:51
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:137