CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
edm::Ptr< T > Class Template Reference

#include <DataFormats/Common/interface/Ptr.h>

Public Types

typedef unsigned long key_type
 
typedef T value_type
 

Public Member Functions

T const * get () const
 Returns C++ pointer to the item. More...
 
bool hasProductCache () const
 
ProductID id () const
 Accessor for product ID. More...
 
bool isAvailable () const
 
bool isNonnull () const
 Checks for non-null. More...
 
bool isNull () const
 Checks for null. More...
 
bool isTransient () const
 Checks if this Ptr is transient (i.e. not persistable). More...
 
key_type key () const
 
bool operator! () const
 Checks for null. More...
 
T const & operator* () const
 Dereference operator. More...
 
T const * operator-> () const
 Member dereference operator. More...
 
void const * product () const
 
EDProductGetter const * productGetter () const
 Accessor for product getter. More...
 
template<typename C >
 Ptr (Handle< C > const &handle, key_type itemKey, bool setNow=true)
 
template<typename C >
 Ptr (OrphanHandle< C > const &handle, key_type itemKey, bool setNow=true)
 
template<typename C >
 Ptr (C const *product, key_type itemKey, bool setNow=true)
 
template<typename C >
 Ptr (TestHandle< C > const &handle, key_type itemKey, bool setNow=true)
 
 Ptr (ProductID const &productID, key_type itemKey, EDProductGetter const *prodGetter)
 
 Ptr (ProductID const &productID, T const *item, key_type item_key)
 
 Ptr (ProductID const &id)
 
 Ptr ()
 
 Ptr (Ptr< T > const &iOther)
 
template<typename U >
 Ptr (Ptr< U > const &iOther, typename boost::enable_if_c< boost::is_base_of< T, U >::value >::type *=0)
 
template<typename U >
 Ptr (Ptr< U > const &iOther, typename boost::enable_if_c< boost::is_base_of< U, T >::value >::type *=0)
 
RefCore const & refCore () const
 
 ~Ptr ()
 Destructor. More...
 

Private Member Functions

void getData_ () const
 
template<typename C >
T const * getItem_ (C const *product, key_type iKey)
 
 Ptr (T const *item, key_type item_key)
 

Private Attributes

RefCore core_
 
key_type key_
 

Friends

class PtrVectorBase
 

Detailed Description

template<class T>
class edm::Ptr< T >

Description: Persistent 'pointer' to an item in a collection where the collection is in the edm::Event

Usage: <usage>

Definition at line 51 of file AssociativeIterator.h.

Member Typedef Documentation

template<class T>
typedef unsigned long edm::Ptr< T >::key_type

Definition at line 43 of file Ptr.h.

template<class T>
typedef T edm::Ptr< T >::value_type

Definition at line 44 of file Ptr.h.

Constructor & Destructor Documentation

template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( Handle< C > const &  handle,
key_type  itemKey,
bool  setNow = true 
)
inline

Definition at line 48 of file Ptr.h.

48  :
49  core_(handle.id(), getItem_(handle.product(), itemKey), 0, false), key_(itemKey) {}
key_type key_
Definition: Ptr.h:212
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:217
RefCore core_
Definition: Ptr.h:211
template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( OrphanHandle< C > const &  handle,
key_type  itemKey,
bool  setNow = true 
)
inline

Definition at line 53 of file Ptr.h.

53  :
54  core_(handle.id(), getItem_(handle.product(), itemKey), 0, false), key_(itemKey) {}
key_type key_
Definition: Ptr.h:212
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:217
tuple handle
Definition: patZpeak.py:22
RefCore core_
Definition: Ptr.h:211
template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( C const *  product,
key_type  itemKey,
bool  setNow = true 
)
inline

Definition at line 68 of file Ptr.h.

68  :
69  core_(ProductID(), product != 0 ? getItem_(product,itemKey) : 0, 0, true),
70  key_(product != 0 ? itemKey : key_traits<key_type>::value) {}
key_type key_
Definition: Ptr.h:212
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:217
void const * product() const
Definition: Ptr.h:181
RefCore core_
Definition: Ptr.h:211
template<class T>
template<typename C >
edm::Ptr< T >::Ptr ( TestHandle< C > const &  handle,
key_type  itemKey,
bool  setNow = true 
)
inline

Definition at line 76 of file Ptr.h.

76  :
77  core_(handle.id(), getItem_(handle.product(), itemKey), 0, true), key_(itemKey) {}
key_type key_
Definition: Ptr.h:212
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:217
tuple handle
Definition: patZpeak.py:22
RefCore core_
Definition: Ptr.h:211
template<class T>
edm::Ptr< T >::Ptr ( ProductID const &  productID,
key_type  itemKey,
EDProductGetter const *  prodGetter 
)
inline

