PeriDyno 1.0.0
Loading...
Searching...
No Matches
Node Class Reference

#include <Node.h>

Inheritance diagram for Node:
Collaboration diagram for Node:

Public Types

template<class T>
using SPtr = std::shared_ptr<T>
 
- Public Types inherited from dyno::OBase
typedef std::vector< FBase * > FieldVector
 
typedef std::map< FieldID, FBase * > FieldMap
 

Public Member Functions

 Node ()
 
 ~Node () override
 
void setName (std::string name)
 
std::string getName () override
 
virtual std::string getNodeType ()
 
bool isAutoSync ()
 
bool isAutoHidden ()
 
void setAutoSync (bool con)
 Whether the node can be automatically synchronized when its ancestor is updated.
 
void setAutoHidden (bool con)
 
virtual bool isActive ()
 Check the state of dynamics.
 
virtual void setActive (bool active)
 Set the state of dynamics.
 
virtual bool isVisible ()
 Check the visibility of context.
 
virtual void setVisible (bool visible)
 Set the visibility of context.
 
virtual Real getDt ()
 Simulation timestep.
 
void setDt (Real dt)
 
void setSceneGraph (SceneGraph *scn)
 
SceneGraph * getSceneGraph ()
 
std::vector< NodePort * > & getImportNodes ()
 
std::vector< NodePort * > & getExportNodes ()
 
bool addModule (std::shared_ptr< Module > module)
 Add a module to m_module_list and other special module lists.
 
template<class TModule>
bool addModule (std::shared_ptr< TModule > tModule)
 Add a speical kind of module.
 
template<class TModule>
std::shared_ptr< TModule > addModule (std::string name)
 
bool deleteModule (std::shared_ptr< Module > module)
 
template<class TModule>
bool deleteModule (std::shared_ptr< TModule > tModule)
 
std::list< std::shared_ptr< Module > > & getModuleList ()
 
bool hasModule (std::string name)
 
std::shared_ptr< ModulegetModule (std::string name)
 Get a module by its name.
 
template<class TModule>
std::shared_ptr< TModule > getModule ()
 Get the Module by the module class name.
 
template<class TModule>
std::shared_ptr< TModule > getModule (std::string name)
 
std::shared_ptr< PipelineresetPipeline ()
 
std::shared_ptr< AnimationPipeline > animationPipeline ()
 
std::shared_ptr< GraphicsPipeline > graphicsPipeline ()
 
void update ()
 Called every time interval.
 
void updateGraphicsContext ()
 
void reset ()
 
virtual NBoundingBox boundingBox ()
 
bool connect (NodePort *nPort)
 Depth-first tree traversal.
 
bool disconnect (NodePort *nPort)
 
bool attachField (FBase *field, std::string name, std::string desc, bool autoDestroy=true) override
 Attach a field to Node.
 
std::vector< NodePort * > & getAllNodePorts ()
 
uint sizeOfNodePorts ()
 
uint sizeOfImportNodes () const
 
uint sizeOfExportNodes () const
 
void setForceUpdate (bool b)
 
 DEF_VAR_STATE (Real, ElapsedTime, 0, "Elapsed Time")
 
 DEF_VAR_STATE (Real, TimeStep, Real(0.033), "Time step size")
 
 DEF_VAR_STATE (uint, FrameNumber, 0, "Frame number")
 
- Public Member Functions inherited from dyno::OBase
 OBase ()
 
 ~OBase () override
 
virtual std::string caption ()
 Return the caption.
 
virtual bool captionVisible ()
 Whether to hide the caption in the GUI.
 
virtual std::string description ()
 Return a description for the node or module, override this function to support user-defined description.
 
bool addField (FBase *data)
 Add a field to Base FieldID will be set to the name of Field by default.
 
bool addField (FieldID name, FBase *data)
 Add a field to Base.
 
bool addFieldAlias (FieldID name, FBase *data)
 
bool addFieldAlias (FieldID name, FBase *data, FieldMap &fieldAlias)
 
bool findField (FBase *data)
 Find a field by its pointer.
 
