LnPtr< T > Class Template Reference

: A Reference Counted Smart Pointer for Intrinsic or User-Defined Types More...

#include <Pointers.H>

Inheritance diagram for LnPtr< T >:

Inheritance graph
[legend]
Collaboration diagram for LnPtr< T >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 LnPtr ()
 The default constructor. The wrapped pointer is null.
 LnPtr (T *rhs)
 Construct a LnPtr<T> setting the wrapped pointer to rhs.
LnPtr< T > & operator= (const LnPtr< T > &rhs)
 The copy assignment operator.
LnPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
 ~LnPtr ()
 The destructor -- decrements the reference count and deletes the wrapped pointer if there is only one reference.
bool unique () const
 Returns true if only one reference to the wrapped pointer.
int linkCount () const
 Returns the number of references to the wrapped pointer.
T & operator* () const
 Returns a reference to the value pointed to by the wrapped pointer; i.e.
bool isNull () const
 Returns true if the wrapped pointer is null.
bool operator== (const LnPtr< T > &rhs) const
 Are the two pointers (not the values to which they point) equal?
bool operator!= (const LnPtr< T > &rhs) const
 Are the two pointers not equal?
 LnPtr ()
 The default constructor. The wrapped pointer is null.
 LnPtr (T *rhs)
 Construct a LnPtr<T> setting the wrapped pointer to rhs.
LnPtr< T > & operator= (const LnPtr< T > &rhs)
 The copy assignment operator.
LnPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
 ~LnPtr ()
 The destructor -- decrements the reference count and deletes the wrapped pointer if there is only one reference.
bool unique () const
 Returns true if only one reference to the wrapped pointer.
int linkCount () const
 Returns the number of references to the wrapped pointer.
T & operator* () const
 Returns a reference to the value pointed to by the wrapped pointer; i.e.
bool isNull () const
 Returns true if the wrapped pointer is null.
bool operator== (const LnPtr< T > &rhs) const
 Are the two pointers (not the values to which they point) equal?
bool operator!= (const LnPtr< T > &rhs) const
 Are the two pointers not equal?
 LnPtr ()
 The default constructor. The wrapped pointer is null.
 LnPtr (T *rhs)
 Construct a LnPtr<T> setting the wrapped pointer to rhs.
LnPtr< T > & operator= (const LnPtr< T > &rhs)
 The copy assignment operator.
LnPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
 ~LnPtr ()
 The destructor -- decrements the reference count and deletes the wrapped pointer if there is only one reference.
bool unique () const
 Returns true if only one reference to the wrapped pointer.
int linkCount () const
 Returns the number of references to the wrapped pointer.
T & operator* () const
 Returns a reference to the value pointed to by the wrapped pointer; i.e.
bool isNull () const
 Returns true if the wrapped pointer is null.
bool operator== (const LnPtr< T > &rhs) const
 Are the two pointers (not the values to which they point) equal?
bool operator!= (const LnPtr< T > &rhs) const
 Are the two pointers not equal?

Protected Attributes

T * ptr
T * ptr
T * ptr


Detailed Description

template<class T>
class LnPtr< T >

: A Reference Counted Smart Pointer for Intrinsic or User-Defined Types

The template class LnPtr<T> provides a reference counted wrapper around a pointer to type T (a T*). This "smart" pointer is intended for use with any type type T, including the intrinsic types. For this reason, we do not supply an operator->(), as such an operator on intrinsic types has only recently become a part of the C++ language and many compilers do not yet implement it.


Constructor & Destructor Documentation

template<class T>
LnPtr< T >::LnPtr (  )  [inline]

The default constructor. The wrapped pointer is null.

template<class T>
LnPtr< T >::LnPtr ( T *  rhs  )  [inline, explicit]

Construct a LnPtr<T> setting the wrapped pointer to rhs.

template<class T>
LnPtr< T >::~LnPtr (  )  [inline]

The destructor -- decrements the reference count and deletes the wrapped pointer if there is only one reference.

References LnPtr< T >::ptr, and UseCount::unique().

template<class T>
LnPtr< T >::LnPtr (  ) 

The default constructor. The wrapped pointer is null.

template<class T>
LnPtr< T >::LnPtr ( T *  rhs  )  [explicit]

Construct a LnPtr<T> setting the wrapped pointer to rhs.

template<class T>
LnPtr< T >::~LnPtr (  ) 

The destructor -- decrements the reference count and deletes the wrapped pointer if there is only one reference.

template<class T>
LnPtr< T >::LnPtr (  ) 

The default constructor. The wrapped pointer is null.

template<class T>
LnPtr< T >::LnPtr ( T *  rhs  )  [explicit]

Construct a LnPtr<T> setting the wrapped pointer to rhs.

template<class T>
LnPtr< T >::~LnPtr (  ) 

The destructor -- decrements the reference count and deletes the wrapped pointer if there is only one reference.


Member Function Documentation

template<class T>
LnPtr< T > & LnPtr< T >::operator= ( const LnPtr< T > &  rhs  )  [inline]

