NRP Core  1.4.1
OutputNode< DATA > Class Template Referenceabstract

Implementation of an output node in the computation graph. More...

#include <output_node.h>

Inheritance diagram for OutputNode< DATA >:
ComputationalNode

Public Member Functions

 OutputNode (const std::string &id, OutputNodePolicies::PublishFormatPolicy publishFormatPolicy=OutputNodePolicies::PublishFormatPolicy::SERIES, bool publishFromCache=false, int maxPortConnections=0, unsigned int computePeriod=1)
 Constructor. More...
 
template<class T_IN >
InputPort< T_IN, DATA > * getOrRegisterInput (const std::string &id)
 Gets or register input port to this node and returns a pointer to it. More...
 
unsigned int getComputePeriod ()
 
void setComputePeriod (unsigned int computePeriod)
 
bool publishFromCache ()
 
virtual bool doCompute () const override final
 Tells if this node should be executed in this graph execution cycle, used in some graph execution modes. More...
 
- Public Member Functions inherited from ComputationalNode
 ComputationalNode ()=delete
 
virtual ~ComputationalNode ()=default
 
 ComputationalNode (std::string id, NodeType type)
 Constructor. More...
 
const std::string & id () const
 Returns the node 'id'. More...
 
NodeType type () const
 Returns the node 'type'. More...
 
virtual std::string typeStr () const
 Returns the node 'type' as a string. More...
 
void setVisited (bool visited)
 Sets a value for the node 'visited' property, used for graph traversing. More...
 
bool isVisited () const
 Returns true if the node has been marked as visited, false otherwise. More...
 
void setDoCompute (bool doCompute)
 Sets a value for the node 'doCompute' property, used in some graph execution modes. More...
 

Protected Member Functions

void configure () override
 Configures the node making it ready to execute 'compute'. More...
 
virtual void compute () override final
 Requests the node to execute its computation. More...
 
void graphCycleStartCB () override final
 Function called by the Computational Graph at the beginning of a new execution cycle. More...
 
void storeMsg (const std::string &id, const DATA *data)
 Stores a new msg in _storedMsgs['id']. More...
 
void sendMsgs (const std::string &id)
 Sends all msgs stored in _storedMsgs['id'] and clears the storage. More...
 
virtual void sendSingleMsg (const std::string &id, const DATA *data)=0
 Sends out a single msg, to be implemented by derived classes. More...
 
virtual void sendBatchMsg (const std::string &id, const std::vector< const DATA * > &data)=0
 Sends out a vector of msg as a single batch, to be implemented by derived classes. More...
 
- Protected Member Functions inherited from ComputationalNode
virtual void graphLoadedCB ()
 Function called by the Computational Graph to nodes that the graph has been completely loaded. More...
 

Protected Attributes

std::map< std::string, std::shared_ptr< Port > > _inputPorts
 List of ports owned by this node. More...
 
std::map< std::string, std::vector< const DATA * > > _storedMsgs
 List of msgs stored in this node. More...
 
OutputNodePolicies::PublishFormatPolicy _publishFormatPolicy
 Send policy used by this node. More...
 
bool _publishFromCache
 Publish frequency policy used by this node. More...
 
int _maxPortConnections
 Maximum number of subscriptions of ports in this node. More...
 
bool _isConfigured = false
 true if the node has been configured, false otherwise More...
 
unsigned int _computePeriod
 Property specifying the number of loops that passes between executions of this node. More...
 
unsigned int _nLoop = 0
 Variable counting the number of times this nodes has been asked to execute (1 per loop) More...
 

Friends

class ComputationalNodes_OUTPUT_NODE_Test
 
class ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test
 

Additional Inherited Members

- Public Types inherited from ComputationalNode
enum  NodeType { Input, Output, Functional }
 All the possible node types. More...
 
- Static Public Member Functions inherited from ComputationalNode
static std::pair< std::string, std::string > parseNodeAddress (const std::string &address, bool hasPort=true)
 Parses a computational node address returning the node id and the port (if any) contained in the address. More...
 
- Static Public Attributes inherited from ComputationalNode
const static std::map< NodeType, std::string > nodeTypeStr
 

Detailed Description

template<class DATA>
class OutputNode< DATA >

Implementation of an output node in the computation graph.

Output nodes are the connection point to send data out of the computation graph. In its 'compute' operation all messages received since last 'compute' are sent using the 'sendSingleMsg' implemented by derived classes.

Constructor & Destructor Documentation

◆ OutputNode()

template<class DATA >
OutputNode< DATA >::OutputNode ( const std::string &  id,
OutputNodePolicies::PublishFormatPolicy  publishFormatPolicy = OutputNodePolicies::PublishFormatPolicy::SERIES,
bool  publishFromCache = false,
int  maxPortConnections = 0,
unsigned int  computePeriod = 1 
)
inline

Constructor.

Member Function Documentation

◆ compute()