bool findFieldAlias (const FieldID name)
 Find a field by its name.
 
bool findFieldAlias (const FieldID name, FieldMap &fieldAlias)
 Find a field in fieldAlias by its name This function is typically called by other functions.
 
bool removeField (FBase *data)
 Remove a field by its pointer.
 
bool removeFieldAlias (const FieldID name)
 Remove a field by its name.
 
bool removeFieldAlias (const FieldID name, FieldMap &fieldAlias)
 
FBasegetField (const FieldID name)
 Return a field by its name.
 
std::vector< FBase * > & getAllFields ()
 
template<typename T>
TgetField (FieldID name)
 
bool isAllFieldsReady ()
 Check the completeness of all required fields.
 
std::vector< FieldIDgetFieldAlias (FBase *data)
 
int getFieldAliasCount (FBase *data)
 
void setBlockCoord (float x, float y)
 
float bx ()
 
float by ()
 
bool findInputField (FBase *field)
 
bool addInputField (FBase *field)
 
bool removeInputField (FBase *field)
 
std::vector< FBase * > & getInputFields ()
 
bool findOutputField (FBase *field)
 
bool addOutputField (FBase *field)
 
bool addToOutput (FBase *field)
 
bool removeOutputField (FBase *field)
 
bool removeFromOutput (FBase *field)
 
std::vector< FBase * > & getOutputFields ()
 
bool findParameter (FBase *field)
 
bool addParameter (FBase *field)
 
bool removeParameter (FBase *field)
 
std::vector< FBase * > & getParameters ()
 
- Public Member Functions inherited from dyno::Object
 Object ()
 
virtual ~Object ()
 
ObjectId objectId ()
 

Public Attributes

std::string m_node_name
 

Protected Member Functions

bool appendExportNode (NodePort *nodePort)
 
bool removeExportNode (NodePort *nodePort)
 
virtual void preUpdateStates ()
 
virtual void updateStates ()
 
virtual void postUpdateStates ()
 
virtual void updateTopology ()
 
virtual void resetStates ()
 
virtual bool validateInputs ()
 
virtual bool requireUpdate ()
 
void tick ()
 notify all state and output fields are updated
 

Private Member Functions

bool addNodePort (NodePort *port)
 
bool addToModuleList (std::shared_ptr< Module > module)
 
bool deleteFromModuleList (std::shared_ptr< Module > module)
 

Private Attributes

bool mAutoSync = false
 A parameter to control whether the node can be updated automatically by its ancestor.
 
bool mPhysicsEnabled = true
 
bool mRenderingEnabled = true
 
bool mExported = true
 
bool mForceUpdate = true
 
bool mAutoHidden = false
 
Real mDt
 Time step size.
 
std::list< std::shared_ptr< Module > > mModuleList
 A module list containing all modules.
 
std::shared_ptr< PipelinemResetPipeline
 Pointer of the pipeline.
 
std::shared_ptr< AnimationPipeline > mAnimationPipeline
 
std::shared_ptr< GraphicsPipeline > mGraphicsPipeline
 
std::vector< NodePort * > mImportNodes
 
std::vector< NodePort * > mExportNodes
 
SceneGraph * mSceneGraph = nullptr
 

Friends

class NodePort
 

Additional Inherited Members

- Static Public Member Functions inherited from dyno::Object
static bool registerClass (ClassInfo *ci)
 
static ObjectcreateObject (std::string name)
 
static std::map< std::string, ClassInfo * > * getClassMap ()
 
static ObjectId baseId ()
 Base Id.
 
- Protected Attributes inherited from dyno::OBase
std::vector< FBase * > fields_input
 
std::vector< FBase * > fields_output
 
std::vector< FBase * > fields_param
 

Detailed Description

Definition at line 67 of file Node.h.

Member Typedef Documentation

◆ SPtr

template<class T>
using dyno::Node::SPtr = std::shared_ptr<T>

Definition at line 72 of file Node.h.

Constructor & Destructor Documentation

◆ Node()

dyno::Node::Node ( )

