iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::MessagePosting< Port, Msg, Ret > Class Template Reference

#include <nrt/Core/Blackboard/details/ModulePortHelpers.H>

template<class Port, class Msg, class Ret>
class nrt::MessagePosting< Port, Msg, Ret >

A Posting port is a unique binding of a sent Message type and a returned Message type to a port class.

Module objects can post() on a given Posting port if and only if they derive from the corresponding MessagePoster of the Posting. Typically, Msg and Ret should derive from nrt::MessageBase, with a special case allowed for Ret being void. See MessagePoster for how to use post(). A convenience macro is provided (in details/ModulePortHelpers.H) to easily declare a posting class:

Where PortName is the name of the class that will embody your Posting port, MsgType is the type of posted message (must derive from nrt::MessageBase), RetType is the type of message returned by any subscriber (callback) that will respond to posts on this Posting (must derive from nrt::MessageBase or be void), and Description is a plain C-style string describing your Posting. For example:

class MessageA : public nrt::MessageBase { }; // define some message type A
NRT_DECLARE_MESSAGEPOSTER_PORT(OutputA, MessageA, void, "MessageA Output"); // Our port is named OutputA

The reason for declaring a new Posting type is to allow one to have several postings with identical message and return types, but different descriptions and port classes. Although these deal with identical messages, they may post in different namespaces and on different topics (see the definition of MessagePoster) and thus achieve different functions.

Definition at line 143 of file ModulePortHelpers.H.

Public Types

typedef Port PortType
typedef Msg MsgType
 The outgoing message type.
typedef Ret RetType
 The return message type.
typedef std::unique_ptr< Msg > MsgUptr
 Outgoing message pointer type, as passed to post()
typedef std::shared_ptr< Msg
const > 
 Outgoing message pointer type, as received by callbacks.
typedef std::unique_ptr< Ret > RetUptr
 Return message pointer type, as returned by callback.
typedef std::shared_ptr< Ret
const > 
 Return message pointer type, as received back by poster.
typedef std::function< RetPtr(MsgPtr)> CallbackFuncType
 Callback function type.

Public Member Functions

template<typename... Args>
nrt::MessagePosting< Port, Msg,
Ret >::MsgUptr 
make_message (Args &&...args)

Static Public Member Functions

template<typename... Args>
static MsgUptr make_message (Args &&...args)
 Allocate a message and return a unique_ptr to it, to be used by post() More...

Static Public Attributes

static bool const isSplittable = false
 Postings with non-void returns cannot be split.


template<class Posting >
class MessagePosterCore

Member Function Documentation

template<class Port, class Msg, class Ret>
template<typename... Args>
static MsgUptr nrt::MessagePosting< Port, Msg, Ret >::make_message ( Args &&...  args)

Allocate a message and return a unique_ptr to it, to be used by post()

All given args are forwarded to the message constructor.

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