Chain is the class used to manage the chain execution of multiple executable blocks (manipulation object). More...

#include <Chain.hpp>

Public Member Functions

 Chain ()
 
virtual ~Chain ()
 
int addObject (BaseManipulation *obj, int id_=-1)
 
void clear ()
 
std::unique_ptr< Chainclone () const
 
bool deleteObject (int idobj)
 
void exec (bool debug=false)
 
void exec (int idobj)
 
uint8_t getID ()
 
int getID (int i)
 
std::string getName (int i)
 
uint8_t getNChains ()
 
uint32_t getNObjects ()
 
std::string getOutputDebugResults ()
 
bool isPlottingDebugResults ()
 
void setOutputDebugResults (std::string path)
 
void setPlotDebugResults (bool active)
 

Protected Member Functions

void checkLoops ()
 
void swap (Chain &x) noexcept
 

Protected Attributes

uint8_t m_id
 
std::vector< int > m_idObjects
 
bitpit::Logger * m_log
 
uint32_t m_objcounter
 
std::vector< BaseManipulation * > m_objects
 
std::string m_outputDebRes
 
bool m_plotDebRes
 

Static Protected Attributes

static uint8_t sm_chaincounter
 

Detailed Description

Chain is the class used to manage the chain execution of multiple executable blocks (manipulation object).

Chain is a wrapper, executable container capable to manage the workflow execution of multiple manipulation objects, connected each other through port PINs. Each object added to the chain is inserted in the chain. According to the mutual connections with other object, the class will automatically assign to it a priority of execution. An ID is assigned to a new chain and to every object in the chain, in order to give to the user a persistent information to recover or the position or the ID of the object in the chain. The execution is performed following the correct order of the object chain in order to avoid conflicts in parent/child dependencies. Closed connections loops in the chain are not allowed.

Examples
genericinput_example_00001.cpp, genericinput_example_00002.cpp, genericinput_example_00003.cpp, genericinput_example_00004.cpp, genericinput_example_00005.cpp, geohandlers_example_00000.cpp, geohandlers_example_00001.cpp, geohandlers_example_00002.cpp, geohandlers_example_00003.cpp, geohandlers_example_00004.cpp, iocgns_example_00001.cpp, iocgns_example_00002.cpp, ioofoam_example_00001.cpp, ioofoam_example_00002.cpp, manipulators_example_00001.cpp, manipulators_example_00002.cpp, manipulators_example_00003.cpp, manipulators_example_00004.cpp, manipulators_example_00005.cpp, manipulators_example_00006.cpp, manipulators_example_00007.cpp, manipulators_example_00008.cpp, utils_example_00003.cpp, and utils_example_00004.cpp.

Definition at line 48 of file Chain.hpp.

Constructor & Destructor Documentation

◆ Chain()

mimmo::Chain::Chain ( )

Default constructor of Chain. It sets to zero/null each member/pointer.

Definition at line 34 of file Chain.cpp.

◆ ~Chain()

mimmo::Chain::~Chain ( )
virtual

Default destructor of Chain.

Definition at line 49 of file Chain.cpp.

Member Function Documentation

◆ addObject()

int mimmo::Chain::addObject ( BaseManipulation obj,
int  id_ = -1 
)

It adds a manipulator object in the chain. The position of the objects after the insertion can be modified in order to respect the parent/child dependencies during the execution of the chain.

Parameters
[in]objPointer to object to be inserted.
[in]id_Id of the object to be inserted (optional, if not passed or negative it is computed).
Returns
Index of insertion of the object in the chain. Return -1 if the object cannot be inserted (wrong parent/child dependencies).
Examples
genericinput_example_00001.cpp, genericinput_example_00002.cpp, genericinput_example_00003.cpp, genericinput_example_00004.cpp, genericinput_example_00005.cpp, geohandlers_example_00000.cpp, geohandlers_example_00001.cpp, geohandlers_example_00002.cpp, geohandlers_example_00003.cpp, geohandlers_example_00004.cpp, iocgns_example_00001.cpp, iocgns_example_00002.cpp, ioofoam_example_00001.cpp, ioofoam_example_00002.cpp, manipulators_example_00001.cpp, manipulators_example_00002.cpp, manipulators_example_00003.cpp, manipulators_example_00004.cpp, manipulators_example_00005.cpp, manipulators_example_00006.cpp, manipulators_example_00007.cpp, manipulators_example_00008.cpp, utils_example_00003.cpp, and utils_example_00004.cpp.

Definition at line 170 of file Chain.cpp.

◆ checkLoops()

void mimmo::Chain::checkLoops ( )
protected

It checks if a loop exists in the chain. In the case that a loop exists the process ends with an error.

Definition at line 337 of file Chain.cpp.

◆ clear()

void mimmo::Chain::clear ( )

