CMS 3D CMS Logo

DTBufferTree.h
Go to the documentation of this file.
1 #ifndef DTBufferTree_H
2 #define DTBufferTree_H
3 
11 #include <map>
12 #include <memory>
13 #include <vector>
14 
15 // This trait template defines the type of the output argument
16 // in the find function. Usually the output type is just the
17 // content type, but in the special case where the content is
18 // a unique_ptr the the output type is a bare pointer. The
19 // functions in the trait template make that output type work
20 // in both cases.
21 template <typename T>
23 public:
26 
27  static T getOutputValue(T const& t) { return t; }
28  static T getDefault() { return 0; }
29 };
30 
31 template <typename T>
32 class DTBufferTreeTrait<std::unique_ptr<T> > {
33 public:
34  typedef T const* outputTypeOfConstFind;
36 
37  static T* getOutputValue(std::unique_ptr<T> const& t) { return t.get(); }
38  static T* getDefault() { return nullptr; }
39 };
40 
41 template <class Key, class Content>
42 class DTBufferTree {
43 public:
44  typedef typename std::vector<Key>::const_iterator ElementKey;
45 
46  DTBufferTree();
47  virtual ~DTBufferTree();
48 
49  void clear();
50 
51  int insert(ElementKey fKey, ElementKey lKey, Content cont);
52  int insert(const Key& k, Content cont);
53  int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait<Content>::outputTypeOfConstFind& cont) const;
55  int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait<Content>::outputTypeOfNonConstFind& cont);
57 
58 private:
59  DTBufferTree(DTBufferTree const&) = delete;
60  DTBufferTree& operator=(DTBufferTree const&) = delete;
61 
63  typedef typename std::map<Key, DTBufferTree<Key, Content>*> map_cont;
64  typedef typename std::map<Key, DTBufferTree<Key, Content>*>::const_iterator map_iter;
65 
66  Content bufferContent;
67  map_cont bufferMap;
68 };
69 
70 #include "CondFormats/DTObjects/interface/DTBufferTree.icc"
71 
72 // This class is defined because it is easier to forward declare
73 // it than the template. Then unique_ptr is not exposed. When
74 // we stop using GCCXML (which does not recognize C++11's unique_ptr)
75 // this will not be as important, although it will still keep
76 // #include <memory> out of the header file of the class using
77 // DTBufferTree.
78 class DTBufferTreeUniquePtr : public DTBufferTree<int, std::unique_ptr<std::vector<int> > > {};
79 
80 #endif // DTBufferTree_H
DTBufferTree< Key, Content > map_node
Definition: DTBufferTree.h:62
static T getOutputValue(T const &t)
Definition: DTBufferTree.h:27
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Content bufferContent
Definition: DTBufferTree.h:66
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:151
static T getDefault()
Definition: DTBufferTree.h:28
map_cont bufferMap
Definition: DTBufferTree.h:67
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
static T * getOutputValue(std::unique_ptr< T > const &t)
Definition: DTBufferTree.h:37
std::vector< Key >::const_iterator ElementKey
Definition: DTBufferTree.h:44
long double T
std::map< Key, DTBufferTree< Key, Content > * > map_cont
Definition: DTBufferTree.h:63
cont
load Luminosity info ##
Definition: generateEDF.py:629
std::map< Key, DTBufferTree< Key, Content > * >::const_iterator map_iter
Definition: DTBufferTree.h:64