Base Framework
|
Automation pointer that counts the number of references to an object. More...
#include <base/mem/ReferenceCounter.h>
Public Types | |
typedef PreferredAtomicCounter | Counter |
Public Member Functions | |
ReferenceCounter () noexcept | |
ReferenceCounter (TYPE *_value) noexcept | |
ReferenceCounter (TYPE *_value, Counter *_references) noexcept | |
ReferenceCounter (const ReferenceCounter ©) noexcept | |
ReferenceCounter (ReferenceCounter &&move) noexcept | |
template<class POLY > | |
ReferenceCounter (const ReferenceCounter< POLY > ©) noexcept | |
template<class POLY > | |
ReferenceCounter (ReferenceCounter< POLY > &&move) noexcept | |
template<class POLY > | |
bool | isType () const noexcept |
template<class POLY > | |
ReferenceCounter< POLY > | castChecked () const |
template<class POLY > | |
ReferenceCounter< POLY > | cast () const noexcept |
ReferenceCounter & | operator= (const ReferenceCounter &assign) |
template<class POLY > | |
ReferenceCounter & | operator= (const ReferenceCounter< POLY > &assign) |
ReferenceCounter & | operator= (TYPE *assign) |
bool | operator== (const ReferenceCounter &compare) const noexcept |
bool | operator!= (const ReferenceCounter &compare) const noexcept |
TYPE * | getValue () const noexcept |
Counter * | getReferences () const noexcept |
bool | isMultiReferenced () const noexcept |
MemorySize | getNumberOfReferences () const noexcept |
void | copyOnWrite () |
void | invalidate () |
bool | isValid () const noexcept |
TYPE & | operator* () |
const TYPE & | operator* () const |
TYPE * | operator-> () noexcept |
const TYPE * | operator-> () const noexcept |
operator bool () const noexcept | |
~ReferenceCounter () | |
Automation pointer that counts the number of references to an object.
Automation pointer for reference counting objects. This class is responsible for counting the total number of references to an object. The pointer automatically deletes a reference counted object when the number of references reaches zero. If possible, you should use the CombinedReferenceCounter in preference to this class. ReferenceCounter is a bit slower than CombinedReferenceCounter but works for any class being reference counted. The ReferenceCounter class is relocateable.
typedef PreferredAtomicCounter ReferenceCounter< TYPE >::Counter |
The type of the reference counter.
|
inlinenoexcept |
Initializes an automation pointer as invalid (i.e. nullptr).
|
inlinenoexcept |
Initializes an automation pointer with the specified pointer value. The automation pointer may be implicitly initialized.
value | The desired pointer value. |
|
inlinenoexcept |
Initializes an automation pointer with the specified pointer value.
value | The desired pointer value. |
references | The reference counter. |
|
inlinenoexcept |
Initialization of automation pointer from other automation pointer.
|
inlinenoexcept |
Move initialization of automation pointer from other automation pointer.
|
inlinenoexcept |
Initialization of automation pointer from other automation pointer using compile time polymorphism.
|
inlinenoexcept |
Move initialization of automation pointer from other automation pointer using compile time polymorphism.
|
inline |
Destroys the automation pointer.
|
inlinenoexcept |
Dynamic cast to the specified type.
|
inline |
Dynamic cast to the specified type. Raises CastException if the reference is invalid or the reference cannot be cast to the specified type.
|
inline |
Makes a new copy of the reference counted object if referenced by more than one automation pointer. This member function is invocated by some classes before a object is modified. The reference counted object must implement the default copy constructor for this to work.
|
inlinenoexcept |
Returns the number of references. Returns 0 if pointer is nullptr.
|
inlinenoexcept |
Returns the reference counter. Do NOT modify.
|
inlinenoexcept |
Returns the pointer value of this automation pointer. Be careful when utilizing this member function. Its completely up to you to ensure that the reference counting rules aren't violated. Invocation of this method should be avoided.
|
inline |
Invalidates the reference.
|
inlinenoexcept |
Returns true if the reference counted object is referenced by more than one automation pointer.
|
inlinenoexcept |
Returns true if the object may be cast to the specified type.
|
inlinenoexcept |
Returns true if the automation pointer is valid (i.e. it is pointing to an object).
|
inlinenoexcept |
Returns true if the automation pointer is valid (i.e. it is pointing to an object).
|
inlinenoexcept |
Returns true if the references are non-equal.
|
inline |
Returns the reference counted object.
|
inline |
Returns the reference counted object.
|
inlinenoexcept |
Returns the reference counted object.
|
inlinenoexcept |
Returns the reference counted object.
|
inline |
Assignment of automation pointer to this automation pointer.
|
inline |
Assignment of automation pointer to this automation pointer using compile time polymorphism.
|
inline |
Assignment of normal pointer to this automation pointer.
|
inlinenoexcept |
Returns true if the references are equal.