DART  6.10.1
dart::dynamics::Node Class Referenceabstract

The Node class is a base class for BodyNode and any object that attaches to a BodyNode. More...

#include <Node.hpp>

Inheritance diagram for dart::dynamics::Node:
dart::common::Subject dart::common::VersionCounter dart::dynamics::JacobianNode dart::dynamics::TemplatedJacobianNode< BodyNode > dart::dynamics::TemplatedJacobianNode< NodeType > dart::dynamics::BodyNode

Classes

class  Properties
 If your Node has a Properties class, then that Properties class should inherit this Node::Properties class. More...
 
class  State
 If your Node has a State class, then that State class should inherit this Node::State class. More...
 

Public Types

template<class Mixin >
using MakeState = common::MakeCloneable< State, Mixin >
 Use the MakeState class to easily create a State extension from an existing class or struct. More...
 
template<class Mixin >
using MakeProperties = common::MakeCloneable< Properties, Mixin >
 Use the MakeProperties class to easily create a Properties extension from an existing class or struct. More...
 

Public Member Functions

virtual ~Node ()=default
 Virtual destructor. More...
 
virtual const std::string & setName (const std::string &newName)=0
 Set the name of this Node. More...
 
virtual const std::string & getName () const =0
 Get the name of this Node. More...
 
virtual void setNodeState (const State &otherState)
 Set the State of this Node. By default, this does nothing. More...
 
virtual std::unique_ptr< StategetNodeState () const
 Get the State of this Node. More...
 
virtual void copyNodeStateTo (std::unique_ptr< State > &outputState) const
 Copy the State of this Node into a unique_ptr. More...
 
virtual void setNodeProperties (const Properties &properties)
 Set the Properties of this Node. By default, this does nothing. More...
 
virtual std::unique_ptr< PropertiesgetNodeProperties () const
 Get the Properties of this Node. More...
 
virtual void copyNodePropertiesTo (std::unique_ptr< Properties > &outputProperties) const
 Copy the Properties of this Node into a unique_ptr. More...
 
BodyNodePtr getBodyNodePtr ()
 Get a pointer to the BodyNode that this Node is associated with. More...
 
ConstBodyNodePtr getBodyNodePtr () const
 Get a pointer to the BodyNode that this Node is associated with. More...
 
bool isRemoved () const
 Returns true if this Node has been staged for removal from its BodyNode. More...
 
virtual std::shared_ptr< SkeletongetSkeleton ()
 Return the Skeleton that this Node is attached to. More...
 
virtual std::shared_ptr< const SkeletongetSkeleton () const
 Return the Skeleton that this Node is attached to. More...
 
virtual std::size_t incrementVersion ()
 Increment the version for this object. More...
 
virtual std::size_t getVersion () const
 Get the version number of this object. More...
 

Protected Member Functions

virtual NodecloneNode (BodyNode *bn) const =0
 Allow your Node implementation to be cloned into a new BodyNode. More...
 
 Node (BodyNode *_bn)
 Constructor. More...
 
std::string registerNameChange (const std::string &newName)
 Inform the Skeleton that the name of this Node has changed. More...
 
void attach ()
 Attach the Node to its BodyNode. More...
 
void stageForRemoval ()
 When all external references to the Node disappear, it will be deleted. More...
 
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers. More...
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers. More...
 
void setVersionDependentObject (VersionCounter *dependent)
 

Protected Attributes

std::weak_ptr< NodeDestructormDestructor
 weak pointer to the destructor for this Node. More...
 
BodyNodemBodyNode
 Pointer to the BodyNode that this Node is attached to. More...
 
bool mAmAttached
 bool that tracks whether this Node is attached to its BodyNode More...
 
std::size_t mIndexInBodyNode
 The index of this Node within its vector in its BodyNode's NodeMap. More...
 
std::size_t mIndexInSkeleton
 The index of this Node within its vector in its Skeleton's NodeMap. More...
 
std::size_t mIndexInTree
 Index of this Node within its tree. More...
 
std::set< Observer * > mObservers
 List of current Observers. More...
 
std::size_t mVersion
 

Private Member Functions

std::shared_ptr< NodeDestructorgetOrCreateDestructor ()
 

Private Attributes

VersionCountermDependent
 

Friends

class BodyNode
 
class Skeleton
 
template<class >
class AccessoryNode
 
template<class , class >
class TemplateNodePtr
 
template<class , class >
class TemplateWeakNodePtr
 

Detailed Description

The Node class is a base class for BodyNode and any object that attaches to a BodyNode.

This base class handles ownership and reference counting for the classes that inherit it.

In most cases, when creating your own custom Node class, you will also want to inherit from AccessoryNode using CRTP.

Member Typedef Documentation

◆ MakeProperties

Use the MakeProperties class to easily create a Properties extension from an existing class or struct.

◆ MakeState

template<class Mixin >
using dart::dynamics::Node::MakeState = common::MakeCloneable<State, Mixin>

Use the MakeState class to easily create a State extension from an existing class or struct.

Constructor & Destructor Documentation

◆ ~Node()

virtual dart::dynamics::Node::~Node ( )
virtualdefault

Virtual destructor.

◆ Node()

dart::dynamics::Node::Node ( BodyNode _bn)
protected

Constructor.

Member Function Documentation

◆ addObserver()

void dart::common::Subject::addObserver ( Observer _observer) const
protectedinherited

Add an Observer to the list of Observers.

◆ attach()

void dart::dynamics::Node::attach ( )
protected

Attach the Node to its BodyNode.

◆ cloneNode()

virtual Node* dart::dynamics::Node::cloneNode ( BodyNode bn) const
protectedpure virtual

Allow your Node implementation to be cloned into a new BodyNode.

Implemented in dart::dynamics::BodyNode.

◆ copyNodePropertiesTo()

void dart::dynamics::Node::copyNodePropertiesTo ( std::unique_ptr< Properties > &  outputProperties) const
virtual

Copy the Properties of this Node into a unique_ptr.

By default, this simply calls getNodeProperties() and passes the result into the outputProperties, but this function can be overriden to be more performant.

◆ copyNodeStateTo()

void dart::dynamics::Node::copyNodeStateTo ( std::unique_ptr< State > &  outputState) const
virtual

Copy the State of this Node into a unique_ptr.

By default, this simply calls getNodeState() and passes the result into the outputState, but this function can be overriden to be more performant by avoiding allocations.

◆ getBodyNodePtr() [1/2]

BodyNodePtr dart::dynamics::Node::getBodyNodePtr ( )

Get a pointer to the BodyNode that this Node is associated with.

◆ getBodyNodePtr() [2/2]

ConstBodyNodePtr dart::dynamics::Node::getBodyNodePtr ( ) const

Get a pointer to the BodyNode that this Node is associated with.

◆ getName()

virtual const std::string& dart::dynamics::Node::getName ( ) const
pure virtual

Get the name of this Node.

Implemented in dart::dynamics::BodyNode.

◆ getNodeProperties()

std::unique_ptr< Node::Properties > dart::dynamics::Node::getNodeProperties ( ) const
virtual

Get the Properties of this Node.

By default, this returns a nullptr which implies that the Node has no properties.

◆ getNodeState()

std::unique_ptr< Node::State > dart::dynamics::Node::getNodeState ( ) const
virtual

Get the State of this Node.

By default, this returns a nullptr which implies that the Node is stateless.

◆ getOrCreateDestructor()

std::shared_ptr< NodeDestructor > dart::dynamics::Node::getOrCreateDestructor ( )
private

◆ getSkeleton() [1/2]

std::shared_ptr< Skeleton > dart::dynamics::Node::getSkeleton ( )
virtual

Return the Skeleton that this Node is attached to.

Reimplemented in dart::dynamics::BodyNode.

◆ getSkeleton() [2/2]

std::shared_ptr< const Skeleton > dart::dynamics::Node::getSkeleton ( ) const
virtual

Return the Skeleton that this Node is attached to.

Reimplemented in dart::dynamics::BodyNode.

