GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

GFC::Pointer< T > Class Template Reference

Smart pointer template class. More...

#include <gfc/pointer.hh>

List of all members.

Public Member Functions

Constructors
Accessors
Methods

Detailed Description

template<typename T>
class GFC::Pointer< T >

Smart pointer template class.

Pointer is a standard auto_ptr-like smart pointer for managing heap allocated reference counted objects. T must be a class derived from GFC::G::Object or GFC::ReferencedObject.


Constructor & Destructor Documentation

template<typename T>
GFC::Pointer< T >::Pointer T *  object = 0  )  [inline]
 

Construct a new smart pointer.

Parameters:
object A pointer to an object allocated on the heap.

Initialize a new Pointer with any dumb pointer.

template<typename T>
GFC::Pointer< T >::Pointer Pointer< T > &  src  )  [inline]
 

Copy constructor.

Parameters:
src A reference to a smart pointer.

Initialize a new Pointer with any compatible Pointer.

template<typename T>
template<typename T1>
GFC::Pointer< T >::Pointer const Pointer< T1 > &  src  )  [inline]
 

Copy constructor.

Parameters:
src A Pointer to type T1 where T1 is derived from T.

Initialize a new Pointer of type T from a Pointer of type T1, only if T1 is derived from T.

template<typename T>
GFC::Pointer< T >::~Pointer  )  [inline]
 

Destructor.

Decreases the object reference count.


Member Function Documentation

template<typename T>
T* GFC::Pointer< T >::get  )  const [inline]
 

Returns the dumb pointer; the regular C pointer managed by the Pointer.

Returns:
The dumb pointer.

template<typename T>
T& GFC::Pointer< T >::operator *  )  const [inline]
 

Dereference operator.

Returns:
A reference to the object pointed to by the dumb pointer.

template<typename T>
GFC::Pointer< T >::operator T *  )  const [inline]
 

Conversion operator.

Converts a Pointer into its dumb pointer: the C pointer it manages. Normally it is considered pretty evil to mix smart and regular pointers. In GFC you can safely if you just follow the reference counting rules for each of them. You can never call delete on Pointer either because you don't call delete on GFC objects; you call unref().

template<typename T>
template<typename T1>
bool GFC::Pointer< T >::operator!= const Pointer< T1 > &  other  )  [inline]
 

Compares the dumb pointer with other's dumb pointer, for inequality.

Parameters:
other Another smart pointer.
Returns:
true if both Pointers manage a different dumb pointer.

template<typename T>
T* GFC::Pointer< T >::operator->  )  const [inline]
 

Member selection operator.

Returns:
The dumb pointer.

template<typename T>
template<typename T1>
Pointer& GFC::Pointer< T >::operator= const Pointer< T1 > &  src  )  [inline]
 

Assignment operator.

Parameters:
src A Pointer to type T1 where T1 is derived from T.

Releases the current dumb pointer, if any and assigns the dumb pointer of type T1 managed by src to this Pointer as a dumb pointer of type T, only if T1 is derived from T. The reference count is incremented.

template<typename T>
Pointer& GFC::Pointer< T >::operator= const Pointer< T > &  src  )  [inline]
 

Assignment operator.

Parameters:
src A reference to a smart pointer.

Releases the current dumb pointer, if any and assigns the dumb pointer managed by src to this Pointer, incrementing its reference count.

template<typename T>
Pointer& GFC::Pointer< T >::operator= T *  object  )  [inline]
 

Assignment operator.

Parameters:
object A pointer to an object allocated on the heap.

Releases the current dumb pointer, if any and assigns object to this Pointer, incrementing its reference count.

template<typename T>
template<typename T1>
bool GFC::Pointer< T >::operator== const Pointer< T1 > &  other  )  [inline]
 

Compares the dumb pointer with other's dumb pointer, for equality.

Parameters:
other Another smart pointer.
Returns:
true if both Pointers manage to same dumb pointer.

template<typename T>
T* GFC::Pointer< T >::release  )  [inline]
 

Releases the dumb pointer.

Returns:
The regular C pointer previously managed by the Pointer.

Before releasing the dumb pointer its reference count is incremented to prevent it being destroyed. You must call unref() on the pointer to prevent a memory leak.

template<typename T>
void GFC::Pointer< T >::reset T *  object = 0  )  [inline]
 

Sets a new dumb pointer for the Pointer to manage.

Parameters:
object The new dumb pointer.

Releases the current dumb pointer, if any, and assigns object to the Pointer, incrementing its reference count.


The documentation for this class was generated from the following file:
Generated on Tue Aug 24 00:04:57 2004 for GFC-Core by doxygen 1.3.8