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:
20  template <class T> T const* getPtr() const;
21  virtual ~RefHolderBase();
22  virtual RefHolderBase* clone() const = 0;
23 
24  virtual ProductID id() const = 0;
25  virtual size_t key() const = 0;
26 
27  // Check to see if the Ref hidden in 'rhs' is equal to the Ref
28  // hidden in 'this'. They can not be equal if they are of
29  // different types.
30  virtual bool isEqualTo(RefHolderBase const& rhs) const = 0;
31 
32  // If the type of Ref I contain matches the type contained in
33  // 'fillme', set the Ref in 'fillme' equal to mine and return
34  // true. If not, write the name of the type I really contain to
35  // msg, and return false.
36 
37  virtual bool fillRefIfMyTypeMatches(RefHolderBase& ref,
38  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 
61  inline
63  { }
64 
65  template <class T>
66  T const*
68  {
69  return static_cast<T const*>(pointerToType(typeid(T)));
70  }
71 
72  }
73 }
74 
75 #endif
virtual EDProductGetter const * productGetter() const =0
virtual ProductID id() const =0
virtual std::unique_ptr< RefVectorHolderBase > makeVectorHolder() const =0
virtual bool isEqualTo(RefHolderBase const &rhs) const =0
virtual size_t key() const =0
T const * getPtr() const
Definition: RefHolderBase.h:67
virtual void const * pointerToType(std::type_info const &toType) const =0
tuple msg
Definition: mps_check.py:277
virtual bool isAvailable() const =0
HLT enums.
virtual bool fillRefIfMyTypeMatches(RefHolderBase &ref, std::string &msg) const =0
virtual RefHolderBase * clone() const =0
virtual bool isTransient() const =0
long double T