Definition at line 8 of file Node.cpp.

◆ ~Node()

dyno::Node::~Node ( )
override

Definition at line 16 of file Node.cpp.

Member Function Documentation

◆ addModule() [1/3]

bool dyno::Node::addModule ( std::shared_ptr< Module > module)

Add a module to m_module_list and other special module lists.

Parameters
modulemodule should be created before calling this function
Returns
true return true if successfully added
false return false if module already exists

Definition at line 365 of file Node.cpp.

◆ addModule() [2/3]

template<class TModule>
bool dyno::Node::addModule ( std::shared_ptr< TModule > tModule)
inline

Add a speical kind of module.

Template Parameters
TModuleModule type
Parameters
tModuleAdded module
Returns
true
false

Definition at line 137 of file Node.h.

◆ addModule() [3/3]

template<class TModule>
std::shared_ptr< TModule > dyno::Node::addModule ( std::string name)
inline

Definition at line 198 of file Node.h.

◆ addNodePort()

bool dyno::Node::addNodePort ( NodePort * port)
private

Definition at line 580 of file Node.cpp.

◆ addToModuleList()

bool dyno::Node::addToModuleList ( std::shared_ptr< Module > module)
private

Definition at line 657 of file Node.cpp.

◆ animationPipeline()

std::shared_ptr< AnimationPipeline > dyno::Node::animationPipeline ( )

Definition at line 311 of file Node.cpp.

◆ appendExportNode()

bool dyno::Node::appendExportNode ( NodePort * nodePort)
protected

Definition at line 435 of file Node.cpp.

◆ attachField()

bool dyno::Node::attachField ( FBase * field,
std::string name,
std::string desc,
bool autoDestroy = true )
overridevirtual

Attach a field to Node.

Parameters
fieldField pointer
nameField name
descField description
autoDestroyThe field will be destroyed by Base if true, otherwise, the field should be explicitly destroyed by its creator.
Returns
Return false if the name conflicts with exists fields' names

Reimplemented from dyno::OBase.

Definition at line 493 of file Node.cpp.

◆ boundingBox()

NBoundingBox dyno::Node::boundingBox ( )
virtual

Definition at line 196 of file Node.cpp.

◆ connect()

bool dyno::Node::connect ( NodePort * nPort)

Depth-first tree traversal.

Parameters
actOperation on the node

Breadth-first tree traversal

Parameters
actOperation on the node

Definition at line 481 of file Node.cpp.

◆ DEF_VAR_STATE() [1/3]

dyno::Node::DEF_VAR_STATE ( Real ,
ElapsedTime ,
0 ,
"Elapsed Time"  )

◆ DEF_VAR_STATE() [2/3]

dyno::Node::DEF_VAR_STATE ( Real ,
TimeStep ,
Real(0.033) ,
"Time step size"  )

◆ DEF_VAR_STATE() [3/3]

dyno::Node::DEF_VAR_STATE ( uint ,
FrameNumber ,
0 ,
"Frame number"  )

◆ deleteFromModuleList()

bool dyno::Node::deleteFromModuleList ( std::shared_ptr< Module > module)
private

Definition at line 670 of file Node.cpp.

◆ deleteModule() [1/2]

bool dyno::Node::deleteModule ( std::shared_ptr< Module > module)

Definition at line 373 of file Node.cpp.

◆ deleteModule() [2/2]

template<class TModule>
bool dyno::Node::deleteModule ( std::shared_ptr< TModule > tModule)
inline

Definition at line 143 of file Node.h.

◆ disconnect()

bool dyno::Node::disconnect ( NodePort * nPort)

Definition at line 488 of file Node.cpp.

◆ getAllNodePorts()

std::vector< NodePort * > & dyno::Node::getAllNodePorts ( )
inline

Definition at line 261 of file Node.h.

◆ getDt()

float dyno::Node::getDt ( )
virtual

Simulation timestep.

Definition at line 93 of file Node.cpp.

◆ getExportNodes()

std::vector< NodePort * > & dyno::Node::getExportNodes ( )
inline

