LnClassPtr< T > Class Template Reference

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

#include <Pointers.H>

Inheritance diagram for LnClassPtr< T >:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 LnClassPtr ()
 The default constructor. The wrapped pointer is null.
 LnClassPtr (T *rhs)
 Construct a LnPtr<T> setting the wrapped pointer to rhs.
LnClassPtr< T > & operator= (const LnClassPtr< T > &rhs)
 The copy assignment operator.
LnClassPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
 ~LnClassPtr ()
 Applies operator-> to the wrapped pointer.
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 LnClassPtr< T > &rhs) const
bool operator!= (const LnClassPtr< T > &rhs) const
T * operator-> () const
 LnClassPtr ()
 The default constructor. The wrapped pointer is null.
 LnClassPtr (T *rhs)
 Construct a LnPtr<T> setting the wrapped pointer to rhs.
LnClassPtr< T > & operator= (const LnClassPtr< T > &rhs)
 The copy assignment operator.
LnClassPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
 ~LnClassPtr ()
 Applies operator-> to the wrapped pointer.
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 LnClassPtr< T > &rhs) const
bool operator!= (const LnClassPtr< T > &rhs) const
T * operator-> () const
 LnClassPtr ()
 The default constructor. The wrapped pointer is null.
 LnClassPtr (T *rhs)
 Construct a LnPtr<T> setting the wrapped pointer to rhs.
LnClassPtr< T > & operator= (const LnClassPtr< T > &rhs)
 The copy assignment operator.
LnClassPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
T * operator-> () const
 Applies operator-> to the wrapped pointer.
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


Detailed Description

template<class T>
class LnClassPtr< T >

: A Smart Reference Counted Pointer for User-Defined Types

The template class LnClassPtr<T> is derived from LnPtr<T>. It provides a reference counted wrapper around a pointer to type T (a T*). The type T MUST be a user-defined type, not an intrinsic type. Given this restriction, we can supply an operator->().


Constructor & Destructor Documentation

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

The default constructor. The wrapped pointer is null.

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

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

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

Applies operator-> to the wrapped pointer.

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

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

The default constructor. The wrapped pointer is null.

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

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

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

Applies operator-> to the wrapped pointer.

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

The default constructor. The wrapped pointer is null.

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

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


Member Function Documentation

template<class T>
LnClassPtr< T > & LnClassPtr< T >::operator= ( const LnClassPtr< 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 LnClassPtr< T >::ptr, LnClassPtr< T >::ucnt, and LnClassPtr< T >::unique().

template<class T>
LnClassPtr< T > & LnClassPtr< 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 from LnPtr< T >.

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

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

Returns true if only one reference to the wrapped pointer.

Reimplemented from LnPtr< T >.

References UseCount::unique().

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

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

Returns the number of references to the wrapped pointer.

Reimplemented from LnPtr< T >.

References UseCount::linkCount().

template<class T>
T & LnClassPtr< 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 from LnPtr< T >.

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

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

Returns true if the wrapped pointer is null.

Reimplemented from LnPtr< T >.

References LnClassPtr< T >::ptr.

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

References LnClassPtr< T >::ptr.

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

References LnClassPtr< T >::ptr.

template<class T>
T * LnClassPtr< T >::operator-> (  )  const [inline]

References LnClassPtr< T >::ptr.

template<class T>
LnClassPtr<T>& LnClassPtr< T >::operator= ( const LnClassPtr< 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>
LnClassPtr<T>& LnClassPtr< 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 from LnPtr< T >.

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

Returns true if only one reference to the wrapped pointer.

Reimplemented from LnPtr< T >.

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

Returns the number of references to the wrapped pointer.

Reimplemented from LnPtr< T >.

template<class T>
T& LnClassPtr< 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 from LnPtr< T >.

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

Returns true if the wrapped pointer is null.

Reimplemented from LnPtr< T >.

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

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

template<class T>
T* LnClassPtr< T >::operator-> (  )  const

template<class T>
LnClassPtr<T>& LnClassPtr< T >::operator= ( const LnClassPtr< 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>
LnClassPtr<T>& LnClassPtr< 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 from LnPtr< T >.

template<class T>
T* LnClassPtr< T >::operator-> (  )  const

Applies operator-> to the wrapped pointer.

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

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, inherited]

Are the two pointers not equal?

References LnPtr< T >::ptr.


Member Data Documentation

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

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

Reimplemented from LnPtr< T >.


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