NRP Core  1.4.1
InputNode< DATA > Class Template Referenceabstract

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

#include <input_node.h>

Inheritance diagram for InputNode< DATA >:
ComputationalNode

Public Member Functions

 InputNode (const std::string &id, InputNodePolicies::MsgPublishPolicy msgPublishPolicy=InputNodePolicies::MsgPublishPolicy::LAST, InputNodePolicies::MsgCachePolicy msgCachePolicy=InputNodePolicies::MsgCachePolicy::KEEP_CACHE, size_t queue_size=10)
 Constructor. More...
 
void registerOutput (const std::string &id)
 Registers an Output port with id 'id' with this node. More...
 
OutputPort< DATA > * getSinglePort (const std::string &id)
 Returns a pointer to single output port if the port is registered, nullptr otherwise. More...
 
OutputPort< std::vector< const DATA * > > * getListPort (const std::string &id)
 Returns a pointer to list output port if the port is registered, nullptr otherwise. More...
 
InputNodePolicies::MsgPublishPolicy msgPublishPolicy ()
 
InputNodePolicies::MsgCachePolicy msgCachePolicy ()
 
void setMsgPublishPolicy (InputNodePolicies::MsgPublishPolicy msgPublishPolicy)
 
void setMsgCachePolicy (InputNodePolicies::MsgCachePolicy msgCachePolicy)
 
- 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...
 
virtual bool doCompute () const
 Tells if this node should be executed in this graph execution cycle, used in some graph execution modes. More...
 

Protected Member Functions

void compute () override final
 Compute. Updates and sends stored msgs. More...
 
virtual bool updatePortData (const std::string &id)=0
 Updates pointers stored in _portMap for port 'id'. More...
 
- Protected Member Functions inherited from ComputationalNode
virtual void configure ()=0
 Configures the node making it ready to execute 'compute'. More...
 
virtual void graphCycleStartCB ()
 Function called by the Computational Graph at the beginning of a new execution cycle. More...
 
virtual void graphLoadedCB ()
 Function called by the Computational Graph to nodes that the graph has been completely loaded. More...
 

Protected Attributes

InputNodePolicies::MsgPublishPolicy _msgPublishPolicy
 Send policy used by this node. More...
 
InputNodePolicies::MsgCachePolicy _msgCachePolicy
 Msg cache policy used by this node. More...
 
std::map< std::string, DataPortHandle< DATA > > _portMap
 Map containing data to handle topics. Data is guaranteed to be unchanged between 'compute' calls
More...
 
size_t _queueSize
 Maximum number of msgs that the node can store per port. More...
 

Friends

class ComputationalNodes_INPUT_NODE_UPDATE_POLICY_WITH_KEEP_CACHE_Test
 
class ComputationalNodes_INPUT_NODE_UPDATE_POLICY_WITH_CLEAR_CACHE_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 InputNode< DATA >

Implementation of an input node in the computation graph.

Input nodes are the connection points to feed data into the computation graph from outside. It owns output ports which are used to forward incoming data to other nodes. One node can handle multiple ports. The class is templated with the data type the node can handle. Each node implementation can handle only one data type.

Derived classes of InputNode remains responsible for the ownership of the data passed to InputNode through the updatePortData() virtual method.

Constructor & Destructor Documentation

◆ InputNode()

template<class DATA >
InputNode< DATA >::InputNode ( const std::string &  id,
InputNodePolicies::MsgPublishPolicy  msgPublishPolicy = InputNodePolicies::MsgPublishPolicy::LAST,
InputNodePolicies::MsgCachePolicy  msgCachePolicy = InputNodePolicies::MsgCachePolicy::KEEP_CACHE,
size_t  queue_size = 10 
)
inline

Constructor.

Member Function Documentation

◆ compute()

template<class DATA >
void InputNode< DATA >::compute ( )
inlinefinaloverrideprotectedvirtual

Compute. Updates and sends stored msgs.

Implements ComputationalNode.

◆ getListPort()

template<class DATA >
OutputPort<std::vector<const DATA*> >* InputNode< DATA >::getListPort ( const std::string &  id)
inline

Returns a pointer to list output port if the port is registered, nullptr otherwise.

◆ getSinglePort()

template<class DATA >
OutputPort<DATA>* InputNode< DATA >::getSinglePort ( const std::string &  id)
inline

Returns a pointer to single output port if the port is registered, nullptr otherwise.

◆ msgCachePolicy()

template<class DATA >
InputNodePolicies::MsgCachePolicy InputNode< DATA >::msgCachePolicy ( )
inline

◆ msgPublishPolicy()

template<class DATA >
InputNodePolicies::MsgPublishPolicy InputNode< DATA >::msgPublishPolicy ( )
inline

◆ registerOutput()

template<class DATA >
void InputNode< DATA >::registerOutput ( const std::string &  id)
inline

Registers an Output port with id 'id' with this node.

◆ setMsgCachePolicy()

template<class DATA >
void InputNode< DATA >::setMsgCachePolicy ( InputNodePolicies::MsgCachePolicy  msgCachePolicy)
inline

◆ setMsgPublishPolicy()

template<class DATA >
void InputNode< DATA >::setMsgPublishPolicy ( InputNodePolicies::MsgPublishPolicy  msgPublishPolicy)
inline

◆ updatePortData()

template<class DATA >
virtual bool InputNode< DATA >::updatePortData ( const std::string &  id)
protectedpure virtual

Updates pointers stored in _portMap for port 'id'.

Expected behavior: Implementations of this function must guarantee that data pointers stored in _portMap[id] are valid and will not change between calls to this function. Even after the function is called again, pointers in _portMap[id] should still be valid and remain unchanged if the function returns false, i.e., if port 'id' data wasn't changed.

Parameters
idkey in _portMap which data is asked to be updated
Returns
true if port 'id' has new data, false otherwise

Implemented in InputMQTTNode< MSG_TYPE >, InputMQTTNode< DataPack< MSG_TYPE > >, InputSpinnakerNode, InputROSNode< MSG_TYPE >, InputEngineNode, InputTimeBaseNode, and InputDummy.

Friends And Related Function Documentation

◆ ComputationalNodes_INPUT_NODE_UPDATE_POLICY_WITH_CLEAR_CACHE_Test

template<class DATA >
friend class ComputationalNodes_INPUT_NODE_UPDATE_POLICY_WITH_CLEAR_CACHE_Test
friend

◆ ComputationalNodes_INPUT_NODE_UPDATE_POLICY_WITH_KEEP_CACHE_Test

template<class DATA >
friend class ComputationalNodes_INPUT_NODE_UPDATE_POLICY_WITH_KEEP_CACHE_Test
friend

Member Data Documentation

◆ _msgCachePolicy

template<class DATA >
InputNodePolicies::MsgCachePolicy InputNode< DATA >::_msgCachePolicy
protected

Msg cache policy used by this node.

◆ _msgPublishPolicy

template<class DATA >
InputNodePolicies::MsgPublishPolicy InputNode< DATA >::_msgPublishPolicy
protected

Send policy used by this node.

◆ _portMap

template<class DATA >
std::map<std::string, DataPortHandle<DATA> > InputNode< DATA >::_portMap
protected

Map containing data to handle topics. Data is guaranteed to be unchanged between 'compute' calls

◆ _queueSize

template<class DATA >
size_t InputNode< DATA >::_queueSize
protected

Maximum number of msgs that the node can store per port.


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