dart
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for dart::dynamics::Node:
Collaboration graph
[legend]

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.
 
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.
 
virtual const std::string & setName (const std::string &newName)=0
 Set the name of this Node.
 
virtual const std::string & getName () const =0
 Get the name of this Node.
 
virtual void setNodeState (const State &otherState)
 Set the State of this Node. By default, this does nothing.
 
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.
 
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.
 
ConstBodyNodePtr getBodyNodePtr () const
 Get a pointer to the BodyNode that this Node is associated with.
 
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.
 
virtual std::shared_ptr< const SkeletongetSkeleton () const
 Return the Skeleton that this Node is attached to.
 
- Public Member Functions inherited from dart::common::Subject
virtual ~Subject ()
 Destructor will notify all Observers that it is destructing.
 
- Public Member Functions inherited from dart::common::VersionCounter
 VersionCounter ()
 Default constructor.
 
virtual std::size_t incrementVersion ()
 Increment the version for this object.
 
virtual std::size_t getVersion () const
 Get the version number of this object.
 

Protected Member Functions

virtual NodecloneNode (BodyNode *bn) const =0
 Allow your Node implementation to be cloned into a new BodyNode.
 
 Node (BodyNode *_bn)
 Constructor.
 
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.
 
void stageForRemoval ()
 When all external references to the Node disappear, it will be deleted.
 
- Protected Member Functions inherited from dart::common::Subject
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers.
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers.
 
- Protected Member Functions inherited from dart::common::VersionCounter
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.
 
bool mAmAttached
 bool that tracks whether this Node is attached to its BodyNode
 
std::size_t mIndexInBodyNode
 The index of this Node within its vector in its BodyNode's NodeMap.
 
std::size_t mIndexInSkeleton
 The index of this Node within its vector in its Skeleton's NodeMap.
 
std::size_t mIndexInTree
 Index of this Node within its tree.
 
- Protected Attributes inherited from dart::common::Subject
std::set< Observer * > mObservers
 List of current Observers.
 
- Protected Attributes inherited from dart::common::VersionCounter
std::size_t mVersion
 

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.

Member Function Documentation

◆ 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.

◆ 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.

◆ 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.

Member Data Documentation

◆ 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.


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