CMS 3D CMS Logo

RefHolderBase.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_RefHolderBase_h
2 #define DataFormats_Common_RefHolderBase_h
3 /* \class edm::reftobase::Base
4  *
5  *
6  */
7 #include <memory>
8 #include <typeinfo>
9 
10 namespace edm {
11  class ProductID;
12  class EDProductGetter;
13  namespace reftobase {
14 
15  class RefVectorHolderBase;
16 
17  class RefHolderBase {
18  public:
19  RefHolderBase();
20  template <class T>
21  T const* getPtr() const;
22  virtual ~RefHolderBase();
23  virtual RefHolderBase* clone() const = 0;
24 
25  virtual ProductID id() const = 0;
26  virtual size_t key() const = 0;
27 
28  // Check to see if the Ref hidden in 'rhs' is equal to the Ref
29  // hidden in 'this'. They can not be equal if they are of
30  // different types.
31  virtual bool isEqualTo(RefHolderBase const& rhs) const = 0;
32 
33  // If the type of Ref I contain matches the type contained in
34  // 'fillme', set the Ref in 'fillme' equal to mine and return
35  // true. If not, write the name of the type I really contain to
36  // msg, and return false.
37 
38  virtual bool fillRefIfMyTypeMatches(RefHolderBase& ref, std::string& msg) const = 0;
39 
40  virtual std::unique_ptr<RefVectorHolderBase> makeVectorHolder() const = 0;
41  virtual EDProductGetter const* productGetter() const = 0;
42 
45  virtual bool isAvailable() const = 0;
46 
47  virtual bool isTransient() const = 0;
48 
49  private:
50  // "cast" the real type of the element (the T of contained Ref),
51  // and cast it to the type specified by toType.
52  // Return 0 if the real type is not toType nor a subclass of
53  // toType.
54  virtual void const* pointerToType(std::type_info const& toType) const = 0;
55  };
56 
57  //------------------------------------------------------------------
58  // Implementation of RefHolderBase
59  //------------------------------------------------------------------
60 
62 
63  template <class T>
64  T const* RefHolderBase::getPtr() const {
65  return static_cast<T const*>(pointerToType(typeid(T)));
66  }
67 
68  } // namespace reftobase
69 } // namespace edm
70 
71 #endif
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::reftobase::RefHolderBase::RefHolderBase
RefHolderBase()
Definition: RefHolder.cc:6
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::reftobase::RefHolderBase::productGetter
virtual EDProductGetter const * productGetter() const =0
edm::reftobase::RefHolderBase::isAvailable
virtual bool isAvailable() const =0
edm::reftobase::RefHolderBase
Definition: RefHolderBase.h:17
edm::EDProductGetter
Definition: EDProductGetter.h:41
edm::reftobase::RefHolderBase::makeVectorHolder
virtual std::unique_ptr< RefVectorHolderBase > makeVectorHolder() const =0
edm::reftobase::RefHolderBase::fillRefIfMyTypeMatches
virtual bool fillRefIfMyTypeMatches(RefHolderBase &ref, std::string &msg) const =0
edm::reftobase::RefHolderBase::key
virtual size_t key() const =0
edm::reftobase::RefHolderBase::clone
virtual RefHolderBase * clone() const =0
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EDProductGetter
edm::reftobase::RefHolderBase::id
virtual ProductID id() const =0
edm::reftobase::RefHolderBase::pointerToType
virtual void const * pointerToType(std::type_info const &toType) const =0
edm::reftobase::RefHolderBase::isEqualTo
virtual bool isEqualTo(RefHolderBase const &rhs) const =0
T
long double T
Definition: Basic3DVectorLD.h:48
edm::reftobase::RefHolderBase::~RefHolderBase
virtual ~RefHolderBase()
Definition: RefHolderBase.h:61
edm::reftobase::RefHolderBase::isTransient
virtual bool isTransient() const =0
edm::reftobase::RefHolderBase::getPtr
T const * getPtr() const
Definition: RefHolderBase.h:64
edm::ProductID
Definition: ProductID.h:27