#include <LeapUtil.h>
Classes | |
struct | ManagedPointerEntry |
struct | ManagedPointerPool |
Public Types | |
enum | { kManagedPointerPoolSize = ManagedPointerPoolSize } |
typedef T | ManagedType |
Public Member Functions | |
ManagedType * | GetPointer () const |
uint32_t | GetRefCount () const |
how many references are there to this managed pointer? More... | |
operator bool () const | |
boolean and comparison operator overloads More... | |
operator ManagedType * () const | |
operators for easy implicit assignment to raw pointer type or direct use of the object pointer More... | |
bool | operator! () const |
bool | operator!= (const ManagedType *pPointer) const |
bool | operator!= (const SmartPointer &rhs) const |
ManagedType * | operator-> () const |
const SmartPointer & | operator= (const SmartPointer &rhs) |
bool | operator== (const ManagedType *pPointer) const |
bool | operator== (const SmartPointer &rhs) const |
void | Release () |
SmartPointer () | |
default constructor - equivalent of a NULL pointer. More... | |
SmartPointer (ManagedType *pManaged) | |
SmartPointer (const SmartPointer &rhs) | |
copy constructor. increases reference count for shared managed pointer entry More... | |
~SmartPointer () | |
destructor decreases reference count for managed pointer entry. More... | |
Static Public Member Functions | |
static uint32_t | GetNumManagedPointers () |
static bool | IsManaged (const ManagedType *pPointer) |
returns true if the given raw pointer is managed by a smart pointer somewhere, false if not. More... | |
static const SmartPointer & | Null () |
convenient static method for returning in cases where a null return value is needed. More... | |
Private Member Functions | |
void | refDec () |
void | refInc () |
increment the reference count on our shared managed pointer entry (if any) More... | |
Static Private Member Functions | |
static ManagedPointerPool & | s_pool () |
Private Attributes | |
ManagedPointerEntry * | m_pManagedPointer |
smart pointer template class. maintains reference count that is incremented for each new instance of a smart pointer that refers to the same raw pointer and decremented each time a reference is released. a reference is released when a smart pointer goes out of scope OR has another value assigned to it OR .Release() is called explicitly. when the reference count reaches zero the Destructor::Destroy static method is invoked on the raw pointer. note: this smart pointer class is not thread-safe. making it thread safe would have required adding a cross-platform mutex class. the use cases in the sample code do not require it.
Definition at line 627 of file LeapUtil.h.
typedef T LeapUtil::SmartPointer< T, Destructor, ManagedPointerPoolSize >::ManagedType |
Definition at line 632 of file LeapUtil.h.
anonymous enum |
Enumerator | |
---|---|
kManagedPointerPoolSize |
Definition at line 630 of file LeapUtil.h.
|
inline |
default constructor - equivalent of a NULL pointer.
Definition at line 806 of file LeapUtil.h.
|
inlineexplicit |
construction of a smart pointer from a raw pointer is not implicit - they should be created once at the beginning of an object's life and passed around/dereferenced. creating a new smart pointer from a raw pointer should not happen unintentionally. assignment operator for raw pointer type does not exist for the same reason that the raw pointer constructor is explicit. creation of a smart pointer from a raw pointer should be deliberate.
Definition at line 816 of file LeapUtil.h.
|
inline |
copy constructor. increases reference count for shared managed pointer entry
Definition at line 822 of file LeapUtil.h.
|
inline |
destructor decreases reference count for managed pointer entry.
Definition at line 843 of file LeapUtil.h.
|
inlinestatic |
returns the number of raw pointers of this type under management. use SmartPointer::kManagedPointerPoolSize to get the total number of pointers of this type that can be managed.
Definition at line 896 of file LeapUtil.h.
|
inline |
explicit access to the managed pointer. usually the overloaded cast and -> operators are sufficient but it is sometimes useful to have a named method to call.
Definition at line 850 of file LeapUtil.h.
|
inline |
how many references are there to this managed pointer?
Definition at line 853 of file LeapUtil.h.
|
inlinestatic |
returns true if the given raw pointer is managed by a smart pointer somewhere, false if not.
Definition at line 889 of file LeapUtil.h.
|
inlinestatic |
convenient static method for returning in cases where a null return value is needed.
Definition at line 882 of file LeapUtil.h.
|
inline |
boolean and comparison operator overloads
Definition at line 861 of file LeapUtil.h.
|
inline |
operators for easy implicit assignment to raw pointer type or direct use of the object pointer
Definition at line 856 of file LeapUtil.h.
|
inline |
Definition at line 863 of file LeapUtil.h.
|
inline |
Definition at line 867 of file LeapUtil.h.
|
inline |
Definition at line 871 of file LeapUtil.h.
|
inline |
Definition at line 858 of file LeapUtil.h.
|
inline |
assignment operator overload for smart pointer to smart pointer. releases old managed entry and increases reference count for new one.
Definition at line 830 of file LeapUtil.h.
|
inline |
Definition at line 865 of file LeapUtil.h.
|
inline |
Definition at line 869 of file LeapUtil.h.
|
inlineprivate |
decrement the reference count on our shared managed pointer entry (if any) if the reference count hits 0 the raw pointer is passed to Destructor::Destroy and the managed pointer entry is returned to the pool.
Definition at line 785 of file LeapUtil.h.
|
inlineprivate |
increment the reference count on our shared managed pointer entry (if any)
Definition at line 774 of file LeapUtil.h.
|
inline |
calling Release is an alternative to assigning SmartPointer::Null(). refDec() is called in the destructor of the smart pointer - it is not necessary to call Release() in the destructor of a class containing a smart pointer.
Definition at line 876 of file LeapUtil.h.
|
inlinestaticprivate |
Definition at line 767 of file LeapUtil.h.
|
private |
Definition at line 899 of file LeapUtil.h.