#include <scim_pointer.h>
Collaboration diagram for scim::Pointer< T >:
Public Member Functions | |
Constructors | |
Pointer (T *object=0) | |
Pointer (Pointer &src) | |
template<typename T1> | |
Pointer (const Pointer< T1 > &src) | |
~Pointer () | |
Pointer & | operator= (T *object) |
Pointer & | operator= (const Pointer &src) |
template<typename T1> | |
Pointer & | operator= (const Pointer< T1 > &src) |
Accessors | |
T & | operator * () const |
T * | operator-> () const |
operator T * () const | |
T * | get () const |
bool | null () const |
Returns true if the Pointer has no dumb pointer. | |
Methods | |
T * | release () |
void | reset (T *object=0) |
Friends | |
template<typename T1, typename T2> | |
bool | operator== (const Pointer< T1 > &t1, const Pointer< T2 > &t2) |
Pointer is a standard auto_ptr-like smart pointer for managing heap allocated reference counted objects. T must be a class derived from scim::ReferencedObject.
|
Construct a new smart pointer.
Initialize a new Pointer with any dumb pointer. |
|
Copy constructor.
Initialize a new Pointer with any compatible Pointer. |
|
Copy constructor.
Initialize a new Pointer of type T from a Pointer of type T1, only if T1 is derived from T. |
|
Destructor. Decreases the object reference count. |
|
Assignment operator.
Releases the current dumb pointer, if any and assigns object to this Pointer, incrementing its reference count. |
|
Assignment operator.
Releases the current dumb pointer, if any and assigns the dumb pointer managed by src to this Pointer, incrementing its reference count. |
|
Assignment operator.
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. |
|
Dereference operator.
|
|
Member selection operator.
|
|
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 scim 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 scim objects; you call unref(). |
|
Returns the dumb pointer; the regular C pointer managed by the Pointer.
|
|
Returns true if the Pointer has no dumb pointer.
|
|
Releases the dumb 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. |
|
Sets a new dumb pointer for the Pointer to manage.
Releases the current dumb pointer, if any, and assigns object to the Pointer, incrementing its reference count. |
|
Compares two Pointers.
|