The copy assignment operator.

The contained pointer is set to the one wrapped by rhs. The reference count is decremented on this object and the reference count is incremented for the newly wrapped pointer.

References LnPtr< T >::ptr, LnPtr< T >::ucnt, and LnPtr< T >::unique().

template<class T>
LnPtr< T > & LnPtr< T >::operator= ( T *  rhs  )  [inline]

Sets the wrapped pointer to rhs.

Decrements the count on the previously wrapped pointer and deletes it if there was only one reference.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

References LnPtr< T >::ptr, and LnPtr< T >::unique().

template<class T>
bool LnPtr< T >::unique (  )  const [inline]

Returns true if only one reference to the wrapped pointer.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

References UseCount::unique().

Referenced by LnPtr< T >::operator=().

template<class T>
int LnPtr< T >::linkCount (  )  const [inline]

Returns the number of references to the wrapped pointer.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

References UseCount::linkCount().

template<class T>
T & LnPtr< T >::operator* (  )  const [inline]

Returns a reference to the value pointed to by the wrapped pointer; i.e.

dereferencing this LnPtr<T>, returns the dereferenced wrapped pointer. It is an error if the wrapped pointer is null.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

References BL_ASSERT, and LnPtr< T >::ptr.

template<class T>
bool LnPtr< T >::isNull (  )  const [inline]

Returns true if the wrapped pointer is null.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

References LnPtr< T >::ptr.

template<class T>
bool LnPtr< T >::operator== ( const LnPtr< T > &  rhs  )  const [inline]

Are the two pointers (not the values to which they point) equal?

References LnPtr< T >::ptr.

template<class T>
bool LnPtr< T >::operator!= ( const LnPtr< T > &  rhs  )  const [inline]

Are the two pointers not equal?

References LnPtr< T >::ptr.

template<class T>
LnPtr<T>& LnPtr< T >::operator= ( const LnPtr< T > &  rhs  ) 

The copy assignment operator.

The contained pointer is set to the one wrapped by rhs. The reference count is decremented on this object and the reference count is incremented for the newly wrapped pointer.

template<class T>
LnPtr<T>& LnPtr< T >::operator= ( T *  rhs  ) 

Sets the wrapped pointer to rhs.

Decrements the count on the previously wrapped pointer and deletes it if there was only one reference.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
bool LnPtr< T >::unique (  )  const

Returns true if only one reference to the wrapped pointer.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
int LnPtr< T >::linkCount (  )  const

Returns the number of references to the wrapped pointer.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
T& LnPtr< T >::operator* (  )  const

Returns a reference to the value pointed to by the wrapped pointer; i.e.

dereferencing this LnPtr<T>, returns the dereferenced wrapped pointer. It is an error if the wrapped pointer is null.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
bool LnPtr< T >::isNull (  )  const

Returns true if the wrapped pointer is null.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
bool LnPtr< T >::operator== ( const LnPtr< T > &  rhs  )  const

Are the two pointers (not the values to which they point) equal?

template<class T>
bool LnPtr< T >::operator!= ( const LnPtr< T > &  rhs  )  const

Are the two pointers not equal?

template<class T>
LnPtr<T>& LnPtr< T >::operator= ( const LnPtr< T > &  rhs  ) 

The copy assignment operator.

The contained pointer is set to the one wrapped by rhs. The reference count is decremented on this object and the reference count is incremented for the newly wrapped pointer.

template<class T>
LnPtr<T>& LnPtr< T >::operator= ( T *  rhs  ) 

Sets the wrapped pointer to rhs.

Decrements the count on the previously wrapped pointer and deletes it if there was only one reference.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
bool LnPtr< T >::unique (  )  const

Returns true if only one reference to the wrapped pointer.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
int LnPtr< T >::linkCount (  )  const

Returns the number of references to the wrapped pointer.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
T& LnPtr< T >::operator* (  )  const

Returns a reference to the value pointed to by the wrapped pointer; i.e.

dereferencing this LnPtr<T>, returns the dereferenced wrapped pointer. It is an error if the wrapped pointer is null.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
bool LnPtr< T >::isNull (  )  const

Returns true if the wrapped pointer is null.

Reimplemented in LnClassPtr< T >, LnClassPtr< T >, LnClassPtr< BoxArray::Ref >, and LnClassPtr< BoxArray::Ref >.

template<class T>
bool LnPtr< T >::operator== ( const LnPtr< T > &  rhs  )  const

Are the two pointers (not the values to which they point) equal?

template<class T>
bool LnPtr< T >::operator!= ( const LnPtr< T > &  rhs  )  const

Are the two pointers not equal?


Member Data Documentation

template<class T>
T* LnPtr< T >::ptr [protected]

template<class T>
T* LnPtr< T >::ptr [protected]

template<class T>
T* LnPtr< T >::ptr [protected]


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

Generated on Fri Nov 21 10:11:02 2008 for AMRParticlePaths by  doxygen 1.5.5