Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

LibGPIB::CountedPointer Class Reference

A counted pointer template. More...

#include <CountedPointer.h>

List of all members.

Public Methods

Constructors and Destructor
 CountedPointer ()
 Construct a null pointer.

 ~CountedPointer ()
 The destructor.

Public Methods
bool IsUnique () const
 Return true if this is the only object which is accessing the pointed object.

bool IsNull () const
 Return true if the current object points to a null object.

Operators
CountedPointer& operator= (const CountedPointer& other)
 Assignment operator.

PointedType& operator * () const
 Operator to access the object which is being pointed to.

PointedType* operator-> () const
 Operator to access the members of object which is being pointed to.


Static Public Methods

const CountedPointer CreateWithObject ()
 Create a new CountedPointer with an valid new heap object attached to it.


Protected Attributes

PointedType* mPointer
 The actual pointer.


Private Methods

 CountedPointer (PointedType *new_object)
 Create a new object and assigned the specified pointer to it.


Private Attributes

ReferenceCount mRefCount
 The reference count of the current object.


Friends

bool operator== (const CountedPointer<PointedType>& lhs, const CountedPointer<PointedType>& rhs)
 Operator to compare and see if two CountedPointer objects are equal.

bool operator!= (const CountedPointer<PointedType>& lhs, const CountedPointer<PointedType>& rhs)
 Operator to see if two CountedPointer objects are not equal.


Detailed Description

template<class PointedType> class LibGPIB::CountedPointer

A counted pointer template.

This class was inspired by the corresponding class in \URL["Scientific and Engineering C++"]{http://www.awl.com/cseng/cgi-bin/cdquery.pl?name=sec}.

These CountedPointer objects do not have any constructors or conversion operators which convert PointedType* to CountedPointer. Hence, these pointers cannot be used where dumb pointers are expected. The only way to connect a real object to a CountedPointer object is to use the CreateWithObject method. This ensures that the CountedPointer object is always pointing at an object on the heap.

Author(s):
$Author: pagey $ Manish P. Pagey

Version:
#$Id: CountedPointer.h,v 1.2 2000/08/04 07:03:16 pagey Exp $#

Definition at line 34 of file CountedPointer.h.


Constructor & Destructor Documentation

template<class PointedType>
LibGPIB::CountedPointer<PointedType>::CountedPointer<PointedType> ( )

Construct a null pointer.

Definition at line 173 of file CountedPointer.h.

template<class PointedType>
LibGPIB::CountedPointer<PointedType>::~CountedPointer<PointedType> ( )

The destructor.

Definition at line 178 of file CountedPointer.h.

template<class PointedType>
LibGPIB::CountedPointer<PointedType>::CountedPointer<PointedType> ( PointedType * new_object ) [private]

Create a new object and assigned the specified pointer to it.

Definition at line 185 of file CountedPointer.h.


Member Function Documentation

template<class PointedType>
const CountedPointer<PointedType> LibGPIB::CountedPointer<PointedType>::CreateWithObject ( ) [static]

Create a new CountedPointer with an valid new heap object attached to it.

Definition at line 204 of file CountedPointer.h.

template<class PointedType>
bool LibGPIB::CountedPointer<PointedType>::IsNull ( ) const

Return true if the current object points to a null object.

Definition at line 198 of file CountedPointer.h.

template<class PointedType>
bool LibGPIB::CountedPointer<PointedType>::IsUnique ( ) const

Return true if this is the only object which is accessing the pointed object.

Definition at line 192 of file CountedPointer.h.

template<class PointedType>
PointedType & LibGPIB::CountedPointer<PointedType>::operator * ( ) const

Operator to access the object which is being pointed to.

Definition at line 229 of file CountedPointer.h.

template<class PointedType>
PointedType * LibGPIB::CountedPointer<PointedType>::operator-> ( ) const

Operator to access the members of object which is being pointed to.

Definition at line 223 of file CountedPointer.h.

template<class PointedType>
CountedPointer<PointedType>& LibGPIB::CountedPointer<PointedType>::operator= ( const CountedPointer<PointedType> & other )

Assignment operator.

Definition at line 210 of file CountedPointer.h.


Friends And Related Function Documentation

template<class PointedType>
bool operator!= ( const CountedPointer<PointedType>& lhs,
const CountedPointer<PointedType>& rhs ) [friend]

Operator to see if two CountedPointer objects are not equal.

Definition at line 131 of file CountedPointer.h.

template<class PointedType>
bool operator== ( const CountedPointer<PointedType>& lhs,
const CountedPointer<PointedType>& rhs ) [friend]

Operator to compare and see if two CountedPointer objects are equal.

Definition at line 123 of file CountedPointer.h.


Member Data Documentation

template<class PointedType>
PointedType * LibGPIB::CountedPointer<PointedType>::mPointer [protected]

The actual pointer.

Definition at line 144 of file CountedPointer.h.

template<class PointedType>
ReferenceCount LibGPIB::CountedPointer<PointedType>::mRefCount [private]

The reference count of the current object.

Definition at line 159 of file CountedPointer.h.


The documentation for this class was generated from the following file:
Generated at Tue Aug 8 01:37:55 2000 for libgpib by doxygen1.1.4 written by Dimitri van Heesch, © 1997-2000