Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ref< T > Class Template Reference

Reference counting smart-pointer. More...

#include <Ref.h>

List of all members.

Public Types

typedef std::vector< Ref<
T > > 
vector
typedef std::list< Ref< T > > list

Public Methods

 Ref ()
 Create a null reference.

 Ref (T *ptr)
 Create a new reference.

 Ref (LinkBase const &r)
 Light-weight copy with reference counting.

template<typename Q>  Ref (Ref< Q > const &r)
 Light-weight copy with reference counting.

 Ref (Ref const &r)
 Light-weight copy with reference counting.

 ~Ref ()
 Decrement the reference count, and potentially destroy the referenced object.

bool unique () const
 Returns true if this is the only reference.

int count () const
 Get the number of outstanding references.

template<class Q> Ref const & operator= (Ref< Q > const &r)
 Light-weight copy with reference counting.

Ref const & operator= (Ref const &r)
 Light-weight copy with reference counting.

LinkBase const & operator= (LinkBase const &r)
 Light-weight copy with reference counting.

template<class Q> Q * operator= (Q *ptr)
 Raw pointer assignment.

void * operator= (void *ptr)
 Raw pointer assignment for assigning NULL.

T * get () const
 Dereference.

T * operator-> () const
 Dereference.

T & operator * () const
 Dereference.

bool operator! () const
 Test for null pointer.

bool valid () const
 Test for non-null pointer.

template<class Q> bool operator== (Ref< Q > const &p) const
 Comparison with other simdata pointers.

bool operator== (Referenced const *p) const
 Comparison with other simdata pointers.

template<class Q> bool operator!= (Ref< Q > const &p) const
 Comparison with other simdata pointers.

bool operator!= (Referenced const *p) const
 Comparison with other simdata pointers.


Protected Methods

template<class Q> void _rebind (Q *ptr)
 Rebind to a new object.


Protected Attributes

T * _reference
 The actual pointer.


Detailed Description

template<class T>
class Ref< T >

Reference counting smart-pointer.

Reference counting smart-pointer for use with simdata::Referenced objects.

Classes derived from Reference should be handled with Ref<T> smart pointers, or Link<T> dynamic references.

Author:
Mark Rose <mrose@stm.lbl.gov>


Member Typedef Documentation

template<class T>
typedef std::list< Ref<T> > Ref< T >::list
 

template<class T>
typedef std::vector< Ref<T> > Ref< T >::vector
 


Constructor & Destructor Documentation

template<class T>
Ref< T >::Ref   [inline]
 

Create a null reference.

template<class T>
Ref< T >::Ref T *    ptr [inline]
 

Create a new reference.

template<class T>
Ref< T >::Ref LinkBase const &    r [inline]
 

Light-weight copy with reference counting.

template<class T>
template<typename Q>
Ref< T >::Ref Ref< Q > const &    r [inline]
 

Light-weight copy with reference counting.

template<class T>
Ref< T >::Ref Ref< T > const &    r [inline]
 

Light-weight copy with reference counting.

template<class T>
Ref< T >::~Ref   [inline]
 

Decrement the reference count, and potentially destroy the referenced object.


Member Function Documentation

template<class T>
template<class Q>
void Ref< T >::_rebind Q *    ptr [inline, protected]
 

Rebind to a new object.

template<class T>
int Ref< T >::count   const [inline]
 

Get the number of outstanding references.

template<class T>
T* Ref< T >::get   const [inline]
 

Dereference.

template<class T>
T& Ref< T >::operator *   const [inline]
 

Dereference.

template<class T>
bool Ref< T >::operator!   const [inline]
 

Test for null pointer.

template<class T>
bool Ref< T >::operator!= Referenced const *    p const [inline]
 

Comparison with other simdata pointers.

template<class T>
template<class Q>
bool Ref< T >::operator!= Ref< Q > const &    p const [inline]
 

Comparison with other simdata pointers.

template<class T>
T* Ref< T >::operator->   const [inline]
 

Dereference.

template<class T>
void* Ref< T >::operator= void *    ptr [inline]
 

Raw pointer assignment for assigning NULL.

Assigning any pointer other than '0' will assert.

template<class T>
template<class Q>
Q* Ref< T >::operator= Q *    ptr [inline]
 

Raw pointer assignment.

template<class T>
LinkBase const& Ref< T >::operator= LinkBase const &    r [inline]
 

Light-weight copy with reference counting.

template<class T>
Ref const& Ref< T >::operator= Ref< T > const &    r [inline]
 

Light-weight copy with reference counting.

template<class T>
template<class Q>
Ref const& Ref< T >::operator= Ref< Q > const &    r [inline]
 

Light-weight copy with reference counting.

template<class T>
bool Ref< T >::operator== Referenced const *    p const [inline]
 

Comparison with other simdata pointers.

template<class T>
template<class Q>
bool Ref< T >::operator== Ref< Q > const &    p const [inline]
 

Comparison with other simdata pointers.

template<class T>
bool Ref< T >::unique   const [inline]
 

Returns true if this is the only reference.

template<class T>
bool Ref< T >::valid   const [inline]
 

Test for non-null pointer.


Member Data Documentation

template<class T>
T* Ref< T >::_reference [protected]
 

The actual pointer.


The documentation for this class was generated from the following file:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]