Definition at line 116 of file Node.h.

◆ getImportNodes()

std::vector< NodePort * > & dyno::Node::getImportNodes ( )
inline

Definition at line 115 of file Node.h.

◆ getModule() [1/3]

template<class TModule>
std::shared_ptr< TModule > dyno::Node::getModule ( )
inline

Get the Module by the module class name.

Template Parameters
TModuleModule class name
Returns
std::shared_ptr<TModule> return nullptr is no module is found, otherwise return the first found module

Definition at line 168 of file Node.h.

◆ getModule() [2/3]

std::shared_ptr< Module > dyno::Node::getModule ( std::string name)

Get a module by its name.

Parameters
nameModule name
Returns
std::shared_ptr<Module> return nullptr is no module is found, otherwise return the first found module

Definition at line 622 of file Node.cpp.

◆ getModule() [3/3]

template<class TModule>
std::shared_ptr< TModule > dyno::Node::getModule ( std::string name)
inline

Definition at line 186 of file Node.h.

◆ getModuleList()

std::list< std::shared_ptr< Module > > & dyno::Node::getModuleList ( )
inline

Definition at line 149 of file Node.h.

◆ getName()

std::string dyno::Node::getName ( )
overridevirtual

Reimplemented from dyno::OBase.

Definition at line 43 of file Node.cpp.

◆ getNodeType()

std::string dyno::Node::getNodeType ( )
virtual

Definition at line 48 of file Node.cpp.

◆ getSceneGraph()

SceneGraph * dyno::Node::getSceneGraph ( )

Definition at line 108 of file Node.cpp.

◆ graphicsPipeline()

std::shared_ptr< GraphicsPipeline > dyno::Node::graphicsPipeline ( )

Definition at line 320 of file Node.cpp.

◆ hasModule()

bool dyno::Node::hasModule ( std::string name)

Definition at line 637 of file Node.cpp.

◆ isActive()

bool dyno::Node::isActive ( )
virtual

Check the state of dynamics.

Definition at line 73 of file Node.cpp.

◆ isAutoHidden()

bool dyno::Node::isAutoHidden ( )

Definition at line 58 of file Node.cpp.

◆ isAutoSync()

bool dyno::Node::isAutoSync ( )

Definition at line 53 of file Node.cpp.

◆ isVisible()

bool dyno::Node::isVisible ( )
virtual

Check the visibility of context.

Definition at line 83 of file Node.cpp.

◆ postUpdateStates()

void dyno::Node::postUpdateStates ( )
protectedvirtual

Definition at line 201 of file Node.cpp.

◆ preUpdateStates()

void dyno::Node::preUpdateStates ( )
protectedvirtual

Definition at line 136 of file Node.cpp.

◆ removeExportNode()

bool dyno::Node::removeExportNode ( NodePort * nodePort)
protected

Definition at line 453 of file Node.cpp.

◆ requireUpdate()

bool dyno::Node::requireUpdate ( )
protectedvirtual

Definition at line 237 of file Node.cpp.

◆ reset()

void dyno::Node::reset ( )

Definition at line 183 of file Node.cpp.

◆ resetPipeline()

std::shared_ptr< Pipeline > dyno::Node::resetPipeline ( )

Definition at line 302 of file Node.cpp.

◆ resetStates()

void dyno::Node::resetStates ( )
protectedvirtual

Definition at line 214 of file Node.cpp.

◆ setActive()

void dyno::Node::setActive ( bool active)
virtual

Set the state of dynamics.

Definition at line 78 of file Node.cpp.

◆ setAutoHidden()

void dyno::Node::setAutoHidden ( bool con)

Definition at line 68 of file Node.cpp.

◆ setAutoSync()

void dyno::Node::setAutoSync ( bool con)

Whether the node can be automatically synchronized when its ancestor is updated.

Parameters
iftrue, the node can be synchronized automatically, otherwise not

Definition at line 63 of file Node.cpp.

◆ setDt()

void dyno::Node::setDt ( Real dt)

Definition at line 98 of file Node.cpp.

