CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RefHolder_.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_RefHolder__h
2 #define DataFormats_Common_RefHolder__h
4 
9 #include <memory>
10 
11 namespace edm {
12  namespace reftobase {
13  //------------------------------------------------------------------
14  // Class template RefHolder<REF>
15  //------------------------------------------------------------------
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  virtual ~RefHolder();
25  virtual RefHolderBase* clone() const;
26 
27  virtual ProductID id() const;
28  virtual size_t key() const;
29  virtual bool isEqualTo(RefHolderBase const& rhs) const;
30  virtual bool fillRefIfMyTypeMatches(RefHolderBase& fillme,
31  std::string& msg) const;
32  REF const& getRef() const;
33  void setRef(REF const& r);
34  virtual std::auto_ptr<RefVectorHolderBase> makeVectorHolder() const;
35  virtual EDProductGetter const* productGetter() const;
36  virtual bool hasProductCache() const;
37  virtual void const * product() const;
38 
41  virtual bool isAvailable() const { return ref_.isAvailable(); }
42 
43  //Needed for ROOT storage
45  private:
46  virtual void const* pointerToType(TypeWithDict const& iToType) const;
47  REF ref_;
48  };
49 
50  //------------------------------------------------------------------
51  // Implementation of RefHolder<REF>
52  //------------------------------------------------------------------
53 
54  template <class REF>
55  RefHolder<REF>::RefHolder() :
56  RefHolderBase(), ref_()
57  { }
58 
59  template <class REF>
60  RefHolder<REF>::RefHolder(REF const& ref) :
61  RefHolderBase(), ref_(ref)
62  { }
63 
64  template <class REF>
66  { }
67 
68  template <class REF>
71  {
72  return new RefHolder(ref_);
73  }
74 
75  template <class REF>
76  ProductID
78  {
79  return ref_.id();
80  }
81 
82  template <class REF>
83  bool
85  {
86  RefHolder const* h(dynamic_cast<RefHolder const*>(&rhs));
87  return h && (getRef() == h->getRef());
88  }
89 
90  template <class REF>
91  bool
93  std::string& msg) const
94  {
95  RefHolder* h = dynamic_cast<RefHolder*>(&fillme);
96  bool conversion_worked = (h != 0);
97  if (conversion_worked)
98  h->setRef(ref_);
99  else
100  msg = typeid(REF).name();
101  return conversion_worked;
102  }
103 
104  template <class REF>
105  inline
106  REF const&
108  {
109  return ref_;
110  }
111 
112  template<class REF>
114  return ref_.productGetter();
115  }
116 
117  template<class REF>
119  return ref_.hasProductCache();
120  }
121 
122  template<class REF>
123  void const * RefHolder<REF>::product() const {
124  return ref_.product();
125  }
126 
127  template <class REF>
128  inline
129  void
131  {
132  std::swap(ref_, other.ref_);
133  }
134 
135  template <class REF>
136  inline
137  void
139  {
140  ref_ = r;
141  }
142 
143  template <class REF>
144  void const*
146  {
147  typedef typename REF::value_type contained_type;
148  static TypeWithDict const s_type(typeid(contained_type));
149 
150  return iToType.pointerToBaseType(ref_.get(), s_type);
151  }
152  } // namespace reftobase
153 }
154 
155 #endif
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
void const * pointerToBaseType(void const *ptr, TypeWithDict const &derivedType) const
REF const & getRef() const
Definition: RefHolder_.h:107
virtual ProductID id() const
Definition: RefHolder_.h:77
virtual bool hasProductCache() const
Definition: RefHolder_.h:118
virtual RefHolderBase * clone() const
Definition: RefHolder_.h:70
#define CMS_CLASS_VERSION(_version_)
Definition: classes.h:31
virtual bool isAvailable() const
Definition: RefHolder_.h:41
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Container::value_type value_type
virtual EDProductGetter const * productGetter() const
Definition: RefHolder_.h:113
virtual void const * product() const
Definition: RefHolder_.h:123
virtual bool fillRefIfMyTypeMatches(RefHolderBase &fillme, std::string &msg) const
Definition: RefHolder_.h:92
virtual std::auto_ptr< RefVectorHolderBase > makeVectorHolder() const
Definition: RefHolder.h:14
void setRef(REF const &r)
Definition: RefHolder_.h:138
string const
Definition: compareJSON.py:14
#define private
Definition: FWFileEntry.h:17
virtual bool isEqualTo(RefHolderBase const &rhs) const
Definition: RefHolder_.h:84
virtual size_t key() const
Definition: RefHolder.h:27
ProductIndex id() const
Definition: ProductID.h:38
virtual void const * pointerToType(TypeWithDict const &iToType) const
Definition: RefHolder_.h:145
void swap(RefHolder &other)
Definition: RefHolder_.h:130
def template
Definition: svgfig.py:520