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>
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  DTBufferTree(DTBufferTree const&) = delete;
48  DTBufferTree& operator=(DTBufferTree const&) = delete;
49  virtual ~DTBufferTree();
50 
51  void clear();
52 
53  int insert(ElementKey fKey, ElementKey lKey, Content cont);
54  int insert(const Key& k, Content cont);
59 
60 private:
62  typedef typename std::map<Key, DTBufferTree<Key, Content>*> map_cont;
63  typedef typename std::map<Key, DTBufferTree<Key, Content>*>::const_iterator map_iter;
64 
65  Content bufferContent;
67 };
68 
69 #include "CondFormats/DTObjects/interface/DTBufferTree.icc"
70 
71 // This class is defined because it is easier to forward declare
72 // it than the template. Then unique_ptr is not exposed. When
73 // we stop using GCCXML (which does not recognize C++11's unique_ptr)
74 // this will not be as important, although it will still keep
75 // #include <memory> out of the header file of the class using
76 // DTBufferTree.
77 class DTBufferTreeUniquePtr : public DTBufferTree<int, std::unique_ptr<std::vector<int> > > {};
78 
79 #endif // DTBufferTree_H
DTBufferTree< Key, Content > map_node
Definition: DTBufferTree.h:61
static T getOutputValue(T const &t)
Definition: DTBufferTree.h:27
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
virtual ~DTBufferTree()
Content bufferContent
Definition: DTBufferTree.h:65
static T getDefault()
Definition: DTBufferTree.h:28
map_cont bufferMap
Definition: DTBufferTree.h:66
static T * getOutputValue(std::unique_ptr< T > const &t)
Definition: DTBufferTree.h:37
std::vector< Key >::const_iterator ElementKey
Definition: DTBufferTree.h:44
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
int insert(ElementKey fKey, ElementKey lKey, Content cont)
long double T
std::map< Key, DTBufferTree< Key, Content > * > map_cont
Definition: DTBufferTree.h:62
cont
load Luminosity info ##
Definition: generateEDF.py:620
std::map< Key, DTBufferTree< Key, Content > * >::const_iterator map_iter
Definition: DTBufferTree.h:63
DTBufferTree & operator=(DTBufferTree const &)=delete