File indexing completed on 2024-04-06 12:02:05
0001 #ifndef DTBufferTree_H
0002 #define DTBufferTree_H
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <map>
0012 #include <memory>
0013 #include <vector>
0014
0015
0016
0017
0018
0019
0020
0021 template <typename T>
0022 class DTBufferTreeTrait {
0023 public:
0024 typedef T outputTypeOfConstFind;
0025 typedef T outputTypeOfNonConstFind;
0026
0027 static T getOutputValue(T const& t) { return t; }
0028 static T getDefault() { return 0; }
0029 };
0030
0031 template <typename T>
0032 class DTBufferTreeTrait<std::unique_ptr<T> > {
0033 public:
0034 typedef T const* outputTypeOfConstFind;
0035 typedef T* outputTypeOfNonConstFind;
0036
0037 static T* getOutputValue(std::unique_ptr<T> const& t) { return t.get(); }
0038 static T* getDefault() { return nullptr; }
0039 };
0040
0041 template <class Key, class Content>
0042 class DTBufferTree {
0043 public:
0044 typedef typename std::vector<Key>::const_iterator ElementKey;
0045
0046 DTBufferTree();
0047 DTBufferTree(DTBufferTree const&) = delete;
0048 DTBufferTree& operator=(DTBufferTree const&) = delete;
0049 virtual ~DTBufferTree();
0050
0051 void clear();
0052
0053 int insert(ElementKey fKey, ElementKey lKey, Content cont);
0054 int insert(const Key& k, Content cont);
0055 int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait<Content>::outputTypeOfConstFind& cont) const;
0056 int find(const Key& k, typename DTBufferTreeTrait<Content>::outputTypeOfConstFind& cont) const;
0057 int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait<Content>::outputTypeOfNonConstFind& cont);
0058 int find(const Key& k, typename DTBufferTreeTrait<Content>::outputTypeOfNonConstFind& cont);
0059
0060 private:
0061 typedef DTBufferTree<Key, Content> map_node;
0062 typedef typename std::map<Key, DTBufferTree<Key, Content>*> map_cont;
0063 typedef typename std::map<Key, DTBufferTree<Key, Content>*>::const_iterator map_iter;
0064
0065 Content bufferContent;
0066 map_cont bufferMap;
0067 };
0068
0069 #include "CondFormats/DTObjects/interface/DTBufferTree.icc"
0070
0071
0072
0073
0074
0075
0076
0077 class DTBufferTreeUniquePtr : public DTBufferTree<int, std::unique_ptr<std::vector<int> > > {};
0078
0079 #endif