NRP Core  1.4.1
OutputMQTTNode< MSG_TYPE > Class Template Reference

Output node used to connect an MQTT publisher to the computational graph. More...

#include <output_node.h>

Inheritance diagram for OutputMQTTNode< MSG_TYPE >:
OutputNode< MSG_TYPE > ComputationalNode

Public Member Functions

 OutputMQTTNode (const std::string &id, const std::string &address, bool publishFromCache=false, unsigned int computePeriod=1)
 Constructor. More...
 
std::string typeStr () const override
 Returns the node 'type' as a string. More...
 
- Public Member Functions inherited from OutputNode< MSG_TYPE >
 OutputNode (const std::string &id, OutputNodePolicies::PublishFormatPolicy publishFormatPolicy=OutputNodePolicies::PublishFormatPolicy::SERIES, bool publishFromCache=false, int maxPortConnections=0, unsigned int computePeriod=1)
 Constructor. More...
 
InputPort< T_IN, MSG_TYPE > * 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...
 
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 sendSingleMsg (const std::string &, const MSG_TYPE *data) override
 Sends out a single msg, to be implemented by derived classes. More...
 
void sendBatchMsg (const std::string &, const std::vector< const MSG_TYPE * > &) override
 Sends out a vector of msg as a single batch, to be implemented by derived classes. More...
 
template<class PUB_TYPE >
void publishMqttMsg (const PUB_TYPE *data)
 
- Protected Member Functions inherited from OutputNode< MSG_TYPE >
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 MSG_TYPE *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...
 
- 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...
 

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
 
- Protected Attributes inherited from OutputNode< MSG_TYPE >
std::map< std::string, std::shared_ptr< Port > > _inputPorts
 List of ports owned by this node. More...
 
std::map< std::string, std::vector< const MSG_TYPE * > > _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
 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
 Variable counting the number of times this nodes has been asked to execute (1 per loop) More...
 

Detailed Description

template<class MSG_TYPE>
class OutputMQTTNode< MSG_TYPE >

Output node used to connect an MQTT publisher to the computational graph.

The template parameter MSG_TYPE is the MQTT msg type this node can publish

Constructor & Destructor Documentation

◆ OutputMQTTNode()

template<class MSG_TYPE >
OutputMQTTNode< MSG_TYPE >::OutputMQTTNode ( const std::string &  id,
const std::string &  address,
bool  publishFromCache = false,
unsigned int  computePeriod = 1 
)
inline

Constructor.

Member Function Documentation

◆ publishMqttMsg()

template<class MSG_TYPE >
template<class PUB_TYPE >
void OutputMQTTNode< MSG_TYPE >::publishMqttMsg ( const PUB_TYPE *  data)
inlineprotected

◆ sendBatchMsg()

template<class MSG_TYPE >
void OutputMQTTNode< MSG_TYPE >::sendBatchMsg ( const std::string &  id,
const std::vector< const MSG_TYPE * > &  data 
)
inlineoverrideprotectedvirtual

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

Implements OutputNode< MSG_TYPE >.

◆ sendSingleMsg()

template<class MSG_TYPE >
void OutputMQTTNode< MSG_TYPE >::sendSingleMsg ( const std::string &  id,
const MSG_TYPE *  data 
)
inlineoverrideprotectedvirtual

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

Implements OutputNode< MSG_TYPE >.

◆ typeStr()

template<class MSG_TYPE >
std::string OutputMQTTNode< MSG_TYPE >::typeStr ( ) const
inlineoverridevirtual

Returns the node 'type' as a string.

Reimplemented from ComputationalNode.


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