CCA

Base CCA Data-Flow Component. More...

#include <Node.h>

Inheritance diagram for cca::Node:
Collaboration diagram for cca::Node:

List of all members.

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

Base CCA Data-Flow Component.

Definition at line 61 of file Node.h.


Member Typedef Documentation

typedef std::pair<std::string, InputPortPtr> cca::Node::NamedInputPort [protected]

Definition at line 391 of file Node.h.

typedef std::map<std::string, InputPortPtr> cca::Node::NamedInputPorts [protected]

Definition at line 393 of file Node.h.

typedef std::pair<std::string, OutputPortPtr> cca::Node::NamedOutputPort [protected]

Definition at line 392 of file Node.h.

typedef std::map<std::string, OutputPortPtr> cca::Node::NamedOutputPorts [protected]

Definition at line 394 of file Node.h.


Constructor & Destructor Documentation

cca::Node::Node ( const std::string &  name)

Constructor.

Parameters:
nodenameName of this Node

Definition at line 56 of file Node.cpp.

References create(), getName(), and logger.

Here is the call graph for this function:

cca::Node::~Node ( ) [virtual]

Definition at line 65 of file Node.cpp.

References stop().

Here is the call graph for this function:

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:
nameName of the port to configure
portcfgPortConfiguration 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void cca::Node::configureInputPort ( const std::string &  name,
const std::string &  scope 
) [virtual]

Configure input port.

Parameters:
nameName of the port to configure
scopeConnecting scope

Definition at line 223 of file Node.cpp.

References getName(), inputPorts, and logger.

Here is the call graph for this function:

void cca::Node::configureOutputPort ( const std::string &  name,
PortConfigurationPtr  portcfg 
) [virtual]

Configure output port.

Parameters:
nameName of the port to configure
portPortConfiguration, 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void cca::Node::configureOutputPort ( const std::string &  name,
const std::string &  scope 
) [virtual]

Configure output port.

Parameters:
nameName of the port to configure
scopeConnecting scope

Definition at line 271 of file Node.cpp.

References getName(), logger, and outputPorts.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

template<typename T >
T cca::Node::getProperty ( const std::string &  name) const [inline]
Exceptions:
boost::bad_any_cast
Parameters:
nameName of the property
Returns:
Property value

Definition at line 102 of file Node.h.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void cca::Node::inputCallback ( rsb::EventPtr  event,
const std::string &  name 
) [protected, virtual]

Input callback.

Parameters:
eventArriving event
inputPortPort index of the receiving input port.

Definition at line 379 of file Node.cpp.

References getName(), isConfigured(), logger, process(), and strategy.

Referenced by registerPort().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

bool cca::Node::isReady ( ) const [virtual]

Returns if node is ready for processing.

Definition at line 477 of file Node.cpp.

References ready.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
nameName of the input port

Definition at line 489 of file Node.cpp.

References inputPorts.

void cca::Node::onCreate ( ) [virtual]

Function called when this node is created.

Definition at line 404 of file Node.cpp.

References getName(), and logger.

Referenced by create().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void cca::Node::onTick ( ) [virtual]

Function called on every tick, even when processing strategy is not timed.

Definition at line 473 of file Node.cpp.

References getName(), and logger.

Referenced by tick().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
nameName of the port for later reference
portPort shared pointer
optionalDeclare 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

template<typename T >
void cca::Node::registerProperty ( const std::string &  name,
const T &  defaultvalue 
) [inline]

Registers a property for a cca node, usually done in its constructor.

Creates the property and assigns a default value, that is set on intitialization and every reset of the node.

Parameters:
nameName of the property
defaultvalueDefault value of the property

Definition at line 85 of file Node.h.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
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:
nameName of the property to set
valueValue to set
Returns:
true of the property was inserted, false if a property with the given name existed and nothing was changed

Definition at line 121 of file Node.h.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::map<std::string, std::string> cca::Node::config [protected]

Component configuration.

CCA-specific component configuration, e.g. processing strategy.

Definition at line 410 of file Node.h.

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().

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]

Definition at line 442 of file Node.h.

Referenced by load().

std::string cca::Node::name [private]

Node name.

Definition at line 440 of file Node.h.

Referenced by cca::RandomNumberGenerator< DATATYPE >::create(), and getName().

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]

Definition at line 442 of file Node.h.

Referenced by process().

rsc::runtime::Properties cca::Node::properties [protected]

Component properties. defaultProperties on initialization.

Definition at line 421 of file Node.h.

Referenced by cca::Component::print(), print(), and reset().

bool cca::Node::ready [private]

Definition at line 442 of file Node.h.

Referenced by initialize(), isReady(), process(), resume(), and stop().

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]

User-specific configuration.

User-specific component configuration, arbitrary user data.

Definition at line 416 of file Node.h.


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