This is used to deduce at compile if a specific class has built-in reference counting or needs an external reference count. More...
#include <countedptr.h>
Public Types | |
enum | { IsCastable = CastStatic } |
Used to determine if the data a CountedPtr is managing can be cast. More... | |
typedef ReferenceCount< T > | RefCountType |
This is type of the ReferenceCounter, The type of the class if reference counting is instrusive. | |
Static Public Member Functions | |
static RefCountType * | ConstructionPointer (T *Target) |
This will somehow return a pointer to the reference count. More... | |
This is used to deduce at compile if a specific class has built-in reference counting or needs an external reference count.
Every class that does not implement its own reference count gets this default one. The Default reference count is not thread-safe, and requires that every dereferencing of the smart pointer has the cost of a double dereference. The double dereference is caused because the reference counter has to store a native pointer to the managed object. In benchmarks included with the Unit tests this seems to increase dereference time by about double.
Any class that provides TypePointedTo* GetReferenceCountTargetAsPointer(), Whole GetReferenceCount(), Whole IncrementReferenceCount(), Whole DecrementReferenceCount() and something* GetMostDerived() (which need to be virtual if inheritance is used to be useful) can be used as a reference counter. If it provides these then a specialization of ReferenceCountTraits should be implemented for a given class and CountedPtr will use the type defined by ReferenceCountTraits<T>::RefCountType as the counter.
The Mezzanine provides a Reference count class that can be used with any type at the cost of extra dereferences. Some types (Scripts) have their own internal reference count that when used will increase the locality (since the reference count is part of the managed object) and reduce dereferences to exactly one. Since the CountedPtr is the size of a native pointer if it is used with an internal reference count, the only signifigant overhead should be the counting itself.
Definition at line 87 of file countedptr.h.
anonymous enum |
Used to determine if the data a CountedPtr is managing can be cast.
This uses the CountedPointerCastingState to enter a value the Template MetaProgramming Machinery will understand.
Definition at line 221 of file countedptr.h.
|
inlinestatic |
This will somehow return a pointer to the reference count.
Target | A pointer the freshly created object. |
Definition at line 216 of file countedptr.h.