CpPtr< T > Class Template Reference

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

#include <Pointers.H>

Inheritance diagram for CpPtr< T >:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CpPtr ()
 The default constructor. The wrapped pointer is null.
 CpPtr (T *rhs)
 Construct a CpPtr<T> setting the wrapped pointer to rhs.
 ~CpPtr ()
 The destructor. Deletes the wrapped pointer.
 CpPtr (const CpPtr< T > &rhs)
 The copy constructor.
CpPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
CpPtr< T > & operator= (const CpPtr< T > &rhs)
 The copy assignment operator.
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 null.
T * release ()
 Sets the wrapped pointer to null and returns the previous value.
bool operator== (const CpPtr< T > &rhs) const
 Are the two pointers (not the values to which they point) equal?
bool operator!= (const CpPtr< T > &rhs) const
 Are the two pointers not equal?
 CpPtr ()
 The default constructor. The wrapped pointer is null.
 CpPtr (T *rhs)
 Construct a CpPtr<T> setting the wrapped pointer to rhs.
 ~CpPtr ()
 The destructor. Deletes the wrapped pointer.
 CpPtr (const CpPtr< T > &rhs)
 The copy constructor.
CpPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
CpPtr< T > & operator= (const CpPtr< T > &rhs)
 The copy assignment operator.
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 null.
T * release ()
 Sets the wrapped pointer to null and returns the previous value.
bool operator== (const CpPtr< T > &rhs) const
 Are the two pointers (not the values to which they point) equal?
bool operator!= (const CpPtr< T > &rhs) const
 Are the two pointers not equal?
 CpPtr ()
 The default constructor. The wrapped pointer is null.
 CpPtr (T *rhs)
 Construct a CpPtr<T> setting the wrapped pointer to rhs.
 ~CpPtr ()
 The destructor. Deletes the wrapped pointer.
 CpPtr (const CpPtr< T > &rhs)
 The copy constructor.
CpPtr< T > & operator= (T *rhs)
 Sets the wrapped pointer to rhs.
CpPtr< T > & operator= (const CpPtr< T > &rhs)
 The copy assignment operator.
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 null.
T * release ()
 Sets the wrapped pointer to null and returns the previous value.
bool operator== (const CpPtr< T > &rhs) const
 Are the two pointers (not the values to which they point) equal?
bool operator!= (const CpPtr< T > &rhs) const
 Are the two pointers not equal?

Protected Attributes

T * ptr
T * ptr
T * ptr


Detailed Description

template<class T>
class CpPtr< T >

: A Smart Pointer for Intrinsic or User-Defined Types

The template class CpPtr<T> provides a simple wrapper around a pointer to type T (T*) that builds a copy of the pointed-to object when copied from one CpPtr<T> to another. This is in contrast to a reference-counted pointer class that would maintain one pointed-to object with a reference count indicating the number of references. Hence we call this a "copied" smart pointer class. It is intended for use with any type type T, including the intrinsic types. This class does 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>
CpPtr< T >::CpPtr (  )  [inline]

The default constructor. The wrapped pointer is null.

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

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

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

The destructor. Deletes the wrapped pointer.

References CpPtr< T >::ptr.

template<class T>
CpPtr< T >::CpPtr ( const CpPtr< T > &  rhs  )  [inline]

The copy constructor.

If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

References CpPtr< T >::isNull(), and CpPtr< T >::ptr.

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

The default constructor. The wrapped pointer is null.

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

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

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

The destructor. Deletes the wrapped pointer.

template<class T>
CpPtr< T >::CpPtr ( const CpPtr< T > &  rhs  ) 

The copy constructor.

If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

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

The default constructor. The wrapped pointer is null.

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

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

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

The destructor. Deletes the wrapped pointer.

template<class T>
CpPtr< T >::CpPtr ( const CpPtr< T > &  rhs  ) 

The copy constructor.

If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.


Member Function Documentation

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

Sets the wrapped pointer to rhs.

Deletes the previously wrapped pointer.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

References CpPtr< T >::ptr.

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

The copy assignment operator.

If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

References CpPtr< T >::isNull(), and CpPtr< T >::ptr.

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

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

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

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

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

Returns true if the wrapped pointer null.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

References CpPtr< T >::ptr.

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

template<class T>
T * CpPtr< T >::release (  )  [inline]

Sets the wrapped pointer to null and returns the previous value.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

References CpPtr< T >::ptr.

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

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

References CpPtr< T >::ptr.

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

Are the two pointers not equal?

References CpPtr< T >::ptr.

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

Sets the wrapped pointer to rhs.

Deletes the previously wrapped pointer.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

The copy assignment operator.

If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

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

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

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

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

Returns true if the wrapped pointer null.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

template<class T>
T* CpPtr< T >::release (  ) 

Sets the wrapped pointer to null and returns the previous value.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

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

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

Are the two pointers not equal?

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

Sets the wrapped pointer to rhs.

Deletes the previously wrapped pointer.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

The copy assignment operator.

If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

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

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

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

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

Returns true if the wrapped pointer null.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

template<class T>
T* CpPtr< T >::release (  ) 

Sets the wrapped pointer to null and returns the previous value.

Reimplemented in CpClassPtr< T >, CpClassPtr< T >, CpClassPtr< RealDescriptor >, and CpClassPtr< RealDescriptor >.

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

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

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

Are the two pointers not equal?


Member Data Documentation

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

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

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


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

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