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  virtual ~DTBufferTree();
48 
49  void clear();
50 
51  int insert(ElementKey fKey, ElementKey lKey, Content cont);
52  int insert(const Key& k, Content 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;
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
DTBufferTreeTrait< std::unique_ptr< T > >::outputTypeOfConstFind
T const * outputTypeOfConstFind
Definition: DTBufferTree.h:34
DTBufferTree::clear
void clear()
DTBufferTree::map_node
DTBufferTree< Key, Content > map_node
Definition: DTBufferTree.h:62
generateEDF.cont
cont
load Luminosity info ##
Definition: generateEDF.py:629
DTBufferTree::ElementKey
std::vector< Key >::const_iterator ElementKey
Definition: DTBufferTree.h:44
DTBufferTree::bufferContent
Content bufferContent
Definition: DTBufferTree.h:66
DTBufferTreeTrait::getDefault
static T getDefault()
Definition: DTBufferTree.h:28
Key
Definition: GoldenPattern.h:15
DTBufferTree::insert
int insert(ElementKey fKey, ElementKey lKey, Content cont)
DTBufferTree::~DTBufferTree
virtual ~DTBufferTree()
DTBufferTree::map_cont
std::map< Key, DTBufferTree< Key, Content > * > map_cont
Definition: DTBufferTree.h:63
DTBufferTree::bufferMap
map_cont bufferMap
Definition: DTBufferTree.h:67
DTBufferTreeUniquePtr
Definition: DTBufferTree.h:78
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DTBufferTree::operator=
DTBufferTree & operator=(DTBufferTree const &)=delete
DTBufferTree::DTBufferTree
DTBufferTree()
DTBufferTreeTrait< std::unique_ptr< T > >::getDefault
static T * getDefault()
Definition: DTBufferTree.h:38
DTBufferTreeTrait< std::unique_ptr< T > >::getOutputValue
static T * getOutputValue(std::unique_ptr< T > const &t)
Definition: DTBufferTree.h:37
DTBufferTree
Definition: DTBufferTree.h:42
DTBufferTreeTrait< std::unique_ptr< T > >::outputTypeOfNonConstFind
T * outputTypeOfNonConstFind
Definition: DTBufferTree.h:35
cms::cuda::device::unique_ptr
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
Definition: device_unique_ptr.h:33
DTBufferTreeTrait
Definition: DTBufferTree.h:22
std
Definition: JetResolutionObject.h:76
DTBufferTreeTrait::outputTypeOfConstFind
T outputTypeOfConstFind
Definition: DTBufferTree.h:24
T
long double T
Definition: Basic3DVectorLD.h:48
DTBufferTree::map_iter
std::map< Key, DTBufferTree< Key, Content > * >::const_iterator map_iter
Definition: DTBufferTree.h:64
DTBufferTree::find
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
DTBufferTreeTrait::getOutputValue
static T getOutputValue(T const &t)
Definition: DTBufferTree.h:27
DTBufferTreeTrait::outputTypeOfNonConstFind
T outputTypeOfNonConstFind
Definition: DTBufferTree.h:25