SimulationChain
 All Classes Functions Variables Pages
CSimNode Class Referenceabstract

#include <SimNode.h>

Inheritance diagram for CSimNode:
Collaboration diagram for CSimNode:

Public Member Functions

 CSimNode (int nID=0, ObjType Type=simobject, std::string const &sName=std::string("node"))
 Constructs the base abstract class for simulation object handling. More...
 
double Simulate (double dInput) override=0
 Outputs one step of the simualtion given one sample of the input. More...
 
void GetOutputHistory (std::vector< double > &vHist) const override
 Outputs all output samples recorded by far. More...
 
void EraseOutputHistory () override
 Deletes all recorded samples of output. More...
 
virtual void SetOutputHistory (std::vector< double > &vHist) override
 Set output history. More...
 
virtual void SetInputHistory (std::vector< double > &vHist) override
 Set input history. More...
 
void SaveState (boost::property_tree::ptree &pt) const override=0
 Adds internal object state data to the stream object. More...
 
void LoadState (boost::property_tree::ptree::value_type const &v) override=0
 Load internal object state data from tree. Each object manages the data itself. More...
 
void SetID (int nID=0) override
 Enables user to set an ID of the object. User must ensure that the name is unique. More...
 
int GetID () const override
 Fetches object's ID. More...
 
void SetName (std::string &sName) override
 Registers a name with the object. User must ensure that the name is unique. More...
 
const std::string & GetName () const override
 Fetches object's name. More...
 
void GetName (boost::property_tree::ptree &nameTree) const override
 Builds a tree containing names and types of all children nodes. More...
 
void SetParent (ISISO *Parent) override
 Sets object's parent. There can be only one parent of the same object. More...
 
ISISOGetParent () override
 Fetches object's parent pointer. More...
 
void AddChild (std::shared_ptr< ISISO > Child) override
 Allows adding children to the object. More...
 
void RemoveChild (std::shared_ptr< ISISO > Child)
 Removes a child of the object. More...
 
void GetChildren (std::list< std::weak_ptr< ISISO > > &lChildren) const override
 Fetches the list of object's children. More...
 
bool RemoveObject (int nID) override
 Allows to remove the object. Function searches all the children of the object. More...
 
ISISOSearchObject (const std::string &s) override
 Searches all the children of the object to find object with the specified name. More...
 
ISISOFindFirstRegulator () override
 Searches the tree for the first regulator object.
 
ObjType GetType () const override
 Retrive object functional type. More...
 
void SetType (ObjType Type) override
 Set object functional type. More...
 
void SetStreamForOutput (std::shared_ptr< std::ostream > oStream) override
 Set the output stream for object output values. More...
 
void SetVariableToStoreCurrentOutput (std::weak_ptr< double > dOutVal)
 Set the variable to store the current output value. More...
 
void SetVariableToStoreCurrentInput (std::weak_ptr< double > dInVal)
 Set the variable to store the current input value. More...
 
void RemoveStreamForOutput () override
 Disable the output stream for objects input values. More...
 
bool MoveObjectToFront (ISISO *FrontObject) override
 Move object to the front so it can be run first. More...
 
void ResetMemory () override
 Resets objects memory (reset generators if present). More...
 

Protected Attributes

int m_nID
 Objects unique ID.
 
std::string m_sName
 Objects unique name.
 
CHistorian m_OutputHistory
 Output sample history.
 
CHistorian m_InputHistory
 Input sample history.
 
std::list< std::shared_ptr
< ISISO > > 
m_lChildren
 List of children.
 
ISISOm_Parent
 Pointer to parent.
 
ObjType m_Type
 Objects type.
 
std::shared_ptr< std::ostream > m_oStream
 Output stream.
 
std::weak_ptr< double > m_dOutVal
 Pointer to variable storing last output value.
 
std::weak_ptr< double > m_dInVal
 Pointer to variable storing last input value.
 

Detailed Description

Class implements a common functionality of simulation objects and a composite design pattern to inherit futher.

It defines the basic self organizing tree data structure and ensures no memory leaks by automatic deallocation of its children when the node is being removed.
For more
See also
ISISO.

Constructor & Destructor Documentation

CSimNode::CSimNode ( int  nID = 0,
ObjType  Type = simobject,
std::string const &  sName = std::string("node") 
)

Constructs the base abstract class for simulation object handling.

Parameters
[in]nIDProposed ID for object. Given 0 next viable id will be found automaticly.
[in]TypeType of the object.
[in]sNameProposed name to register.

DEBUG

Here is the call graph for this function:

Member Function Documentation

void CSimNode::AddChild ( std::shared_ptr< ISISO Child)
overridevirtual

Allows adding children to the object.

Parameters
[in]ChildAdds the given child.

prevent setting an object its own child

Implements ISISO.

void CSimNode::EraseOutputHistory ( )
inlineoverridevirtual

Deletes all recorded samples of output.

Implements ISISO.

void CSimNode::GetChildren ( std::list< std::weak_ptr< ISISO > > &  lChildren) const
overridevirtual

Fetches the list of object's children.

Parameters
[out]lChildrenPointes to all the children from the object as a list.

Implements ISISO.

int CSimNode::GetID ( ) const
inlineoverridevirtual

Fetches object's ID.

Returns
ID of the object.

Implements ISISO.

const std::string& CSimNode::GetName ( ) const
inlineoverridevirtual

Fetches object's name.

