CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Holder.h
Go to the documentation of this file.
1 
2 #ifndef DataFormats_Common_Holder_h
3 #define DataFormats_Common_Holder_h
7 #include <memory>
8 
9 namespace edm {
10  namespace reftobase {
11  //------------------------------------------------------------------
12  // Class template Holder<T,REF>
13  //------------------------------------------------------------------
14 
15  template <class T, class REF>
16  class Holder : public BaseHolder<T> {
17  public:
18  Holder();
19  Holder(Holder const& other);
20  explicit Holder(REF const& iRef);
21  Holder& operator=(Holder const& rhs);
22  void swap(Holder& other);
23  ~Holder() override;
24  BaseHolder<T>* clone() const override;
25 
26  T const* getPtr() const override;
27  ProductID id() const override;
28  size_t key() const override;
29  bool isEqualTo(BaseHolder<T> const& rhs) const override;
30  REF const& getRef() const;
31 
32  std::unique_ptr<RefHolderBase> holder() const override {
33  return std::unique_ptr<RefHolderBase>(new RefHolder<REF>(ref_));
34  }
35  std::unique_ptr<BaseVectorHolder<T> > makeVectorHolder() const override;
36  EDProductGetter const* productGetter() const override;
37 
40  bool isAvailable() const override { return ref_.isAvailable(); }
41 
42  bool isTransient() const override { return ref_.isTransient(); }
43 
44  //Used by ROOT storage
46 
47  private:
48  REF ref_;
49  };
50 
51  //------------------------------------------------------------------
52  // Implementation of Holder<T,REF>
53  //------------------------------------------------------------------
54 
55  template <class T, class REF>
56  inline Holder<T, REF>::Holder() : BaseHolder<T>(), ref_() {}
57 
58  template <class T, class REF>
59  inline Holder<T, REF>::Holder(Holder const& other) : BaseHolder<T>(other), ref_(other.ref_) {}
60 
61  template <class T, class REF>
62  inline Holder<T, REF>::Holder(REF const& r) : BaseHolder<T>(), ref_(r) {}
63 
64  template <class T, class REF>
66  Holder temp(rhs);
67  swap(temp);
68  return *this;
69  }
70 
71  template <class T, class REF>
72  inline void Holder<T, REF>::swap(Holder& other) {
73  std::swap(ref_, other.ref_);
74  }
75 
76  template <class T, class REF>
78 
79  template <class T, class REF>
81  return new Holder(*this);
82  }
83 
84  template <class T, class REF>
85  inline T const* Holder<T, REF>::getPtr() const {
86  return ref_.operator->();
87  }
88 
89  template <class T, class REF>
90  inline ProductID Holder<T, REF>::id() const {
91  return ref_.id();
92  }
93 
94  template <class T, class REF>
95  inline bool Holder<T, REF>::isEqualTo(BaseHolder<T> const& rhs) const {
96  Holder const* h = dynamic_cast<Holder const*>(&rhs);
97  return h && (getRef() == h->getRef());
98  // if (h == 0) return false;
99  // return getRef() == h->getRef();
100  }
101 
102  template <class T, class REF>
103  inline REF const& Holder<T, REF>::getRef() const {
104  return ref_;
105  }
106 
107  template <class T, class REF>
109  return ref_.productGetter();
110  }
111 
112  } // namespace reftobase
113 } // namespace edm
114 
117 
118 namespace edm {
119  namespace reftobase {
120 
121  template <typename T, typename REF>
122  std::unique_ptr<BaseVectorHolder<T> > Holder<T, REF>::makeVectorHolder() const {
123  typedef typename HolderToVectorTrait<T, REF>::type helper;
124  return helper::makeVectorHolder();
125  }
126  } // namespace reftobase
127 } // namespace edm
128 
130 
131 namespace edm {
132  namespace reftobase {
133 
134  template <class T, class REF>
135  inline size_t Holder<T, REF>::key() const {
136  typedef typename RefKeyTrait<REF>::type helper;
137  return helper::key(ref_);
138  }
139 
140  } // namespace reftobase
141 } // namespace edm
142 #endif
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
std::unique_ptr< BaseVectorHolder< T > > makeVectorHolder() const override
Definition: Holder.h:122
Holder & operator=(Holder const &rhs)
Definition: Holder.h:65
REF const & getRef() const
Definition: Holder.h:103
EDProductGetter const * productGetter() const override
Definition: Holder.h:108
std::unique_ptr< RefHolderBase > holder() const override
Definition: Holder.h:32
#define CMS_CLASS_VERSION(_version_)
bool isTransient() const override
Definition: Holder.h:42
void swap(Holder &other)
Definition: Holder.h:72
BaseHolder< T > * clone() const override
Definition: Holder.h:80
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
tuple key
prepare the HTCondor submission files and eventually submit them
bool isAvailable() const override
Definition: Holder.h:40
~Holder() override
Definition: Holder.h:77
T const * getPtr() const override
Definition: Holder.h:85
ProductID id() const override
Definition: Holder.h:90
bool isEqualTo(BaseHolder< T > const &rhs) const override
Definition: Holder.h:95
ProductIndex id() const
Definition: ProductID.h:35
size_t key() const override
Definition: Holder.h:135
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
long double T
def template
Definition: svgfig.py:521
void swap(BaseHolder< T > &lhs, BaseHolder< T > &rhs)
Definition: BaseHolder.h:105