◆ setForceUpdate()

void dyno::Node::setForceUpdate ( bool b)

Definition at line 544 of file Node.cpp.

◆ setName()

void dyno::Node::setName ( std::string name)

Definition at line 38 of file Node.cpp.

◆ setSceneGraph()

void dyno::Node::setSceneGraph ( SceneGraph * scn)

Definition at line 103 of file Node.cpp.

◆ setVisible()

void dyno::Node::setVisible ( bool visible)
virtual

Set the visibility of context.

Definition at line 88 of file Node.cpp.

◆ sizeOfExportNodes()

uint dyno::Node::sizeOfExportNodes ( ) const
inline

Definition at line 266 of file Node.h.

◆ sizeOfImportNodes()

uint dyno::Node::sizeOfImportNodes ( ) const

Definition at line 533 of file Node.cpp.

◆ sizeOfNodePorts()

uint dyno::Node::sizeOfNodePorts ( )
inline

Definition at line 263 of file Node.h.

◆ tick()

void dyno::Node::tick ( )
protected

notify all state and output fields are updated

Definition at line 266 of file Node.cpp.

◆ update()

void dyno::Node::update ( )

Called every time interval.

Definition at line 146 of file Node.cpp.

◆ updateGraphicsContext()

void dyno::Node::updateGraphicsContext ( )

Definition at line 206 of file Node.cpp.

◆ updateStates()

void dyno::Node::updateStates ( )
protectedvirtual

Definition at line 141 of file Node.cpp.

◆ updateTopology()

void dyno::Node::updateTopology ( )
protectedvirtual

Definition at line 476 of file Node.cpp.

◆ validateInputs()

bool dyno::Node::validateInputs ( )
protectedvirtual

Definition at line 219 of file Node.cpp.

Friends And Related Symbol Documentation

◆ NodePort

friend class NodePort
friend

Definition at line 352 of file Node.h.

Member Data Documentation

◆ m_node_name

std::string dyno::Node::m_node_name

Definition at line 301 of file Node.h.

◆ mAnimationPipeline

std::shared_ptr<AnimationPipeline> dyno::Node::mAnimationPipeline
private

Definition at line 341 of file Node.h.

◆ mAutoHidden

bool dyno::Node::mAutoHidden = false
private

Definition at line 322 of file Node.h.

◆ mAutoSync

bool dyno::Node::mAutoSync = false
private

A parameter to control whether the node can be updated automatically by its ancestor.

Definition at line 312 of file Node.h.

◆ mDt

Real dyno::Node::mDt
private

Time step size.

Definition at line 328 of file Node.h.

◆ mExported

bool dyno::Node::mExported = true
private

Definition at line 318 of file Node.h.

◆ mExportNodes

std::vector<NodePort*> dyno::Node::mExportNodes
private

Definition at line 348 of file Node.h.

◆ mForceUpdate

bool dyno::Node::mForceUpdate = true
private

Definition at line 320 of file Node.h.

◆ mGraphicsPipeline

std::shared_ptr<GraphicsPipeline> dyno::Node::mGraphicsPipeline
private

Definition at line 342 of file Node.h.

◆ mImportNodes

std::vector<NodePort*> dyno::Node::mImportNodes
private

Definition at line 346 of file Node.h.

◆ mModuleList

std::list<std::shared_ptr<Module> > dyno::Node::mModuleList
private

A module list containing all modules.

Definition at line 334 of file Node.h.

◆ mPhysicsEnabled

bool dyno::Node::mPhysicsEnabled = true
private

Definition at line 314 of file Node.h.

◆ mRenderingEnabled

bool dyno::Node::mRenderingEnabled = true
private

Definition at line 316 of file Node.h.

◆ mResetPipeline

std::shared_ptr<Pipeline> dyno::Node::mResetPipeline
private

Pointer of the pipeline.

Definition at line 340 of file Node.h.

◆ mSceneGraph

SceneGraph* dyno::Node::mSceneGraph = nullptr
private

Definition at line 350 of file Node.h.


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