Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
cet::maybe_ref< T > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/cetlib/v3_06_01/source/cetlib/maybe_ref.h"

Public Types

typedef T value_type
 

Public Member Functions

 maybe_ref ()
 
 maybe_ref (T &t)
 
bool isValid () const
 
 operator bool () const
 
void reseat ()
 
void reseat (T &p)
 
Tref ()
 
T const & ref () const
 
void swap (maybe_ref &other)
 

Private Member Functions

Tref_iff_valid () const
 

Private Attributes

Tptr_
 

Detailed Description

template<class T>
class cet::maybe_ref< T >

Definition at line 35 of file maybe_ref.h.

Member Typedef Documentation

template<class T>
typedef T cet::maybe_ref< T >::value_type

Definition at line 52 of file maybe_ref.h.

Constructor & Destructor Documentation

template<class T>
cet::maybe_ref< T >::maybe_ref ( )
inline

Definition at line 54 of file maybe_ref.h.

54 : ptr_(0) {}
template<class T>
cet::maybe_ref< T >::maybe_ref ( T t)
inlineexplicit

Definition at line 55 of file maybe_ref.h.

Member Function Documentation

template<class T>
bool cet::maybe_ref< T >::isValid ( ) const
inline
template<class T>
cet::maybe_ref< T >::operator bool ( ) const
inlineexplicit

Definition at line 64 of file maybe_ref.h.

References cet::maybe_ref< T >::isValid().

64 { return isValid(); }
bool isValid() const
Definition: maybe_ref.h:60
template<class T>
T& cet::maybe_ref< T >::ref ( )
inline

Definition at line 78 of file maybe_ref.h.

References cet::maybe_ref< T >::ref_iff_valid(), and T.

Referenced by fnex::AnalysisSetupBase::FillTruthVars(), fnex::NuMuAnalysisSetup::FillVars(), and cet::operator==().

79  {
80  return ref_iff_valid();
81  }
T & ref_iff_valid() const
Definition: maybe_ref.h:98
template<class T>
T const& cet::maybe_ref< T >::ref ( ) const
inline

Definition at line 83 of file maybe_ref.h.

References cet::maybe_ref< T >::ref_iff_valid().

84  {
85  return ref_iff_valid();
86  }
T & ref_iff_valid() const
Definition: maybe_ref.h:98
template<class T>
T& cet::maybe_ref< T >::ref_iff_valid ( ) const
inlineprivate

Definition at line 98 of file maybe_ref.h.

References cet::maybe_ref< T >::isValid(), and cet::maybe_ref< T >::ptr_.

Referenced by cet::maybe_ref< T >::ref().

99  {
100  if (isValid())
101  return *ptr_;
102 
103  // TODO: consider throwing a cet::exception
104  throw std::logic_error("cet::maybe_ref<>: referent does not exist");
105  }
bool isValid() const
Definition: maybe_ref.h:60
template<class T>
void cet::maybe_ref< T >::reseat ( )
inline

Definition at line 67 of file maybe_ref.h.

References cet::maybe_ref< T >::ptr_.

68  {
69  ptr_ = 0;
70  }
template<class T>
void cet::maybe_ref< T >::reseat ( T p)
inline

Definition at line 72 of file maybe_ref.h.

References cet::maybe_ref< T >::ptr_, and T.

73  {
74  ptr_ = &p;
75  }
const char * p
Definition: xmltok.h:285
template<class T>
void cet::maybe_ref< T >::swap ( maybe_ref< T > &  other)
inline

Definition at line 89 of file maybe_ref.h.

References cet::maybe_ref< T >::ptr_, and std::swap().

Referenced by cet::swap().

90  {
91  std::swap(ptr_, other.ptr_);
92  }
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)

Member Data Documentation

template<class T>
T* cet::maybe_ref< T >::ptr_
private

The documentation for this class was generated from the following file: