dart
|
TemplateWeakBodyNodePtr is a templated class that enables users to create a non-reference-holding WeakBodyNodePtr. More...
#include <BodyNodePtr.hpp>
Public Member Functions | |
TemplateWeakBodyNodePtr () | |
Default constructor. | |
TemplateWeakBodyNodePtr (BodyNodeT *_ptr) | |
Typical constructor. More... | |
template<class OtherBodyNodeT > | |
TemplateWeakBodyNodePtr (const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr) | |
Constructor that takes in a WeakBodyNodePtr. | |
TemplateWeakBodyNodePtr & | operator= (BodyNodeT *_ptr) |
Assignment operator for raw BodyNode pointers. | |
template<class OtherBodyNodeT > | |
TemplateWeakBodyNodePtr & | operator= (const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr) |
Assignment operator for WeakBodyNodePtrs. | |
TemplateBodyNodePtr< BodyNodeT > | lock () const |
Locks the BodyNode reference to ensure that the referenced BodyNode (1) is currently still available, and (2) does not get deleted. More... | |
void | set (BodyNodeT *_ptr) |
Set the BodyNode for this WeakBodyNodePtr. | |
template<class OtherBodyNodeT > | |
void | set (const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr) |
Attempt to set the BodyNode for this WeakBodyNodePtr based on another WeakBodyNodePtr. | |
bool | expired () const |
Returns true if this WeakBodyNodePtr is referencing a nullptr or a pointer which has been deleted. More... | |
Friends | |
template<class > | |
class | TemplateWeakBodyNodePtr |
TemplateWeakBodyNodePtr is a templated class that enables users to create a non-reference-holding WeakBodyNodePtr.
Holding onto a WeakBodyNodePtr will NOT prevent the BodyNode from getting deleted, but you can use lock() to check whether the BodyNode still exists. If it does exist, it will return a valid strong BodyNodePtr. Otherwise, it will return a nullptr BodyNodePtr.
|
inline |
Typical constructor.
_ptr must be a valid pointer (or a nullptr) when passed to this constructor
|
inline |
Returns true if this WeakBodyNodePtr is referencing a nullptr or a pointer which has been deleted.
Returns false if it is referencing a pointer which is still active.
Note: in multithreaded application, there is no guarantee that the pointer will still be active after this function has finished. To guarantee that the pointer remains active, use lock() and store its return in a BodyNodePtr
|
inline |
Locks the BodyNode reference to ensure that the referenced BodyNode (1) is currently still available, and (2) does not get deleted.
If the BodyNode is not available any longer (i.e. has been deleted), then this will return a nullptr.
To keep the BodyNode active, you should capture the return value of this function in a BodyNodePtr.