aegis_shared_ptr< T > Class Template Reference

#include <aegis.h>


Public Member Functions

bool valid () const
 ~aegis_shared_ptr ()
void swap (aegis_shared_ptr &rhs)
void reset ()
 aegis_shared_ptr ()
template<class Y>
 aegis_shared_ptr (Y *rhs)
 aegis_shared_ptr (const aegis_shared_ptr &rhs)
template<class Y>
 aegis_shared_ptr (const aegis_shared_ptr< Y > &rhs)
aegis_shared_ptroperator= (const aegis_shared_ptr &rhs)
template<class Y>
aegis_shared_ptroperator= (const aegis_shared_ptr< Y > &rhs)
T & operator* () const
T * operator-> () const
T * get () const
 operator bool () const
bool operator! () const
bool operator== (const aegis_shared_ptr &rhs) const
template<class U>
bool operator== (const aegis_shared_ptr< U > &rhs) const
bool operator!= (aegis_shared_ptr &rhs) const
template<class U>
bool operator!= (aegis_shared_ptr< U > &rhs) const
bool operator< (aegis_shared_ptr &rhs) const
template<class U>
bool operator< (aegis_shared_ptr< U > &rhs) const

Private Attributes

long * reference_count
T * subject

Friends

class aegis_shared_ptr


Detailed Description

template<class T>
class aegis_shared_ptr< T >

The aegis_shared_ptr class is used to represent a smart pointer with reference counted copy semantics. The object pointed to is deleted when the last aegis_shared_ptr pointing to it is destroyed or reset.

This class is only used of std::tr1::shared_ptr and boost::shared_ptr are both unavailable. It only implements as much of a shared_ptr as the Aegis code actually uses.

Definition at line 36 of file aegis.h.


Constructor & Destructor Documentation

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

The destructor.

This destructor is not virtual. Thou shalt not derive from this class.

Definition at line 85 of file aegis.h.

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

The default constructor.

Definition at line 134 of file aegis.h.

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

The constructor. It permits initialization from any compatable pointer. Y must be a complete type.

Parameters:
rhs The object pointed to, the object to be managed.

Definition at line 149 of file aegis.h.

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

The copy constructor.

Parameters:
rhs The smart pointer to be copied.

Definition at line 168 of file aegis.h.

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

The compatible copy constructor.

Parameters:
rhs The compatable smart pointer to be copied.

Definition at line 192 of file aegis.h.


Member Function Documentation

template<class T>
bool aegis_shared_ptr< T >::valid (  )  const [inline]

The valid method is used to establish the correctness of the internal state. Think of it as the contract.

Definition at line 65 of file aegis.h.

template<class T>
void aegis_shared_ptr< T >::swap ( aegis_shared_ptr< T > &  rhs  )  [inline]

Swap the contents of two aegis_shared_ptr<T> objects. This method swaps the internal pointers to T. This can be done safely without involving a reference / unreference cycle and is therefore highly efficient.

Definition at line 108 of file aegis.h.

template<class T>
void aegis_shared_ptr< T >::reset (  )  [inline]

The reset method is used to drop the reference, if there is one.

Definition at line 124 of file aegis.h.

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

The assignment operator.

Parameters:
rhs The right hand side of the assigment, the pointer to copy.

Definition at line 214 of file aegis.h.

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

The assignment operator.

Parameters:
rhs The right hand side of the assigment, the pointer to copy.

Definition at line 264 of file aegis.h.

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

The dereference operator. Return a reference to the object, not to the smart pointer.

This is part of why it's called a "smart pointer" when it's actually neither - it *acts* like a pointer.

Definition at line 330 of file aegis.h.

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

The "pointing at" operator. Return a pointer to the object, not to the smart pointer.

This is part of why it's called a "smart pointer" when it's actually neither - it *acts* like a pointer.

Definition at line 345 of file aegis.h.

template<class T>
T* aegis_shared_ptr< T >::get (  )  const [inline]

The get method is used to obtain the pointer to the object.

Definition at line 356 of file aegis.h.

template<class T>
aegis_shared_ptr< T >::operator bool (  )  const [inline]

The bool operator, for implicit conversion to bool. Test of the pointers not NULL.

Definition at line 366 of file aegis.h.

template<class T>
bool aegis_shared_ptr< T >::operator! (  )  const [inline]

The logical not operator. Test if the pointer is NULL.

Definition at line 377 of file aegis.h.

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

Definition at line 384 of file aegis.h.

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

Definition at line 392 of file aegis.h.

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

Definition at line 399 of file aegis.h.

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

Definition at line 407 of file aegis.h.

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

Definition at line 414 of file aegis.h.

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

Definition at line 422 of file aegis.h.


Friends And Related Function Documentation

template<class T>
friend class aegis_shared_ptr [friend]

Definition at line 183 of file aegis.h.


Field Documentation

template<class T>
long* aegis_shared_ptr< T >::reference_count [private]

The reference_count instance variable is used to remember the location of the reference count. By having the reference count separate from the subject, we can cope with compatible pointers, not just exact pointers.

This is not ideal because it allocates huge numbers of small objects. Some heap implementations go slowly when faced with many small allocations. Some heap implementations waste a lot of memory when faced with many small allocations.

Definition at line 50 of file aegis.h.

template<class T>
T* aegis_shared_ptr< T >::subject [private]

The subject instance variable is used to remember the location of the object being reference counted. By having it separate from the reference count, we can skip one indirection.

Definition at line 57 of file aegis.h.


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

Generated on Wed Mar 12 23:37:39 2008 for Aegis by  doxygen 1.5.5