It clears the object.

Definition at line 90 of file Chain.cpp.

◆ clone()

std::unique_ptr< Chain > mimmo::Chain::clone ( ) const

Clone(Hard Copy) the current chain in a new indipendent one.

Returns
unique pointer to the new cloned object

Definition at line 71 of file Chain.cpp.

◆ deleteObject()

bool mimmo::Chain::deleteObject ( int  idobj)

It deletes a manipulator object in the chain.

Returns
True if some linking in the chain after the deletion are interrupted.

Definition at line 148 of file Chain.cpp.

◆ exec() [1/2]

◆ exec() [2/2]

void mimmo::Chain::exec ( int  idobj)

It executes one manipulator object contained in the chain singularly.

Parameters
[in]idobjID of the target manipulator object.

Definition at line 327 of file Chain.cpp.

◆ getID() [1/2]

uint8_t mimmo::Chain::getID ( )

It gets the ID of the chain.

Returns
ID of the chain.

Definition at line 110 of file Chain.cpp.

◆ getID() [2/2]

int mimmo::Chain::getID ( int  i)

It gets the ID of an object in the chain.

Parameters
[in]iIndex of the target object in the chain.
Returns
ID of the i-th object.

Definition at line 129 of file Chain.cpp.

◆ getName()

std::string mimmo::Chain::getName ( int  i)

It gets the name of an object in the chain.

Parameters
[in]iIndex of the target object in the chain.
Returns
name of the i-th object.

Definition at line 139 of file Chain.cpp.

◆ getNChains()

uint8_t mimmo::Chain::getNChains ( )

It gets the number of chains actually defined in the process.

Returns
Number of chains in the process.

Definition at line 119 of file Chain.cpp.

◆ getNObjects()

uint32_t mimmo::Chain::getNObjects ( )

It gets the number of manipulator objects in the chain.

Returns
Number of objects in the chain.

Definition at line 101 of file Chain.cpp.

◆ getOutputDebugResults()

std::string mimmo::Chain::getOutputDebugResults ( )
Returns
specified path for storing intermediate/optional results of each block in the chain, if their plotting is enabled.

Definition at line 271 of file Chain.cpp.

◆ isPlottingDebugResults()

bool mimmo::Chain::isPlottingDebugResults ( )
Returns
true if plotting of intermediate/optional results of each block in the chain is active.

Definition at line 263 of file Chain.cpp.

◆ setOutputDebugResults()

void mimmo::Chain::setOutputDebugResults ( std::string  path)

Specify path for plotting intermediate/optional results of each block in the chain.

Parameters
[in]pathoutput directory path
Examples
manipulators_example_00002.cpp, and manipulators_example_00005.cpp.

Definition at line 256 of file Chain.cpp.

◆ setPlotDebugResults()

void mimmo::Chain::setPlotDebugResults ( bool  active)

Activate plotting of intermediate/optional results of each block in the chain. Results will be stored in a directory path specified with method setOutputDebugResults;

Parameters
[in]activetrue/false to activate plotting
Examples
manipulators_example_00002.cpp, and manipulators_example_00005.cpp.

Definition at line 248 of file Chain.cpp.

◆ swap()

void mimmo::Chain::swap ( Chain x)
protectednoexcept

Chain swap operator.

Parameters
[in]xsibling clas to be swapped

Definition at line 58 of file Chain.cpp.

Member Data Documentation

◆ m_id

uint8_t mimmo::Chain::m_id
protected

ID of the chain.

Definition at line 52 of file Chain.hpp.

◆ m_idObjects

std::vector<int> mimmo::Chain::m_idObjects
protected

ID (order of insertion) of the mimmo objects in the chain.

Definition at line 54 of file Chain.hpp.

◆ m_log

bitpit::Logger* mimmo::Chain::m_log
protected

Pointer to logger.

Definition at line 57 of file Chain.hpp.

◆ m_objcounter

uint32_t mimmo::Chain::m_objcounter
protected

Counter of objects inserted the chain.

Definition at line 55 of file Chain.hpp.

◆ m_objects

std::vector<BaseManipulation*> mimmo::Chain::m_objects
protected

Pointers to manipulation objects placed in the current execution chain.

Definition at line 53 of file Chain.hpp.

◆ m_outputDebRes

std::string mimmo::Chain::m_outputDebRes
protected

directory path to store the debug intermediate results, if plot is enabled

Definition at line 60 of file Chain.hpp.

◆ m_plotDebRes

bool mimmo::Chain::m_plotDebRes
protected

boolean to activate plotting of debug intermediate results

Definition at line 59 of file Chain.hpp.

◆ sm_chaincounter

uint8_t mimmo::Chain::sm_chaincounter
staticprotected

Current global number of chain in the instance.

Definition at line 62 of file Chain.hpp.


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