CCA
|
Base CCA Data-Flow Component. More...
#include <Node.h>
Public Member Functions | |
Node (const std::string &name) | |
Constructor. | |
virtual | ~Node () |
template<typename T > | |
void | registerProperty (const std::string &name, const T &defaultvalue) |
Registers a property for a cca node, usually done in its constructor. | |
template<typename T > | |
T | getProperty (const std::string &name) const |
template<typename T > | |
void | setProperty (const std::string &name, const T &value) throw () |
Sets a new property in the map. | |
virtual std::string | getName () const |
Returns name od the node. | |
virtual void | configureInputPort (const std::string &name, PortConfigurationPtr portcfg) |
Configure input port. | |
virtual void | configureInputPort (const std::string &name, const std::string &scope) |
Configure input port. | |
virtual void | configureOutputPort (const std::string &name, PortConfigurationPtr portcfg) |
Configure output port. | |
virtual void | configureOutputPort (const std::string &name, const std::string &scope) |
Configure output port. | |
virtual void | setProcessingStrategy (StrategyPtr strategy) |
Sets processing strategy. | |
virtual bool | isReady () const |
Returns if node is ready for processing. | |
virtual void | onCreate () |
Function called when this node is created. | |
virtual void | onStop () |
Function called right before this node is stopped. | |
virtual void | onResume () |
Function called right after this node is resumed after it has been stopped /ref onStop. | |
virtual void | onReset () |
Function called when teh component is resetted. | |
virtual void | onLoad () |
Function called right before this node is loaded after it has been persisted /ref onPersist. | |
virtual void | onPersist () |
Function called right before this node is persisted. | |
virtual void | onTick () |
Function called on every tick, even when processing strategy is not timed. | |
virtual void | onInitialize () |
Initialize the node. | |
virtual bool | initialize () |
Initialize the node. | |
virtual bool | reset () |
Reste the component. | |
void | tick () |
For global synchonization, this node receives a global clock beat. | |
virtual std::string | print () const |
Printing information about this node. | |
virtual void | onProcess ()=0 |
This is the mathod where the actual processing of the node takes place. | |
virtual bool | isConfigured () |
Checks, if component is fully configured yet and ready to run. | |
Protected Types | |
typedef std::pair< std::string, InputPortPtr > | NamedInputPort |
typedef std::pair< std::string, OutputPortPtr > | NamedOutputPort |
typedef std::map< std::string, InputPortPtr > | NamedInputPorts |
typedef std::map< std::string, OutputPortPtr > | NamedOutputPorts |
Protected Member Functions | |
void | registerPort (const std::string &name, InputPortPtr port, bool optional=false) |
Adds an input port to this node. | |
void | registerPort (const std::string &name, OutputPortPtr port, bool optional=false) |
bool | newValueAt (const std::string &name) const |
Is a new value available at input port with given number. | |
virtual void | process () |
If processing is triggered. | |
virtual void | create () |
This method does some preparation of the node when it is created and after that calls the user-defined method /ref onCreate(), where additional user code can assigned to the time when the node is created. | |
virtual bool | stop () |
Function called right before this node is stopped. | |
virtual bool | resume () |
Function called right after this node is resumed after it has been stopped /ref onStop. | |
virtual bool | load () |
Function called right before this node is loaded after it has been persisted /ref onPersist. | |
virtual bool | persist () |
Function called right before this node is persisted. | |
virtual void | inputCallback (rsb::EventPtr event, const std::string &name) |
Input callback. | |
virtual StrategyPtr | getProcessingStrategy () const |
Protected Attributes | |
NamedInputPorts | inputPorts |
Input ports (which are RSB listeners) | |
NamedOutputPorts | outputPorts |
Output ports (which are RSB informers) | |
std::map< std::string, std::string > | config |
Component configuration. | |
std::map< std::string, std::string > | userconfig |
User-specific configuration. | |
rsc::runtime::Properties | properties |
Component properties. defaultProperties on initialization. | |
rsc::runtime::Properties | defaultProperties |
Default properties, set on initialization and reset. | |
Private Member Functions | |
Node (Node &node) | |
Copy constructor Copy constructor private for now to disallow copying. | |
void | operator= (const Node &) |
Copy operator Copy operator private for now to disallow copying. | |
Private Attributes | |
std::string | name |
Node name. | |
bool | ready |
bool | loaded |
bool | created |
bool | configured |
bool | processing |
StrategyPtr | strategy |
Processing strategy of this node. | |
rsc::logging::LoggerPtr | logger |
Detailed Description
Member Typedef Documentation
typedef std::pair<std::string, InputPortPtr> cca::Node::NamedInputPort [protected] |
typedef std::map<std::string, InputPortPtr> cca::Node::NamedInputPorts [protected] |
typedef std::pair<std::string, OutputPortPtr> cca::Node::NamedOutputPort [protected] |
typedef std::map<std::string, OutputPortPtr> cca::Node::NamedOutputPorts [protected] |
Constructor & Destructor Documentation
cca::Node::Node | ( | const std::string & | name | ) |
cca::Node::~Node | ( | ) | [virtual] |
cca::Node::Node | ( | Node & | node | ) | [private] |
Copy constructor Copy constructor private for now to disallow copying.
Member Function Documentation
void cca::Node::configureInputPort | ( | const std::string & | name, |
PortConfigurationPtr | portcfg | ||
) | [virtual] |
Configure input port.
- Parameters:
-
name Name of the port to configure portcfg PortConfiguration type, either PortConfiguration::LOCAL() or PortConfiguration::REMOTE(), default is the local port.
Definition at line 199 of file Node.cpp.
References getName(), inputPorts, and logger.
Referenced by cca::Collector< DTOTYPE >::configureInputPortByIndex().
void cca::Node::configureInputPort | ( | const std::string & | name, |
const std::string & | scope | ||
) | [virtual] |
Configure input port.
- Parameters:
-
name Name of the port to configure scope Connecting scope
Definition at line 223 of file Node.cpp.
References getName(), inputPorts, and logger.
void cca::Node::configureOutputPort | ( | const std::string & | name, |
PortConfigurationPtr | portcfg | ||
) | [virtual] |
Configure output port.
- Parameters:
-
name Name of the port to configure port PortConfiguration, either PortConfiguration::LOCAL() or PortConfiguration::REMOTE() with given Scope, default is the local port.
Definition at line 247 of file Node.cpp.
References getName(), logger, and outputPorts.
Referenced by cca::Splitter< DTOTYPE >::configureOutputPortByIndex().
void cca::Node::configureOutputPort | ( | const std::string & | name, |
const std::string & | scope | ||
) | [virtual] |
Configure output port.
- Parameters:
-
name Name of the port to configure scope Connecting scope
Definition at line 271 of file Node.cpp.
References getName(), logger, and outputPorts.
void cca::Node::create | ( | ) | [protected, virtual] |
This method does some preparation of the node when it is created and after that calls the user-defined method /ref onCreate(), where additional user code can assigned to the time when the node is created.
Definition at line 396 of file Node.cpp.
References created, getName(), logger, and onCreate().
Referenced by cca::Collector< DTOTYPE >::Collector(), cca::Component::createBeatInputPort(), cca::Component::createStateInputPort(), cca::Component::createStateOutputPort(), Node(), cca::Collector< DTOTYPE >::onProcess(), cca::RandomNumberGenerator< DATATYPE >::RandomNumberGenerator(), and cca::Splitter< DTOTYPE >::Splitter().
string cca::Node::getName | ( | ) | const [virtual] |
Returns name od the node.
- Returns:
- Name of the node
Definition at line 163 of file Node.cpp.
References name.
Referenced by cca::Component::beatCallback(), cca::Component::Component(), cca::Component::configureBeatInputPort(), configureInputPort(), configureOutputPort(), cca::Component::configureStateInputPort(), cca::Component::configureStateOutputPort(), create(), cca::Component::createBeatInputPort(), cca::Component::createStateInputPort(), cca::Component::createStateOutputPort(), initialize(), inputCallback(), isConfigured(), Node(), onCreate(), onInitialize(), cca::Component::onLearnOffline(), cca::Component::onLearnOnlineAfterProcess(), cca::Component::onLearnOnlineBeforeProcess(), cca::Component::onProcess(), cca::Splitter< DTOTYPE >::onProcess(), cca::Collector< DTOTYPE >::onProcess(), onReset(), onResume(), onStop(), onTick(), cca::RandomNumberGenerator< DATATYPE >::print(), cca::Component::print(), print(), cca::Component::process(), process(), cca::Component::publishState(), registerPort(), cca::Component::requestTransition(), reset(), resume(), cca::Component::scopeName(), setProcessingStrategy(), cca::Component::stateCallback(), stop(), and tick().
StrategyPtr cca::Node::getProcessingStrategy | ( | ) | const [protected, virtual] |
Definition at line 167 of file Node.cpp.
References strategy.
Referenced by cca::Component::print(), cca::Component::process(), and process().
T cca::Node::getProperty | ( | const std::string & | name | ) | const [inline] |
bool cca::Node::initialize | ( | ) | [virtual] |
Initialize the node.
This should be called once, when all ports are connected. Returns, if initializing was complete, which can fail for several reasons. For example, if configuration could not be loaded.
- Returns:
- If successfully initialized
Definition at line 102 of file Node.cpp.
References created, getName(), isConfigured(), logger, onInitialize(), ready, and resume().
Referenced by process(), and reset().
void cca::Node::inputCallback | ( | rsb::EventPtr | event, |
const std::string & | name | ||
) | [protected, virtual] |
Input callback.
- Parameters:
-
event Arriving event inputPort Port index of the receiving input port.
Definition at line 379 of file Node.cpp.
References getName(), isConfigured(), logger, process(), and strategy.
Referenced by registerPort().
bool cca::Node::isConfigured | ( | ) | [virtual] |
Checks, if component is fully configured yet and ready to run.
This includes
- Checking if all input ports are properly configured
- Checking if all output ports are properly configured
- Checking if processing strategy is set
- Returns:
- Is component fully configured
Definition at line 308 of file Node.cpp.
References configured, getName(), inputPorts, logger, outputPorts, and strategy.
Referenced by cca::Component::beatCallback(), initialize(), inputCallback(), cca::Component::process(), resume(), cca::Component::stateCallback(), and tick().
bool cca::Node::isReady | ( | ) | const [virtual] |
bool cca::Node::load | ( | ) | [protected, virtual] |
Function called right before this node is loaded after it has been persisted /ref onPersist.
- Todo:
Define conditions which this method has to full-fill (e.g. time constraints)
Think about which default can go here (e.g loading configuration)
- Returns:
- If loading was successfull
Definition at line 448 of file Node.cpp.
References loaded, and onLoad().
Referenced by cca::Component::requestTransition().
bool cca::Node::newValueAt | ( | const std::string & | name | ) | const [protected] |
Is a new value available at input port with given number.
- Todo:
- Also implement for Scope as input parameter (New value at Scope ...)
- Parameters:
-
name Name of the input port
Definition at line 489 of file Node.cpp.
References inputPorts.
void cca::Node::onCreate | ( | ) | [virtual] |
void cca::Node::onInitialize | ( | ) | [virtual] |
Initialize the node.
This should be called once, when all ports are connected.
Definition at line 159 of file Node.cpp.
References getName(), and logger.
Referenced by initialize().
void cca::Node::onLoad | ( | ) | [virtual] |
Function called right before this node is loaded after it has been persisted /ref onPersist.
- Todo:
Define conditions which this method has to full-fill (e.g. time constraints)
Think about which default can go here (e.g loading configuration)
Definition at line 457 of file Node.cpp.
Referenced by load().
void cca::Node::onPersist | ( | ) | [virtual] |
Function called right before this node is persisted.
- Todo:
Define conditions which this method has to full-fill (e.g. time constraints)
Think about which default can go here (e.g persiting configuration)
Definition at line 469 of file Node.cpp.
Referenced by persist().
virtual void cca::Node::onProcess | ( | ) | [pure virtual] |
This is the mathod where the actual processing of the node takes place.
Implemented in cca::Collector< DTOTYPE >, cca::Splitter< DTOTYPE >, cca::Component, cca::RandomNumberGenerator< DATATYPE >, and cca::NemoTransformation< T >.
Referenced by process().
void cca::Node::onReset | ( | ) | [virtual] |
Function called when teh component is resetted.
- Todo:
- Define conditions which this method has to full-fill (e.g. time constraints)
Definition at line 425 of file Node.cpp.
References getName(), and logger.
Referenced by reset().
void cca::Node::onResume | ( | ) | [virtual] |
Function called right after this node is resumed after it has been stopped /ref onStop.
- Todo:
- Define conditions which this method has to full-fill (e.g. time constraints)
Definition at line 443 of file Node.cpp.
References getName(), and logger.
Referenced by resume().
void cca::Node::onStop | ( | ) | [virtual] |
Function called right before this node is stopped.
- Todo:
- Define conditions which this method has to full-fill (e.g. time constraints)
Definition at line 420 of file Node.cpp.
References getName(), and logger.
Referenced by stop().
void cca::Node::onTick | ( | ) | [virtual] |
void cca::Node::operator= | ( | const Node & | ) | [private] |
Copy operator Copy operator private for now to disallow copying.
bool cca::Node::persist | ( | ) | [protected, virtual] |
Function called right before this node is persisted.
- Todo:
- Define conditions which this method has to full-fill (e.g.
time constraints)
- Todo:
- Think about which default can go here (e.g persiting configuration)
Definition at line 461 of file Node.cpp.
References onPersist().
Referenced by cca::Component::requestTransition().
std::string cca::Node::print | ( | ) | const [virtual] |
Printing information about this node.
Reimplemented in cca::Component, and cca::RandomNumberGenerator< DATATYPE >.
Definition at line 481 of file Node.cpp.
References defaultProperties, getName(), inputPorts, outputPorts, properties, and strategy.
Referenced by operator<<(), and process().
void cca::Node::process | ( | ) | [protected, virtual] |
If processing is triggered.
Reimplemented in cca::Component.
Definition at line 345 of file Node.cpp.
References getName(), getProcessingStrategy(), initialize(), logger, onProcess(), print(), processing, and ready.
Referenced by inputCallback(), and tick().
void cca::Node::registerPort | ( | const std::string & | name, |
InputPortPtr | port, | ||
bool | optional = false |
||
) | [protected] |
Adds an input port to this node.
A shared pointer to the created typed InputPort is returned and the port can also be named for later reference.
- Parameters:
-
name Name of the port for later reference port Port shared pointer optional Declare port to be optional
Definition at line 69 of file Node.cpp.
References getName(), inputCallback(), inputPorts, and logger.
Referenced by cca::Collector< DTOTYPE >::Collector(), and cca::Splitter< DTOTYPE >::Splitter().
void cca::Node::registerPort | ( | const std::string & | name, |
OutputPortPtr | port, | ||
bool | optional = false |
||
) | [protected] |
Definition at line 88 of file Node.cpp.
References getName(), logger, and outputPorts.
void cca::Node::registerProperty | ( | const std::string & | name, |
const T & | defaultvalue | ||
) | [inline] |
bool cca::Node::reset | ( | ) | [virtual] |
Reste the component.
Will stop the component, call user hook onReset and then initialize component.
- Returns:
- If successfully initialized
Definition at line 128 of file Node.cpp.
References defaultProperties, getName(), initialize(), inputPorts, logger, onReset(), properties, and stop().
Referenced by cca::Component::requestTransition().
bool cca::Node::resume | ( | ) | [protected, virtual] |
Function called right after this node is resumed after it has been stopped /ref onStop.
- Todo:
- Define conditions which this method has to full-fill (e.g. time constraints)
- Returns:
- If resuming was successfull
Definition at line 430 of file Node.cpp.
References getName(), isConfigured(), logger, onResume(), and ready.
Referenced by initialize(), and cca::Component::requestTransition().
void cca::Node::setProcessingStrategy | ( | StrategyPtr | strategy | ) | [virtual] |
Sets processing strategy.
Possible startegies right now are: 1. ProcessingStrategy::TIMED() 2. ProcessingStrategy::RESTLESS() 3. ProcessingStrategy::MODERATE() 4. ProcessingStrategy::COORDINATED() 5. ProcessingStrategy::PORT_TRIGGERED()
Definition at line 295 of file Node.cpp.
References getName(), inputPorts, logger, and strategy.
Referenced by cca::Collector< DTOTYPE >::Collector(), cca::NemoTransformation< T >::NemoTransformation(), and cca::Splitter< DTOTYPE >::Splitter().
void cca::Node::setProperty | ( | const std::string & | name, |
const T & | value | ||
) | throw () [inline] |
Sets a new property in the map.
If a property with this name exits, the new one will not be inserted. The old property has to be removed first.
- Parameters:
-
name Name of the property to set value Value to set
- Returns:
true
of the property was inserted,false
if a property with the given name existed and nothing was changed
bool cca::Node::stop | ( | ) | [protected, virtual] |
Function called right before this node is stopped.
- Todo:
- Define conditions which this method has to full-fill (e.g. time constraints)
- Returns:
- If stopping component was successful
Definition at line 409 of file Node.cpp.
References getName(), logger, onStop(), and ready.
Referenced by cca::Component::requestTransition(), reset(), cca::Component::~Component(), and ~Node().
void cca::Node::tick | ( | ) |
For global synchonization, this node receives a global clock beat.
- Todo:
- protected, but callable by friend classes (beat).
Definition at line 171 of file Node.cpp.
References getName(), isConfigured(), logger, onTick(), process(), and strategy.
Referenced by cca::Component::beatCallback().
Member Data Documentation
std::map<std::string, std::string> cca::Node::config [protected] |
bool cca::Node::configured [private] |
Definition at line 442 of file Node.h.
Referenced by isConfigured().
bool cca::Node::created [private] |
Definition at line 442 of file Node.h.
Referenced by create(), and initialize().
rsc::runtime::Properties cca::Node::defaultProperties [protected] |
Default properties, set on initialization and reset.
Definition at line 424 of file Node.h.
Referenced by cca::Component::print(), print(), and reset().
NamedInputPorts cca::Node::inputPorts [protected] |
Input ports (which are RSB listeners)
Definition at line 399 of file Node.h.
Referenced by configureInputPort(), isConfigured(), newValueAt(), cca::Component::print(), print(), registerPort(), reset(), and setProcessingStrategy().
bool cca::Node::loaded [private] |
rsc::logging::LoggerPtr cca::Node::logger [private] |
Reimplemented in cca::Collector< DTOTYPE >, and cca::Component.
Definition at line 447 of file Node.h.
Referenced by configureInputPort(), configureOutputPort(), create(), initialize(), inputCallback(), isConfigured(), Node(), onCreate(), onInitialize(), onReset(), onResume(), onStop(), onTick(), process(), registerPort(), reset(), resume(), setProcessingStrategy(), stop(), and tick().
std::string cca::Node::name [private] |
Node name.
Definition at line 440 of file Node.h.
Referenced by cca::RandomNumberGenerator< DATATYPE >::create(), and getName().
NamedOutputPorts cca::Node::outputPorts [protected] |
Output ports (which are RSB informers)
Definition at line 404 of file Node.h.
Referenced by configureOutputPort(), isConfigured(), cca::Component::print(), print(), and registerPort().
bool cca::Node::processing [private] |
rsc::runtime::Properties cca::Node::properties [protected] |
bool cca::Node::ready [private] |
StrategyPtr cca::Node::strategy [private] |
Processing strategy of this node.
Definition at line 445 of file Node.h.
Referenced by getProcessingStrategy(), inputCallback(), isConfigured(), print(), setProcessingStrategy(), and tick().
std::map<std::string, std::string> cca::Node::userconfig [protected] |
The documentation for this class was generated from the following files: