#include <CountedPointer.h>
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. |
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.
Definition at line 34 of file CountedPointer.h.
|
|
|
Create a new object and assigned the specified pointer to it.
Definition at line 185 of file CountedPointer.h.
|
Create a new CountedPointer with an valid new heap object attached to it.
Definition at line 204 of file CountedPointer.h.
|
Return true if the current object points to a null object.
Definition at line 198 of file CountedPointer.h.
|
Return true if this is the only object which is accessing the pointed object.
Definition at line 192 of file CountedPointer.h.
|
Operator to access the object which is being pointed to.
Definition at line 229 of file CountedPointer.h.
|
Operator to access the members of object which is being pointed to.
Definition at line 223 of file CountedPointer.h.
|
|
Operator to see if two CountedPointer objects are not equal.
Definition at line 131 of file CountedPointer.h.
|
Operator to compare and see if two CountedPointer objects are equal.
Definition at line 123 of file CountedPointer.h.
|
|