test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  class RefHolderBase;
13 
14  namespace reftobase {
15  template<typename T> class BaseVectorHolder;
16  class RefVectorHolderBase;
17 
18  //------------------------------------------------------------------
19  // Class template BaseHolder<T>
20  //
21  // BaseHolder<T> is an abstract base class that manages a single
22  // edm::Ref to an element of type T in a collection in the Event;
23  // the purpose of this abstraction is to hide the type of the
24  // collection from code that can not know about that type.
25  //
26  //------------------------------------------------------------------
27  template <typename T>
28  class BaseHolder {
29  public:
30  BaseHolder();
31  virtual ~BaseHolder();
32  virtual BaseHolder<T>* clone() const = 0;
33 
34  void swap(BaseHolder&);
35 
36  // Return the address of the element to which the hidden Ref
37  // refers.
38  virtual T const* getPtr() const = 0;
39 
40  // Return the ProductID of the collection to which the hidden
41  // Ref refers.
42  virtual ProductID id() const = 0;
43  virtual size_t key() const = 0;
44  // Check to see if the Ref hidden in 'rhs' is equal to the Ref
45  // hidden in 'this'. They can not be equal if they are of
46  // different types. Note that the equality test also returns
47  // false if dynamic type of 'rhs' is different from the dynamic
48  // type of 'this', *even when the hiddens Refs are actually
49  // equivalent*.
50  virtual bool isEqualTo(BaseHolder<T> const& rhs) const = 0;
51 
52  // If the type of Ref I contain matches the type contained in
53  // 'fillme', set the Ref in 'fillme' equal to mine and return
54  // true. If not, write the name of the type I really contain to
55  // msg, and return false.
56  virtual bool fillRefIfMyTypeMatches(RefHolderBase& fillme,
57  std::string& msg) const = 0;
58  virtual std::auto_ptr<RefHolderBase> holder() const = 0;
59 
60  virtual std::auto_ptr<BaseVectorHolder<T> > makeVectorHolder() const = 0;
61  virtual std::auto_ptr<RefVectorHolderBase> makeVectorBaseHolder() const = 0;
62 
63  virtual EDProductGetter const* productGetter() const = 0;
64  virtual bool hasProductCache() const = 0;
65  virtual void const* product() const = 0;
66 
69  virtual bool isAvailable() const = 0;
70 
71  //Used by ROOT storage
73 
74  protected:
75  // We want the following called only by derived classes.
76  BaseHolder(BaseHolder const& other);
78 
79  private:
80  };
81 
82  //------------------------------------------------------------------
83  // Implementation of BaseHolder<T>
84  //------------------------------------------------------------------
85 
86  template <typename T>
88  }
89 
90  template <typename T>
92  // Nothing to do.
93  }
94 
95  template <typename T>
98  // No data to assign.
99  return *this;
100  }
101 
102  template <typename T>
104  // nothing to do.
105  }
106 
107  template <typename T>
108  void
110  // nothing to do.
111  }
112 
113  // Free swap function
114  template <typename T>
115  inline
116  void
118  lhs.swap(rhs);
119  }
120  }
121 }
122 
123 #endif
virtual BaseHolder< T > * clone() const =0
virtual std::auto_ptr< RefVectorHolderBase > makeVectorBaseHolder() const =0
virtual bool isEqualTo(BaseHolder< T > const &rhs) const =0
virtual T const * getPtr() const =0
virtual bool isAvailable() const =0
#define CMS_CLASS_VERSION(_version_)
Definition: classes.h:31
virtual void const * product() const =0
virtual std::auto_ptr< BaseVectorHolder< T > > makeVectorHolder() const =0
void swap(BaseHolder &)
Definition: BaseHolder.h:109
virtual size_t key() const =0
virtual ProductID id() const =0
virtual std::auto_ptr< RefHolderBase > holder() const =0
virtual bool fillRefIfMyTypeMatches(RefHolderBase &fillme, std::string &msg) const =0
virtual EDProductGetter const * productGetter() const =0
string const
Definition: compareJSON.py:14
#define private
Definition: FWFileEntry.h:17
virtual bool hasProductCache() const =0
#define protected
Definition: FWEveView.cc:35
long double T
BaseHolder & operator=(BaseHolder const &rhs)
Definition: BaseHolder.h:97
def template
Definition: svgfig.py:520