Constructor for those users who do not have a product handle, but have a pointer to a product getter (such as the EventPrincipal). prodGetter will ususally be a pointer to the event principal.

Definition at line 82 of file Ptr.h.

82  :
83  core_(productID, 0, mustBeNonZero(prodGetter, "Ptr", productID), false), key_(itemKey) {
84  }
key_type key_
Definition: Ptr.h:212
EDProductGetter const * mustBeNonZero(EDProductGetter const *prodGetter, std::string refType, ProductID const &productID)
RefCore core_
Definition: Ptr.h:211
template<class T>
edm::Ptr< T >::Ptr ( ProductID const &  productID,
T const *  item,
key_type  item_key 
)
inline

Constructor for use in the various X::fillView(...) functions or for extracting a persistent Ptr from a PtrVector. It is an error (not diagnosable at compile- or run-time) to call this constructor with a pointer to a T unless the pointed-to T object is already in a collection of type C stored in the Event. The given ProductID must be the id of the collection in the Event.

Definition at line 93 of file Ptr.h.

93  :
94  core_(productID, item, 0, false),
95  key_(item_key) {
96  }
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211
template<class T>
edm::Ptr< T >::Ptr ( ProductID const &  id)
inlineexplicit

Constructor that creates an invalid ("null") Ptr that is associated with a given product (denoted by that product's ProductID).

Definition at line 102 of file Ptr.h.

102  :
103  core_(id, 0, 0, false),
105  { }
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211
template<class T>
edm::Ptr< T >::Ptr ( )
inline

Definition at line 107 of file Ptr.h.

107  :
108  core_(),
110  {}
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211
template<class T>
edm::Ptr< T >::Ptr ( Ptr< T > const &  iOther)
inline

Definition at line 112 of file Ptr.h.

112  :
113  core_(iOther.core_),
114  key_(iOther.key_)
115  {}
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211
template<class T>
template<typename U >
edm::Ptr< T >::Ptr ( Ptr< U > const &  iOther,
typename boost::enable_if_c< boost::is_base_of< T, U >::value >::type = 0 
)
inline

Definition at line 118 of file Ptr.h.

118  :
119  core_(iOther.id(),
120  (iOther.hasProductCache() ? static_cast<T const*>(iOther.get()): static_cast<T const*>(0)),
121  iOther.productGetter(),
122  iOther.isTransient()),
123  key_(iOther.key()) {
124  }
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211
string const
Definition: compareJSON.py:14
long double T
template<class T>
template<typename U >
edm::Ptr< T >::Ptr ( Ptr< U > const &  iOther,
typename boost::enable_if_c< boost::is_base_of< U, T >::value >::type = 0 
)
inlineexplicit

Definition at line 128 of file Ptr.h.

128  :
129  core_(iOther.id(),
130  dynamic_cast<T const*>(iOther.get()),
131  0,
132  iOther.isTransient()),
133  key_(iOther.key()) {
134  }
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211
string const
Definition: compareJSON.py:14
long double T
template<class T>
edm::Ptr< T >::~Ptr ( )
inline

Destructor.

Definition at line 137 of file Ptr.h.

137 {}
template<class T>
edm::Ptr< T >::Ptr ( T const *  item,
key_type  item_key 
)
inlineprivate

Constructor for extracting a transient Ptr from a PtrVector.

Definition at line 190 of file Ptr.h.

190  :
191  core_(ProductID(), item, 0, true),
192  key_(item_key) {
193  }
key_type key_
Definition: Ptr.h:212
RefCore core_
Definition: Ptr.h:211

Member Function Documentation

template<class T>
T const* edm::Ptr< T >::get ( void  ) const
inline
template<class T>
void edm::Ptr< T >::getData_ ( ) const
inlineprivate

Definition at line 199 of file Ptr.h.

199  {
200  if(!hasProductCache() && 0 != productGetter()) {
201  void const* ad = 0;
202  EDProduct const* prod = productGetter()->getIt(core_.id());
203  if(prod == 0) {
205  }
206  prod->setPtr(typeid(T), key_, ad);
207  core_.setProductPtr(ad);
208  }
209  }
key_type key_
Definition: Ptr.h:212
void setProductPtr(void const *prodPtr) const
Definition: RefCore.h:28
virtual EDProduct const * getIt(ProductID const &) const =0
void productNotFoundException(std::type_info const &type) const
Definition: RefCore.cc:75
RefCore core_
Definition: Ptr.h:211
ProductID id() const
Definition: RefCore.h:23
bool hasProductCache() const
Definition: Ptr.h:176
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: Ptr.h:172
long double T
template<typename T >
template<typename C >
T const * Ptr< T >::getItem_ ( C const *  product,
key_type  iKey 
)
private

Definition at line 217 of file Ptr.h.

References edm::detail::GetProduct< COLLECTION >::address().

217  {
218  assert (product != 0);
219  typename C::const_iterator it = product->begin();
220  std::advance(it,iKey);
222  return address;
223  }
char * address
Definition: mlp_lapack.h:14
static const element_type * address(const iter &i)
Definition: GetProduct.h:34
void const * product() const
Definition: Ptr.h:181
long double T
template<class T>
bool edm::Ptr< T >::hasProductCache ( ) const
inline

Definition at line 176 of file Ptr.h.

Referenced by edm::Ptr< reco::Muon >::getData_(), edm::FwdPtr< T >::hasProductCache(), and edm::PtrVector< Candidate >::push_back().

176 { return 0 != core_.productPtr(); }
void const * productPtr() const
Definition: RefCore.h:26
RefCore core_
Definition: Ptr.h:211
template<class T>
ProductID edm::Ptr< T >::id ( void  ) const
inline
template<class T>
bool edm::Ptr< T >::isAvailable ( ) const
inline

Checks if collection is in memory or available in the event. No type checking is done.

Definition at line 163 of file Ptr.h.

Referenced by reco::CaloJet::getCaloConstituent(), reco::PFJet::getPFConstituent(), edm::FwdPtr< T >::isAvailable(), reco::PFClusterJet::pfCluster(), and reco::TrackJet::track().

163 {return core_.isAvailable();}
bool isAvailable() const
Definition: RefCore.cc:103
RefCore core_
Definition: Ptr.h:211
template<class T>
bool edm::Ptr< T >::isNonnull ( ) const
inline
template<class T>
bool edm::Ptr< T >::isNull ( ) const
inline
template<class T>
bool edm::Ptr< T >::isTransient ( ) const
inline

Checks if this Ptr is transient (i.e. not persistable).

Definition at line 166 of file Ptr.h.

Referenced by edm::FwdPtr< T >::isTransient().

166 {return core_.isTransient();}
RefCore core_
Definition: Ptr.h:211
bool isTransient() const
Definition: RefCore.h:64
template<class T>
key_type edm::Ptr< T >::key ( ) const
inline
template<class T>
bool edm::Ptr< T >::operator! ( ) const
inline

Checks for null.

Definition at line 159 of file Ptr.h.

159 {return isNull();}
bool isNull() const
Checks for null.
Definition: Ptr.h:153
template<typename T >
T const & Ptr< T >::operator* ( ) const
inline

Dereference operator.

Definition at line 229 of file Ptr.h.

References compareJSON::const.

229  {
230  getData_();
231  return *reinterpret_cast<T const*>(core_.productPtr());
232  }
void const * productPtr() const
Definition: RefCore.h:26
RefCore core_
Definition: Ptr.h:211
string const
Definition: compareJSON.py:14
void getData_() const
Definition: Ptr.h:199
long double T
template<typename T >
T const * Ptr< T >::operator-> ( ) const
inline

Member dereference operator.

Definition at line 238 of file Ptr.h.

References compareJSON::const.

Referenced by edm::Ptr< reco::Muon >::get().

238  {
239  getData_();
240  return reinterpret_cast<T const*>(core_.productPtr());
241  }
void const * productPtr() const
Definition: RefCore.h:26
RefCore core_
Definition: Ptr.h:211
string const
Definition: compareJSON.py:14
void getData_() const
Definition: Ptr.h:199
long double T
template<class T>
void const* edm::Ptr< T >::product ( ) const
inline

Definition at line 181 of file Ptr.h.

181 {return 0;}
template<class T>
EDProductGetter const* edm::Ptr< T >::productGetter ( ) const
inline

Accessor for product getter.

Definition at line 172 of file Ptr.h.

Referenced by edm::Ptr< reco::Muon >::getData_(), and edm::FwdPtr< T >::productGetter().

172 {return core_.productGetter();}
RefCore core_
Definition: Ptr.h:211
EDProductGetter const * productGetter() const
Definition: RefCore.h:47
template<class T>
RefCore const& edm::Ptr< T >::refCore ( ) const
inline

Definition at line 178 of file Ptr.h.

Referenced by edm::operator==(), edm::PtrVector< Candidate >::push_back(), and edm::FwdPtr< T >::refCore().

178 {return core_;}
RefCore core_
Definition: Ptr.h:211

Friends And Related Function Documentation

template<class T>
friend class PtrVectorBase
friend

Definition at line 40 of file Ptr.h.

Member Data Documentation

template<class T>
RefCore edm::Ptr< T >::core_
private
template<class T>
key_type edm::Ptr< T >::key_
private