DART  6.7.3
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. More...
 
 TemplateWeakBodyNodePtr (BodyNodeT *_ptr)
 Typical constructor. More...
 
template<class OtherBodyNodeT >
 TemplateWeakBodyNodePtr (const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr)
 Constructor that takes in a WeakBodyNodePtr. More...
 
TemplateWeakBodyNodePtroperator= (BodyNodeT *_ptr)
 Assignment operator for raw BodyNode pointers. More...
 
template<class OtherBodyNodeT >
TemplateWeakBodyNodePtroperator= (const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr)
 Assignment operator for WeakBodyNodePtrs. More...
 
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. More...
 
template<class OtherBodyNodeT >
void set (const TemplateWeakBodyNodePtr< OtherBodyNodeT > &_weakPtr)
 Attempt to set the BodyNode for this WeakBodyNodePtr based on another WeakBodyNodePtr. More...
 
bool expired () const
 Returns true if this WeakBodyNodePtr is referencing a nullptr or a pointer which has been deleted. More...
 

Private Attributes

BodyNodeT * mPtr
 Raw pointer for the BodyNode that this WeakBodyNodePtr references. More...
 
std::shared_ptr< MutexedWeakSkeletonPtrmLocker
 A shared_ptr that allows the WeakBodyNodePtr to know whether it can lock into a BodyNodePtr. 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() [1/3]

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

Default constructor.

◆ TemplateWeakBodyNodePtr() [2/3]

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

◆ TemplateWeakBodyNodePtr() [3/3]

template<class BodyNodeT >
template<class OtherBodyNodeT >
dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::TemplateWeakBodyNodePtr ( const TemplateWeakBodyNodePtr< OtherBodyNodeT > &  _weakPtr)
inline

Constructor that takes in a WeakBodyNodePtr.

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.

◆ operator=() [1/2]

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

Assignment operator for raw BodyNode pointers.

◆ operator=() [2/2]

template<class BodyNodeT >
template<class OtherBodyNodeT >
TemplateWeakBodyNodePtr& dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::operator= ( const TemplateWeakBodyNodePtr< OtherBodyNodeT > &  _weakPtr)
inline

Assignment operator for WeakBodyNodePtrs.

◆ set() [1/2]

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

Set the BodyNode for this WeakBodyNodePtr.

◆ set() [2/2]

template<class BodyNodeT >
template<class OtherBodyNodeT >
void dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::set ( const TemplateWeakBodyNodePtr< OtherBodyNodeT > &  _weakPtr)
inline

Attempt to set the BodyNode for this WeakBodyNodePtr based on another WeakBodyNodePtr.

Friends And Related Function Documentation

◆ TemplateWeakBodyNodePtr

template<class BodyNodeT >
template<class >
friend class TemplateWeakBodyNodePtr
friend

Member Data Documentation

◆ mLocker

template<class BodyNodeT >
std::shared_ptr<MutexedWeakSkeletonPtr> dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::mLocker
private

A shared_ptr that allows the WeakBodyNodePtr to know whether it can lock into a BodyNodePtr.

◆ mPtr

template<class BodyNodeT >
BodyNodeT* dart::dynamics::TemplateWeakBodyNodePtr< BodyNodeT >::mPtr
private

Raw pointer for the BodyNode that this WeakBodyNodePtr references.