CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

edm::Ptr< T > Class Template Reference

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

List of all members.

Public Types

typedef unsigned long key_type
typedef T value_type

Public Member Functions

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

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<typename 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 38 of file Ptr.h.


Member Typedef Documentation

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

Definition at line 42 of file Ptr.h.

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

Definition at line 43 of file Ptr.h.


Constructor & Destructor Documentation

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

Definition at line 47 of file Ptr.h.

                                                                    :
    core_(handle.id(), getItem_(handle.product(), itemKey), 0, false), key_(itemKey) {}
template<typename T>
template<typename C >
edm::Ptr< T >::Ptr ( OrphanHandle< C > const &  handle,
key_type  itemKey,
bool  setNow = true 
) [inline]

Definition at line 52 of file Ptr.h.

                                                                          :
    core_(handle.id(), getItem_(handle.product(), itemKey), 0, false), key_(itemKey) {}
template<typename T>
template<typename C >
edm::Ptr< T >::Ptr ( C const *  product,
key_type  itemKey,
bool  setNow = true 
) [inline]

Definition at line 67 of file Ptr.h.

                                                             :
    core_(ProductID(), product != 0 ? getItem_(product,itemKey) : 0, 0, true),
         key_(product != 0 ? itemKey : key_traits<key_type>::value) {}
template<typename T>
template<typename C >
edm::Ptr< T >::Ptr ( TestHandle< C > const &  handle,
key_type  itemKey,
bool  setNow = true 
) [inline]

Definition at line 75 of file Ptr.h.

                                                                        :
    core_(handle.id(), getItem_(handle.product(), itemKey), 0, true), key_(itemKey) {}
template<typename 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 81 of file Ptr.h.

                                                                                         :
    core_(productID, 0, mustBeNonZero(prodGetter, "Ptr", productID), false), key_(itemKey) {
    }
template<typename 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 92 of file Ptr.h.

                                                                      :
    core_(productID, item, 0, false),
    key_(item_key) {
    }
template<typename T>
edm::Ptr< T >::Ptr ( ProductID const &  id) [inline, explicit]

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

Definition at line 101 of file Ptr.h.

                                      :
    core_(id, 0, 0, false),
    key_(key_traits<key_type>::value)
    { }
template<typename T>
edm::Ptr< T >::Ptr ( ) [inline]

Definition at line 106 of file Ptr.h.

template<typename T>
edm::Ptr< T >::Ptr ( Ptr< T > const &  iOther) [inline]

Definition at line 111 of file Ptr.h.

                             :
    core_(iOther.core_),
    key_(iOther.key_)
    {}
template<typename 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 117 of file Ptr.h.

                                                                                              :
    core_(iOther.id(),
          (iOther.hasProductCache() ? static_cast<T const*>(iOther.get()): static_cast<T const*>(0)),
          iOther.productGetter(),
          iOther.isTransient()),
    key_(iOther.key()) {
    }
template<typename 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 
) [inline, explicit]

Definition at line 127 of file Ptr.h.

                                                                                              :
    core_(iOther.id(),
          dynamic_cast<T const*>(iOther.get()),
          0,
          iOther.isTransient()),
    key_(iOther.key()) {
    }
template<typename T>
edm::Ptr< T >::~Ptr ( ) [inline]

Destructor.

Definition at line 136 of file Ptr.h.

{}
template<typename T>
edm::Ptr< T >::Ptr ( T const *  item,
key_type  item_key 
) [inline, private]

Constructor for extracting a transient Ptr from a PtrVector.

Definition at line 185 of file Ptr.h.

                                          :
    core_(ProductID(), item, 0, true),
    key_(item_key) {
    }

Member Function Documentation

template<typename T>
T const* edm::Ptr< T >::get ( void  ) const [inline]
template<typename T>
void edm::Ptr< T >::getData_ ( ) const [inline, private]

Definition at line 194 of file Ptr.h.

                          {
      if(!hasProductCache() && 0 != productGetter()) {
        void const* ad = 0;
        EDProduct const* prod = productGetter()->getIt(core_.id());
        if(prod == 0) {
          core_.productNotFoundException(typeid(T));
        }
        prod->setPtr(typeid(T), key_, ad);
        core_.setProductPtr(ad);
      }
    }
template<typename T >
template<typename C >
T const * Ptr< T >::getItem_ ( C const *  product,
key_type  iKey 
) [private]

Definition at line 212 of file Ptr.h.

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

                                                           {
    assert (product != 0);
    typename C::const_iterator it = product->begin();
    std::advance(it,iKey);
    T const* address = detail::GetProduct<C>::address(it);
    return address;
  }
template<typename T>
bool edm::Ptr< T >::hasProductCache ( ) const [inline]

Definition at line 175 of file Ptr.h.

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

{ return 0 != core_.productPtr(); }
template<typename T>
ProductID edm::Ptr< T >::id ( void  ) const [inline]
template<typename 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 162 of file Ptr.h.

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

{return core_.isAvailable();}
template<typename T>
bool edm::Ptr< T >::isNonnull ( ) const [inline]
template<typename T>
bool edm::Ptr< T >::isNull ( ) const [inline]
template<typename T>
bool edm::Ptr< T >::isTransient ( ) const [inline]

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

Definition at line 165 of file Ptr.h.

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

{return core_.isTransient();}
template<typename T>
key_type edm::Ptr< T >::key ( ) const [inline]
template<typename T>
bool edm::Ptr< T >::operator! ( ) const [inline]

Checks for null.

Definition at line 158 of file Ptr.h.

{return isNull();}
template<typename T >
T const & Ptr< T >::operator* ( ) const [inline]

Dereference operator.

Definition at line 224 of file Ptr.h.

References compareJSON::const.

                          {
    getData_();
    return *reinterpret_cast<T const*>(core_.productPtr());
  }
template<typename T >
T const * Ptr< T >::operator-> ( ) const [inline]

Member dereference operator.

Definition at line 233 of file Ptr.h.

References compareJSON::const.

Referenced by edm::Ptr< pat::MET >::get().

                           {
    getData_();
    return reinterpret_cast<T const*>(core_.productPtr());
  }
template<typename T>
void const* edm::Ptr< T >::product ( ) const [inline]

Definition at line 180 of file Ptr.h.

{return 0;}
template<typename T>
EDProductGetter const* edm::Ptr< T >::productGetter ( ) const [inline]

Accessor for product getter.

Definition at line 171 of file Ptr.h.

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

{return core_.productGetter();}
template<typename T>
RefCore const& edm::Ptr< T >::refCore ( ) const [inline]

Definition at line 177 of file Ptr.h.

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

{return core_;}

Friends And Related Function Documentation

template<typename T>
friend class PtrVectorBase [friend]

Definition at line 39 of file Ptr.h.


Member Data Documentation

template<typename T>
RefCore edm::Ptr< T >::core_ [private]
template<typename T>
key_type edm::Ptr< T >::key_ [private]