Anp::Handle< T > Class Template Reference

#include <Handle.h>

List of all members.

Public Member Functions

 Handle ()
 Handle (T *ptr)
 Handle (const Handle &rhs)
 ~Handle ()
const Handleoperator= (const Handle &rhs)
T * operator-> () const
T * get () const
T & operator* () const
bool valid () const
void release ()

Private Member Functions

void init ()

Private Attributes

T * p

Detailed Description

template<typename T>
class Anp::Handle< T >

Definition at line 71 of file PhysicsNtuple/HEAD/Handle.h.


Constructor & Destructor Documentation

template<typename T >
Handle< T >::Handle (  )  [inline]

default ctor

Definition at line 134 of file PhysicsNtuple/HEAD/Handle.h.

00134                   : p(0)
00135 {}

template<typename T>
Handle< T >::Handle ( T *  realPtr  )  [inline, explicit]

ctor from a raw pointer

Definition at line 141 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::init().

00141                             : p(realPtr)
00142 {
00143     init();
00144 }

template<typename T>
Handle< T >::Handle ( const Handle< T > &  rhs  )  [inline]

copy ctor

Definition at line 150 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::init().

00150                                    : p(rhs.p)
00151 {
00152     init();
00153 }

template<typename T >
Handle< T >::~Handle (  )  [inline]

dtor

Definition at line 193 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::p, and Anp::Handle< T >::release().

00194 {
00195    if (p)
00196    {
00197       p -> release();
00198    }
00199 }


Member Function Documentation

template<typename T >
T * Handle< T >::get (  )  const [inline]

provides access to pointer

Definition at line 214 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::p.

00215 { 
00216    return p; 
00217 }

template<typename T >
void Handle< T >::init ( void   )  [inline, private]

init

Definition at line 181 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::p.

Referenced by Anp::Handle< T >::Handle(), and Anp::Handle< T >::operator=().

00182 {
00183    if (p)
00184    {
00185       p -> add_ref();
00186    }
00187 }

template<typename T >
T & Handle< T >::operator* (  )  const [inline]

dereference operator

Definition at line 223 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::p.

00224 { 
00225    return *p; 
00226 }

template<typename T >
T * Handle< T >::operator-> (  )  const [inline]

operator-> allows usage with pointer semantics

Definition at line 205 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::p.

00206 { 
00207    return p; 
00208 }

template<typename T >
const Handle< T > & Handle< T >::operator= ( const Handle< T > &  rhs  )  [inline]

assignment operator

Definition at line 160 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::init(), Anp::Handle< T >::p, and Anp::Handle< T >::release().

00161 {
00162    if (p != rhs.p)
00163    {
00164       if (p)
00165       {
00166          p -> release();
00167       }
00168       
00169       p = rhs.p;
00170       init();
00171    }
00172 
00173    return *this;
00174 }

template<typename T >
void Handle< T >::release (  )  [inline]

release - set pointer to 0

Definition at line 246 of file PhysicsNtuple/HEAD/Handle.h.

References Anp::Handle< T >::p.

Referenced by Anp::SelectFlux::Init(), Anp::Handle< T >::operator=(), Anp::PlotTime::Run(), and Anp::Handle< T >::~Handle().

00247 {
00248    if (p)
00249    {
00250       p -> release();
00251    }
00252    p = 0;
00253 }

template<typename T >
bool Handle< T >::valid (  )  const [inline]

Member Data Documentation

template<typename T>
T* Anp::Handle< T >::p [private]

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

Generated on 14 Dec 2017 for loon by  doxygen 1.6.1