template<class DATA >
virtual void OutputNode< DATA >::compute ( )
inlinefinaloverrideprotectedvirtual

Requests the node to execute its computation.

Implements ComputationalNode.

◆ configure()

template<class DATA >
void OutputNode< DATA >::configure ( )
inlineoverrideprotectedvirtual

Configures the node making it ready to execute 'compute'.

Implements ComputationalNode.

◆ doCompute()

template<class DATA >
virtual bool OutputNode< DATA >::doCompute ( ) const
inlinefinaloverridevirtual

Tells if this node should be executed in this graph execution cycle, used in some graph execution modes.

ComputationalNode returns the value of its 'doCompute' property. Subclasses of ComputationalNode can implement further logic that can override this value

Reimplemented from ComputationalNode.

◆ getComputePeriod()

template<class DATA >
unsigned int OutputNode< DATA >::getComputePeriod ( )
inline

◆ getOrRegisterInput()

template<class DATA >
template<class T_IN >
InputPort<T_IN, DATA>* OutputNode< DATA >::getOrRegisterInput ( const std::string &  id)
inline

Gets or register input port to this node and returns a pointer to it.

◆ graphCycleStartCB()

template<class DATA >
void OutputNode< DATA >::graphCycleStartCB ( )
inlinefinaloverrideprotectedvirtual

Function called by the Computational Graph at the beginning of a new execution cycle.

Reimplemented from ComputationalNode.

◆ publishFromCache()

template<class DATA >
bool OutputNode< DATA >::publishFromCache ( )
inline

◆ sendBatchMsg()

template<class DATA >
virtual void OutputNode< DATA >::sendBatchMsg ( const std::string &  id,
const std::vector< const DATA * > &  data 
)
protectedpure virtual

Sends out a vector of msg as a single batch, to be implemented by derived classes.

Implemented in OutputDummy, OutputSpinnakerNode, OutputROSNode< MSG_TYPE >, OutputMQTTNode< MSG_TYPE >, and OutputMQTTNode< DataPack< MSG_TYPE > * >.

◆ sendMsgs()

template<class DATA >
void OutputNode< DATA >::sendMsgs ( const std::string &  id)
inlineprotected

Sends all msgs stored in _storedMsgs['id'] and clears the storage.

◆ sendSingleMsg()

template<class DATA >
virtual void OutputNode< DATA >::sendSingleMsg ( const std::string &  id,
const DATA *  data 
)
protectedpure virtual

Sends out a single msg, to be implemented by derived classes.

Implemented in OutputSpinnakerNode, OutputMQTTNode< MSG_TYPE >, OutputROSNode< MSG_TYPE >, OutputMQTTNode< DataPack< MSG_TYPE > * >, and OutputDummy.

◆ setComputePeriod()

template<class DATA >
void OutputNode< DATA >::setComputePeriod ( unsigned int  computePeriod)
inline

◆ storeMsg()

template<class DATA >
void OutputNode< DATA >::storeMsg ( const std::string &  id,
const DATA *  data 
)
inlineprotected

Stores a new msg in _storedMsgs['id'].

Friends And Related Function Documentation

◆ ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test

template<class DATA >
friend class ComputationalGraphPythonNodes_PYTHON_DECORATORS_BASIC_Test
friend

◆ ComputationalNodes_OUTPUT_NODE_Test

template<class DATA >
friend class ComputationalNodes_OUTPUT_NODE_Test
friend

Member Data Documentation

◆ _computePeriod

template<class DATA >
unsigned int OutputNode< DATA >::_computePeriod
protected

Property specifying the number of loops that passes between executions of this node.

If '_computePeriod' is 1, the node is executed every loop, if 2, every 2 loops, and so on. If 0, the node would never execute unless 'setDoCompute(true)' is called

◆ _inputPorts

template<class DATA >
std::map< std::string, std::shared_ptr<Port> > OutputNode< DATA >::_inputPorts
protected

List of ports owned by this node.

◆ _isConfigured

template<class DATA >
bool OutputNode< DATA >::_isConfigured = false
protected

true if the node has been configured, false otherwise

◆ _maxPortConnections

template<class DATA >
int OutputNode< DATA >::_maxPortConnections
protected

Maximum number of subscriptions of ports in this node.

◆ _nLoop

template<class DATA >
unsigned int OutputNode< DATA >::_nLoop = 0
protected

Variable counting the number of times this nodes has been asked to execute (1 per loop)

◆ _publishFormatPolicy

template<class DATA >
OutputNodePolicies::PublishFormatPolicy OutputNode< DATA >::_publishFormatPolicy
protected

Send policy used by this node.

◆ _publishFromCache

template<class DATA >
bool OutputNode< DATA >::_publishFromCache
protected

Publish frequency policy used by this node.

◆ _storedMsgs

template<class DATA >
std::map< std::string, std::vector<const DATA*> > OutputNode< DATA >::_storedMsgs
protected

List of msgs stored in this node.


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