Base Framework
|
Automation pointer that counts the number of references to an object. More...
#include <base/mem/Reference.h>
Public Member Functions | |
Reference () noexcept | |
Reference (TYPE *_value) noexcept | |
Reference (const Reference ©) noexcept | |
Reference (Reference &&move) noexcept | |
template<class POLY > | |
Reference (const Reference< POLY > ©) noexcept | |
template<class POLY > | |
bool | isType () const noexcept |
template<class POLY > | |
Reference< POLY > | castChecked () const |
template<class POLY > | |
Reference< POLY > | cast () const noexcept |
Reference & | operator= (const Reference ©) |
Reference & | operator= (Reference &&move) |
template<class POLY > | |
Reference & | operator= (const Reference< POLY > &assign) |
Reference & | operator= (TYPE *assign) |
bool | operator== (NullPtr) const noexcept |
bool | operator== (const Reference &compare) const noexcept |
bool | operator!= (const Reference &compare) const noexcept |
TYPE * | getValue () const noexcept |
void | setValue (TYPE *_value) |
bool | isMultiReferenced () const noexcept |
MemorySize | getNumberOfReferences () const noexcept |
void | copyOnWrite () |
void | invalidate () |
bool | isValid () const noexcept |
TYPE & | operator* () |
const TYPE & | operator* () const |
TYPE * | operator-> () |
const TYPE * | operator-> () const |
operator bool () const noexcept | |
void | garbageCollect () |
~Reference () | |
Static Public Member Functions | |
static Reference | make () |
static void | swapper (Reference &a, Reference &b) noexcept |
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. This pointer can only be used to reference count objects of type ReferenceCountedObject but is faster than ReferenceCounter. The Reference class is relocateable.
Note that is it safe to convert this pointer back to a Reference pointer.
This is the recommended automation pointer. Only use other automation classes when needed.
void MyClass::doit() { Reference<MyClass> myObject = this; useIt(myObject); }
Initializes an automation pointer as invalid (i.e. nullptr).
Initializes an automation pointer with the specified pointer value. The automation pointer may be implicitly initialized.
value | The desired pointer value. |
Initialization of automation pointer from other automation pointer.
Move initialization of automation pointer from other automation pointer.
|
inlinenoexcept |
Initialization of automation pointer from other automation pointer using compile time polymorphism.
|
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.
|
inline |
Garbage collects object. Object will be set to nullptr.
|
inlinenoexcept |
Returns the number of references. Returns 0 if pointer is nullptr.
|
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.
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).
Returns a new object by using default construction.
|
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.
|
inline |
Returns the reference counted object.
|
inline |
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.
Assignment of automation pointer to this automation pointer.
Assignment of normal pointer to this automation pointer.
|
inlinenoexcept |
Returns true if the references are equal.
|
inlinenoexcept |
Returns true if the reference is nullptr.
|
inline |
Sets the pointer value of this automation pointer.