Returns
Reference to the objects name.

Implements ISISO.

Here is the caller graph for this function:

void CSimNode::GetName ( boost::property_tree::ptree &  nameTree) const
overridevirtual

Builds a tree containing names and types of all children nodes.

Parameters
[out]nameTreeBuilds tree containing names of object and all its children.

ask children to write their state data

Implements ISISO.

void CSimNode::GetOutputHistory ( std::vector< double > &  vHist) const
inlineoverridevirtual

Outputs all output samples recorded by far.

Parameters
[out]vHistReturns output history as a vector of doubles.

Implements ISISO.

Here is the call graph for this function:

ISISO* CSimNode::GetParent ( )
inlineoverridevirtual

Fetches object's parent pointer.

Returns
Pointer to the parent.

Implements ISISO.

ObjType CSimNode::GetType ( ) const
inlineoverridevirtual

Retrive object functional type.

Returns
Returns type of the object.

Implements ISISO.

Here is the caller graph for this function:

void CSimNode::LoadState ( boost::property_tree::ptree::value_type const &  v)
overridepure virtual

Load internal object state data from tree. Each object manages the data itself.

Parameters
[in]vProperty tree to deserialize objects data from.

Implements ISISO.

Implemented in CPIDRegulator, CGPC, CSimObject, and CPRegulator.

bool CSimNode::MoveObjectToFront ( ISISO FrontObject)
overridevirtual

Move object to the front so it can be run first.

Parameters
[in]FrontObjectPointer to the object to move.

Implements ISISO.

void CSimNode::RemoveChild ( std::shared_ptr< ISISO Child)
inlinevirtual

Removes a child of the object.

Parameters
[in]ChildPointer to the child to remove from the tree.

Implements ISISO.

bool CSimNode::RemoveObject ( int  nID)
overridevirtual

Allows to remove the object. Function searches all the children of the object.

Returns
True if object successfuly removed.
Parameters
[in]nIDSearches an object with the given id and removes it from the tree.

Implements ISISO.

void CSimNode::RemoveStreamForOutput ( )
inlineoverridevirtual

Disable the output stream for objects input values.

Implements ISISO.

void CSimNode::ResetMemory ( )
overridevirtual

Resets objects memory (reset generators if present).

Implements ISISO.

Here is the call graph for this function:

Here is the caller graph for this function:

void CSimNode::SaveState ( boost::property_tree::ptree &  pt) const
overridepure virtual

Adds internal object state data to the stream object.

Parameters
[out]ptProperty tree to store serialized object.

Implements ISISO.

Implemented in CPIDRegulator, CGPC, CSimObject, and CPRegulator.

ISISO * CSimNode::SearchObject ( const std::string &  s)
overridevirtual

Searches all the children of the object to find object with the specified name.

Returns
Pointer to found object or nullptr.
Parameters
[in]sName of an object to search.

Implements ISISO.

Here is the call graph for this function:

Here is the caller graph for this function:

void CSimNode::SetID ( int  nID = 0)
overridevirtual

Enables user to set an ID of the object. User must ensure that the name is unique.

Parameters
[in]nIDNew, proposed ID value. When set to 0 picks first available.

trying to reserve ID

Implements ISISO.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void CSimNode::SetInputHistory ( std::vector< double > &  vHist)
inlineoverridevirtual

Set input history.

Parameters
[out]vHistSets input history as a vector of doubles.

Implements ISISO.

Here is the call graph for this function:

void CSimNode::SetName ( std::string &  sName)
overridevirtual

Registers a name with the object. User must ensure that the name is unique.

Parameters
[in]sNameTries to register new name of the object.

Implements ISISO.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void CSimNode::SetOutputHistory ( std::vector< double > &  vHist)
inlineoverridevirtual

Set output history.

Parameters
[in]vHistSets new output history.

Implements ISISO.

Here is the call graph for this function:

void CSimNode::SetParent ( ISISO Parent)
overridevirtual

Sets object's parent. There can be only one parent of the same object.

Parameters
[in]ParentPointer to the parent.

inform old parent about the child loss

Implements ISISO.

Here is the call graph for this function:

void CSimNode::SetStreamForOutput ( std::shared_ptr< std::ostream >  oStream)
inlineoverridevirtual

Set the output stream for object output values.

Parameters
[in]oStreamOutput stream to store output data to.

Implements ISISO.

void CSimNode::SetType ( ObjType  Type)
inlineoverridevirtual

Set object functional type.

Parameters
[in]TypeType of the object to set.

Implements ISISO.

Here is the caller graph for this function:

void CSimNode::SetVariableToStoreCurrentInput ( std::weak_ptr< double >  dInVal)
inlinevirtual

Set the variable to store the current input value.

Parameters
[out]dInValPointer of the variable to store last input into.

Implements ISISO.

void CSimNode::SetVariableToStoreCurrentOutput ( std::weak_ptr< double >  dOutVal)
inlinevirtual

Set the variable to store the current output value.

Parameters
[out]dOutValPointer of the variable to store last output into.

Implements ISISO.

double CSimNode::Simulate ( double  dInput)
overridepure virtual

Outputs one step of the simualtion given one sample of the input.

Returns
Next simulation output.
Parameters
[in]dInputNext input (can be feedback) value.

Implements ISISO.

Implemented in CSimObject, CRegulator, CGPC, CPIDRegulator, and CPRegulator.


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