Stores a pointer to an object with refcount. More...
#include <klfutil.h>
Public Types | |
typedef T * | Pointer |
Public Member Functions | |
KLFRefPtr () | |
KLFRefPtr (const KLFRefPtr ©) | |
~KLFRefPtr () | |
T * | ptr () |
const T * | ptr () const |
bool | autoDelete () const |
void | setAutoDelete (bool on) |
void | setPointer (Pointer newptr) |
void | setNull () |
KLFRefPtr< T > & | operator= (const KLFRefPtr< T > &other) |
template<class OtherPtr > | |
KLFRefPtr< T > & | operator= (OtherPtr aptr) |
KLFRefPtr< T > & | operator= (Pointer newptr) |
operator T* () | |
operator const T * () const | |
T * | operator() () |
const T * | operator() () const |
Pointer | operator-> () |
Pointer | operator-> () const |
template<class OtherPtr > | |
OtherPtr | dyn_cast () |
template<class OtherPtr > | |
const OtherPtr | dyn_cast () const |
bool | operator== (void *otherptr) const |
bool | operator== (const KLFRefPtr< T > &otherptr) const |
bool | operator!= (void *otherptr) const |
bool | operator!= (const KLFRefPtr< T > &otherptr) const |
Stores a pointer to an object with refcount.
This class provides a normal datatype (with default constructor, copy constructor, assignment, ...) that stores a pointer to a structure that provides the functions ref() and deref() to track reference counts.
When this object is copied, or a pointer is assigned, then the pointed object's ref() function is called. When another pointer is assigned, or when this object is destroyed, then the function deref() is called on the previously pointed object, and the object is possibly delete'd
if needed and required.
Automatic object deletion upon zero refcount is optional, see autoDelete() and setAutoDelete(). It is on by default.
When constructed with the default constructor, pointers are initialized to NULL.
The copy constructor and the assignment operator also preserves autodelete setting, eg.
The pointed/referenced object must:
int
, is strictly positive as long as the object is still referenced.Example:
T* KLFRefPtr< T >::Pointer |
|
inline |
Definition at line 619 of file klfutil.h.
References KLF_DEBUG_BLOCK.
|
inline |
Definition at line 624 of file klfutil.h.
References KLF_DEBUG_BLOCK.
Definition at line 630 of file klfutil.h.
References KLF_DEBUG_BLOCK.
|
inline |
Definition at line 717 of file klfutil.h.
Referenced by KLFPosSearchable::Pos::data().
|
inline |
|
inline |
Definition at line 731 of file klfutil.h.
References KLFRefPtr< T >::operator==().
|
inline |
Definition at line 728 of file klfutil.h.
References KLFRefPtr< T >::operator==().
|
inline |
|
inline |
|
inline |
Definition at line 656 of file klfutil.h.
References KLF_DEBUG_BLOCK, and KLFRefPtr< T >::setPointer().
|
inline |
Definition at line 663 of file klfutil.h.
References KLF_DEBUG_BLOCK, and KLFRefPtr< T >::setPointer().
Definition at line 670 of file klfutil.h.
References KLF_DEBUG_BLOCK, and KLFRefPtr< T >::setPointer().
|
inline |
Definition at line 722 of file klfutil.h.
Referenced by KLFRefPtr< T >::operator!=(), and KLFRefPtr< T >::operator!=().
|
inline |
|
inline |
|
inline |
Definition at line 651 of file klfutil.h.
References KLFRefPtr< T >::setPointer().
Referenced by KLFSyncGuardPtr< T >::reset().
Definition at line 642 of file klfutil.h.
References klfDbg.
Referenced by KLFRefPtr< T >::operator=(), KLFRefPtr< T >::operator=(), KLFRefPtr< T >::operator=(), and KLFRefPtr< T >::setNull().