CMS 3D CMS Logo

RefHolder_.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_RefHolder__h
2 #define DataFormats_Common_RefHolder__h
4 
8 #include <memory>
9 #include <typeinfo>
10 #include <string>
11 
12 namespace edm {
13  namespace reftobase {
14  //------------------------------------------------------------------
15  // Class template RefHolder<REF>
16  //------------------------------------------------------------------
17 
18  template <class REF>
19  class RefHolder : public RefHolderBase {
20  public:
21  RefHolder();
22  explicit RefHolder(REF const& ref);
23  void swap(RefHolder& other);
24  ~RefHolder() override;
25  RefHolderBase* clone() const override;
26 
27  ProductID id() const override;
28  size_t key() const override;
29  bool isEqualTo(RefHolderBase const& rhs) const override;
30  REF const& getRef() const;
31  void setRef(REF const& r);
32  std::unique_ptr<RefVectorHolderBase> makeVectorHolder() const override;
33  EDProductGetter const* productGetter() const override;
34 
37  bool isAvailable() const override { return ref_.isAvailable(); }
38 
39  bool isTransient() const override { return ref_.isTransient(); }
40 
41  //Needed for ROOT storage
43  private:
44  void const* pointerToType(std::type_info const& iToType) const override;
45  REF ref_;
46  };
47 
48  //------------------------------------------------------------------
49  // Implementation of RefHolder<REF>
50  //------------------------------------------------------------------
51 
52  template <class REF>
54 
55  template <class REF>
56  RefHolder<REF>::RefHolder(REF const& ref) : RefHolderBase(), ref_(ref) {}
57 
58  template <class REF>
60 
61  template <class REF>
63  return new RefHolder(ref_);
64  }
65 
66  template <class REF>
68  return ref_.id();
69  }
70 
71  template <class REF>
72  bool RefHolder<REF>::isEqualTo(RefHolderBase const& rhs) const {
73  RefHolder const* h(dynamic_cast<RefHolder const*>(&rhs));
74  return h && (getRef() == h->getRef());
75  }
76 
77  template <class REF>
78  inline REF const& RefHolder<REF>::getRef() const {
79  return ref_;
80  }
81 
82  template <class REF>
84  return ref_.productGetter();
85  }
86 
87  template <class REF>
89  std::swap(ref_, other.ref_);
90  }
91 
92  template <class REF>
93  inline void RefHolder<REF>::setRef(REF const& r) {
94  ref_ = r;
95  }
96 
97  template <class REF>
98  void const* RefHolder<REF>::pointerToType(std::type_info const& iToType) const {
99  typedef typename REF::value_type contained_type;
100  if (iToType == typeid(contained_type)) {
101  return ref_.get();
102  }
103  return pointerToBase(iToType, ref_.get());
104  }
105  } // namespace reftobase
106 } // namespace edm
107 
108 #endif
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
bool isAvailable() const override
Definition: RefHolder_.h:37
REF const & getRef() const
Definition: RefHolder_.h:78
std::unique_ptr< RefVectorHolderBase > makeVectorHolder() const override
Definition: RefHolder.h:14
#define CMS_CLASS_VERSION(_version_)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool isTransient() const override
Definition: RefHolder_.h:39
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
ProductID id() const override
Definition: RefHolder_.h:67
RefHolderBase * clone() const override
Definition: RefHolder_.h:62
ProductIndex id() const
Definition: ProductID.h:35
void const * pointerToType(std::type_info const &iToType) const override
Definition: RefHolder_.h:98
void setRef(REF const &r)
Definition: RefHolder_.h:93
HLT enums.
EDProductGetter const * productGetter() const override
Definition: RefHolder_.h:83
bool isEqualTo(RefHolderBase const &rhs) const override
Definition: RefHolder_.h:72
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void const * pointerToBase(std::type_info const &baseTypeInfo, T const *address)
Definition: OffsetToBase.h:47
void swap(RefHolder &other)
Definition: RefHolder_.h:88
size_t key() const override
Definition: RefHolder.h:26