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  virtual std::unique_ptr<RefVectorHolderBase> makeVectorHolder() const = 0;
34  virtual EDProductGetter const* productGetter() const = 0;
35 
38  virtual bool isAvailable() const = 0;
39 
40  virtual bool isTransient() const = 0;
41 
42  private:
43  // "cast" the real type of the element (the T of contained Ref),
44  // and cast it to the type specified by toType.
45  // Return 0 if the real type is not toType nor a subclass of
46  // toType.
47  virtual void const* pointerToType(std::type_info const& toType) const = 0;
48  };
49 
50  //------------------------------------------------------------------
51  // Implementation of RefHolderBase
52  //------------------------------------------------------------------
53 
55 
56  template <class T>
57  T const* RefHolderBase::getPtr() const {
58  return static_cast<T const*>(pointerToType(typeid(T)));
59  }
60 
61  } // namespace reftobase
62 } // namespace edm
63 
64 #endif
virtual void const * pointerToType(std::type_info const &toType) const =0
virtual bool isTransient() const =0
virtual size_t key() const =0
virtual bool isAvailable() const =0
virtual ProductID id() const =0
virtual EDProductGetter const * productGetter() const =0
virtual RefHolderBase * clone() const =0
virtual bool isEqualTo(RefHolderBase const &rhs) const =0
HLT enums.
long double T
virtual std::unique_ptr< RefVectorHolderBase > makeVectorHolder() const =0