CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
10 
11 namespace edm {
12  class ProductID;
13  class EDProductGetter;
14  namespace reftobase {
15 
16  class RefVectorHolderBase;
17 
18  class RefHolderBase {
19  public:
21  template <class T> 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,
39  std::string& msg) const = 0;
40 
41  virtual std::auto_ptr<RefVectorHolderBase> makeVectorHolder() const = 0;
42  virtual EDProductGetter const* productGetter() const = 0;
43 
46  virtual bool isAvailable() const = 0;
47 
48  virtual bool isTransient() const = 0;
49 
50  private:
51  // "cast" the real type of the element (the T of contained Ref),
52  // and cast it to the type specified by toType.
53  // Return 0 if the real type is not toType nor a subclass of
54  // toType.
55  virtual void const* pointerToType(TypeWithDict const& toType) const = 0;
56  };
57 
58  //------------------------------------------------------------------
59  // Implementation of RefHolderBase
60  //------------------------------------------------------------------
61 
62  inline
64  { }
65 
66  template <class T>
67  T const*
69  {
70  static const TypeWithDict s_type(typeid(T));
71  return static_cast<T const*>(pointerToType(s_type));
72  }
73 
74  }
75 }
76 
77 #endif
virtual void const * pointerToType(TypeWithDict const &toType) const =0
virtual bool isTransient() const =0
virtual std::auto_ptr< RefVectorHolderBase > makeVectorHolder() const =0
virtual size_t key() const =0
virtual bool isAvailable() const =0
T const * getPtr() const
Definition: RefHolderBase.h:68
virtual ProductID id() const =0
virtual EDProductGetter const * productGetter() const =0
virtual bool fillRefIfMyTypeMatches(RefHolderBase &ref, std::string &msg) const =0
virtual RefHolderBase * clone() const =0
string const
Definition: compareJSON.py:14
virtual bool isEqualTo(RefHolderBase const &rhs) const =0
long double T