dart
Public Member Functions | Friends | List of all members
dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT > Class Template Reference

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.
 
TemplateWeakBodyNodePtroperator= (BodyNodeT *_ptr)
 Assignment operator for raw BodyNode pointers.
 
template<class OtherBodyNodeT >
TemplateWeakBodyNodePtroperator= (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
 

Detailed Description

template<class BodyNodeT>
class dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >

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.

Constructor & Destructor Documentation

◆ TemplateWeakBodyNodePtr()

template<class BodyNodeT>
dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::TemplateWeakBodyNodePtr ( BodyNodeT *  _ptr)
inline

Typical constructor.

_ptr must be a valid pointer (or a nullptr) when passed to this constructor

Member Function Documentation

◆ expired()

template<class BodyNodeT>
bool dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::expired ( ) const
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

◆ lock()

template<class BodyNodeT>
TemplateBodyNodePtr<BodyNodeT> dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::lock ( ) const
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.


The documentation for this class was generated from the following file: