Orxonox
0.0.5 Codename: Arcturus
|
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/CorePrereqs.h>
Public Member Functions | |
WeakPtr () | |
Constructor: Initializes the weak pointer with a null pointer. More... | |
WeakPtr (T *pointer) | |
Constructor: Initializes the weak pointer with a pointer to an object. More... | |
WeakPtr (const WeakPtr &other) | |
Copy-constructor. More... | |
template<class O > | |
WeakPtr (const WeakPtr< O > &other) | |
Copy-constructor for weak pointers to objects of another class. More... | |
virtual | ~WeakPtr () |
Destructor. More... | |
T * | get () const |
Returns the wrapped pointer as T* . More... | |
Destroyable * | getBase () const |
Returns the wrapped pointer as Destroyable* . More... | |
const FunctorPtr & | getCallback () const |
Returns the registered callback. More... | |
operator bool () const | |
Returns true if the pointer is not nullptr. More... | |
operator T * () const | |
Implicitly converts the WeakPtr to a pointer of type T* . More... | |
T & | operator* () const |
Overloaded operator, returns a reference to the stored object. More... | |
T * | operator-> () const |
Overloaded operator, returns a pointer to the stored object. More... | |
WeakPtr & | operator= (T *pointer) |
Assigns a new pointer. More... | |
WeakPtr & | operator= (WeakPtr other) |
Assigns the wrapped pointer of another WeakPtr. More... | |
template<class O > | |
WeakPtr & | operator= (const WeakPtr< O > &other) |
Assigns the wrapped pointer of a WeakPtr of another class. More... | |
void | reset () |
Resets the weak pointer (equivalent to assigning a nullptr). More... | |
void | setCallback (const FunctorPtr &callback) |
Registers a callback that will be executed if the stored object is destroyed. More... | |
void | swap (WeakPtr &other) |
Swaps the contents of two weak pointers. More... | |
Private Member Functions | |
virtual void | objectDeleted () override |
Will be called by Destroyable::~Destroyable() if the stored object is deleted. Resets the wrapped pointer and executes the callback. More... | |
Private Attributes | |
Destroyable * | base_ |
The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, WeakPtr couln't be used with forward declarations) More... | |
FunctorPtr | callback_ |
This callback will be executed if the stored object is deleted. More... | |
T * | pointer_ |
The wrapped pointer to an object of type T. More... | |
Additional Inherited Members | |
![]() | |
virtual | ~DestructionListener () |
void | registerAsDestructionListener (Destroyable *object) |
void | unregisterAsDestructionListener (Destroyable *object) |
WeakPtr wraps a pointer to an object, which becomes nullptr if the object is deleted.
|
inline |
Constructor: Initializes the weak pointer with a null pointer.
|
inline |
Constructor: Initializes the weak pointer with a pointer to an object.
|
inline |
Copy-constructor.
|
inline |
Copy-constructor for weak pointers to objects of another class.
|
inlinevirtual |
Destructor.
|
inline |
Returns the wrapped pointer as T*
.
|
inline |
Returns the wrapped pointer as Destroyable*
.
|
inline |
Returns the registered callback.
|
inlineoverrideprivatevirtual |
Will be called by Destroyable::~Destroyable() if the stored object is deleted. Resets the wrapped pointer and executes the callback.
Implements orxonox::DestructionListener.
|
inlineexplicit |
Returns true if the pointer is not nullptr.
|
inline |
Implicitly converts the WeakPtr to a pointer of type T*
.
|
inline |
Overloaded operator, returns a reference to the stored object.
|
inline |
Overloaded operator, returns a pointer to the stored object.
|
inline |
Assigns a new pointer.
|
inline |
Assigns the wrapped pointer of another WeakPtr.
|
inline |
Assigns the wrapped pointer of a WeakPtr of another class.
|
inline |
Resets the weak pointer (equivalent to assigning a nullptr).
|
inline |
Registers a callback that will be executed if the stored object is destroyed.
|
inline |
Swaps the contents of two weak pointers.
|
private |
The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, WeakPtr couln't be used with forward declarations)
|
private |
This callback will be executed if the stored object is deleted.
|
private |
The wrapped pointer to an object of type T.