◆ getVersion()

std::size_t dart::common::VersionCounter::getVersion ( ) const
virtualinherited

Get the version number of this object.

◆ incrementVersion()

std::size_t dart::common::VersionCounter::incrementVersion ( )
virtualinherited

Increment the version for this object.

Reimplemented in dart::dynamics::Shape.

◆ isRemoved()

bool dart::dynamics::Node::isRemoved ( ) const

Returns true if this Node has been staged for removal from its BodyNode.

It will be deleted once all strong references to it expire. If it is an AccessoryNode, you can call reattach() to prevent that from happening.

◆ registerNameChange()

std::string dart::dynamics::Node::registerNameChange ( const std::string &  newName)
protected

Inform the Skeleton that the name of this Node has changed.

If the name is already taken by another Node of the same type, then this function will return a modified version which is unique. If the name is not already taken, then it will just return the same name that the function was given.

◆ removeObserver()

void dart::common::Subject::removeObserver ( Observer _observer) const
protectedinherited

Remove an Observer from the list of Observers.

◆ sendDestructionNotification()

void dart::common::Subject::sendDestructionNotification ( ) const
protectedinherited

Send a destruction notification to all Observers.

This will cause all Observers to behave as if this Subject has been permanently deleted, so it should only be called when that behavior is desired.

◆ setName()

virtual const std::string& dart::dynamics::Node::setName ( const std::string &  newName)
pure virtual

Set the name of this Node.

Implemented in dart::dynamics::BodyNode.

◆ setNodeProperties()

void dart::dynamics::Node::setNodeProperties ( const Properties properties)
virtual

Set the Properties of this Node. By default, this does nothing.

◆ setNodeState()

void dart::dynamics::Node::setNodeState ( const State otherState)
virtual

Set the State of this Node. By default, this does nothing.

◆ setVersionDependentObject()

void dart::common::VersionCounter::setVersionDependentObject ( VersionCounter dependent)
protectedinherited

◆ stageForRemoval()

void dart::dynamics::Node::stageForRemoval ( )
protected

When all external references to the Node disappear, it will be deleted.

Friends And Related Function Documentation

◆ AccessoryNode

template<class >
friend class AccessoryNode
friend

◆ BodyNode

friend class BodyNode
friend

◆ Skeleton

friend class Skeleton
friend

◆ TemplateNodePtr

template<class , class >
friend class TemplateNodePtr
friend

◆ TemplateWeakNodePtr

template<class , class >
friend class TemplateWeakNodePtr
friend

Member Data Documentation

◆ mAmAttached

bool dart::dynamics::Node::mAmAttached
protected

bool that tracks whether this Node is attached to its BodyNode

◆ mBodyNode

BodyNode* dart::dynamics::Node::mBodyNode
protected

Pointer to the BodyNode that this Node is attached to.

◆ mDependent

VersionCounter* dart::common::VersionCounter::mDependent
privateinherited

◆ mDestructor

std::weak_ptr<NodeDestructor> dart::dynamics::Node::mDestructor
protected

weak pointer to the destructor for this Node.

We use a shared_ptr "destructor" class instead of managing Nodes directly with shared_ptrs because this scheme allows BodyNodes to circumvent the shared_ptr management by setting the mNode member of the Destructor to a nullptr. That way the BodyNode can never be deleted by its Destructor.

◆ mIndexInBodyNode

std::size_t dart::dynamics::Node::mIndexInBodyNode
protected

The index of this Node within its vector in its BodyNode's NodeMap.

◆ mIndexInSkeleton

std::size_t dart::dynamics::Node::mIndexInSkeleton
protected

The index of this Node within its vector in its Skeleton's NodeMap.

◆ mIndexInTree

std::size_t dart::dynamics::Node::mIndexInTree
protected

Index of this Node within its tree.

◆ mObservers

std::set<Observer*> dart::common::Subject::mObservers
mutableprotectedinherited

List of current Observers.

◆ mVersion

std::size_t dart::common::VersionCounter::mVersion
protectedinherited