CMS 3D CMS Logo

BaseHolder.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_BaseHolder_h
2 #define DataFormats_Common_BaseHolder_h
3 
6 
7 #include <memory>
8 #include <string>
9 
10 namespace edm {
11  class ProductID;
12 
13  namespace reftobase {
14  class RefHolderBase;
15  template <typename T>
17  class RefVectorHolderBase;
18 
19  //------------------------------------------------------------------
20  // Class template BaseHolder<T>
21  //
22  // BaseHolder<T> is an abstract base class that manages a single
23  // edm::Ref to an element of type T in a collection in the Event;
24  // the purpose of this abstraction is to hide the type of the
25  // collection from code that can not know about that type.
26  //
27  //------------------------------------------------------------------
28  template <typename T>
29  class BaseHolder {
30  public:
31  BaseHolder();
32  virtual ~BaseHolder();
33  virtual BaseHolder<T>* clone() const = 0;
34 
35  void swap(BaseHolder&);
36 
37  // Return the address of the element to which the hidden Ref
38  // refers.
39  virtual T const* getPtr() const = 0;
40 
41  // Return the ProductID of the collection to which the hidden
42  // Ref refers.
43  virtual ProductID id() const = 0;
44  virtual size_t key() const = 0;
45  // Check to see if the Ref hidden in 'rhs' is equal to the Ref
46  // hidden in 'this'. They can not be equal if they are of
47  // different types. Note that the equality test also returns
48  // false if dynamic type of 'rhs' is different from the dynamic
49  // type of 'this', *even when the hiddens Refs are actually
50  // equivalent*.
51  virtual bool isEqualTo(BaseHolder<T> const& rhs) const = 0;
52 
53  // If the type of Ref I contain matches the type contained in
54  // 'fillme', set the Ref in 'fillme' equal to mine and return
55  // true. If not, write the name of the type I really contain to
56  // msg, and return false.
57  virtual bool fillRefIfMyTypeMatches(RefHolderBase& fillme, std::string& msg) const = 0;
58  virtual std::unique_ptr<RefHolderBase> holder() const = 0;
59 
60  virtual std::unique_ptr<BaseVectorHolder<T> > makeVectorHolder() const = 0;
61 
62  virtual EDProductGetter const* productGetter() const = 0;
63 
66  virtual bool isAvailable() const = 0;
67 
68  virtual bool isTransient() const = 0;
69 
70  //Used by ROOT storage
72 
73  protected:
74  // We want the following called only by derived classes.
77 
78  private:
79  };
80 
81  //------------------------------------------------------------------
82  // Implementation of BaseHolder<T>
83  //------------------------------------------------------------------
84 
85  template <typename T>
87 
88  template <typename T>
90  // Nothing to do.
91  }
92 
93  template <typename T>
95  // No data to assign.
96  return *this;
97  }
98 
99  template <typename T>
101  // nothing to do.
102  }
103 
104  template <typename T>
106  // nothing to do.
107  }
108 
109  // Free swap function
110  template <typename T>
111  inline void swap(BaseHolder<T>& lhs, BaseHolder<T>& rhs) {
112  lhs.swap(rhs);
113  }
114  } // namespace reftobase
115 } // namespace edm
116 
117 #endif
edm::reftobase::BaseHolder::BaseHolder
BaseHolder()
Definition: BaseHolder.h:86
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::reftobase::BaseHolder::makeVectorHolder
virtual std::unique_ptr< BaseVectorHolder< T > > makeVectorHolder() const =0
edm::reftobase::BaseVectorHolder
Definition: BaseHolder.h:16
edm::reftobase::BaseHolder::fillRefIfMyTypeMatches
virtual bool fillRefIfMyTypeMatches(RefHolderBase &fillme, std::string &msg) const =0
edm::reftobase::BaseHolder::productGetter
virtual EDProductGetter const * productGetter() const =0
edm::reftobase::RefVectorHolderBase
Definition: RefVectorHolderBase.h:13
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::reftobase::BaseHolder::isAvailable
virtual bool isAvailable() const =0
watchdog.const
const
Definition: watchdog.py:83
edm::reftobase::BaseHolder::~BaseHolder
virtual ~BaseHolder()
Definition: BaseHolder.h:100
edm::reftobase::RefHolderBase
Definition: RefHolderBase.h:17
Utilities.operator
operator
Definition: Utilities.py:24
edm::reftobase::BaseHolder::isEqualTo
virtual bool isEqualTo(BaseHolder< T > const &rhs) const =0
edm::EDProductGetter
Definition: EDProductGetter.h:41
edm::reftobase::BaseHolder::holder
virtual std::unique_ptr< RefHolderBase > holder() const =0
edm::reftobase::BaseHolder::key
virtual size_t key() const =0
edm::reftobase::BaseHolder
Definition: BaseHolder.h:29
trackingPlots.other
other
Definition: trackingPlots.py:1464
CMS_CLASS_VERSION
#define CMS_CLASS_VERSION(_version_)
Definition: CMS_CLASS_VERSION.h:30
edm::reftobase::BaseHolder::swap
void swap(BaseHolder &)
Definition: BaseHolder.h:105
edm::reftobase::BaseHolder::operator=
BaseHolder & operator=(BaseHolder const &rhs)
Definition: BaseHolder.h:94
edm::reftobase::BaseHolder::clone
virtual BaseHolder< T > * clone() const =0
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::reftobase::BaseHolder::getPtr
virtual T const * getPtr() const =0
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::reftobase::BaseHolder::isTransient
virtual bool isTransient() const =0
CMS_CLASS_VERSION.h
T
long double T
Definition: Basic3DVectorLD.h:48
EDProductGetter.h
edm::reftobase::BaseHolder::id
virtual ProductID id() const =0
edm::ProductID
Definition: ProductID.h:27