iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::MessageSubscriber< Subscriber, Tail...> Class Template Reference

#include <nrt/Core/Blackboard/Module.H>

template<class Subscriber, class... Tail>
class nrt::MessageSubscriber< Subscriber, Tail...>

Module objects which derive from nrt::MessageSubscriber<Subscriber> will subscribe to matching Posters.

This interface exposes an onMessage() callback function for the Message type and return type of the Subscriber. Module objects that virtually derive from MessageSubscriber will see their onMessage() function called back by the Blackboard each time a relevant Message is post()'ed, either locally or by a remote poster. Classes deriving from nrt::MessageSubscriber<Subscriber> must implement the onMessage() pure virtual function. Note that onMessage() is defined deeper (in MessageSubscriberCore), and takes the following syntax:

virtual typename Subscriber::RetPtr onMessage(Subscriber::InPtr msg) = 0;

This onMessage() function must be implemented by Module objects which derive from MessageSubscriber<Subscriber>.

To allow perfect forwarding of exceptions, designers of onMessage() functions should take care to only throw nrt::exception::ModuleException, or possibly forward any caught nrt::exception::BlackboardException (e.g., if you post() something within your onMessage()::InPtr function). Indeed, if any other exception is thrown, it will be caught by the Blackboard but will then be wrapped into an nrt::exception::ModuleException which will not be very descriptive to the recipient. The reason for this is that we must know how to serialize exceptions so that we can send them back to remote posters, which we cannot do in general but we can do for nrt::exception::ModuleException and nrt::exception::BlackboardException.

Definition at line 151 of file Module.H.

Inheritance diagram for nrt::MessageSubscriber< Subscriber, Tail...>:
nrt::MessageSubscriber< Tail...>

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