iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::MessageSubscriberCore< Subscription > Class Template Referenceabstract

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

template<class Subscription>
class nrt::MessageSubscriberCore< Subscription >

Core class for the variadic MessageSubscriber template.

Definition at line 56 of file Blackboard.H.

Inheritance diagram for nrt::MessageSubscriberCore< Subscription >:
nrt::ModuleBase nrt::MessageSubscriberCoreBase

Public Types

typedef Subscription SubscriptionType
 Our underlying subscription type (used by Connectors)
 
typedef Subscription InPtr
 Type used for incoming messages in onMessage. More...
 
typedef Subscription::RetUptr OutPtr
 Type that onMessage() returns (typically, void or std::unique_ptr<ReturnMessageType>)
 

Public Member Functions

 MessageSubscriberCore ()
 Constructor, will register this subscriber with the Blackboard.
 
virtual ~MessageSubscriberCore ()
 Virtual destructor for safe inheritance, will un-register this subscriber with the Blackboard.
 
virtual void createSubSubscribers ()
 Create our split sub-ports.
 
virtual void deleteSubSubscribers ()
 Delete our split sub-ports.
 
virtual bool isSplit () const
 Return true if we currently have split-sub-subscribers.
 
template<typename... Args>
OutPtr make_return_message (Args &&...args) const
 Allocate a return message and return a unique_ptr to it, to be used in a callback as return value. More...
 
std::string make_connector (std::string const &name, std::string const &namespc, nrt::ConnectorType const type, std::string const &topic, std::string const &topicfilter) const
 Create a connector for this port's Checking type on the master Blackboard. More...
 
template<typename... Args>
nrt::MessageSubscriberCore
< Subscription >::OutPtr 
make_return_message (Args &&...args) const
 
- Public Member Functions inherited from nrt::ModuleBase
 ModuleBase ()
 Constructor.
 
virtual ~ModuleBase ()
 Virtual destructor for safe inheritance.
 
ModuleUID const & uid () const
 Get our unique ID which will be used to track Module objects in distributed systems.
 
std::string getNamespace () const
 Get the module's namespace. More...
 
void setLogicalPath (std::string const &lp)
 Set the logical path for this module, as categ/subcat/.../classname. More...
 
std::string getLogicalPath () const
 Get the logical path for this module, as categ/subcat/.../classname.
 
- Public Member Functions inherited from nrt::MessageSubscriberCoreBase
virtual ~MessageSubscriberCoreBase ()
 Virtual destructor for safe inheritance.
 
void setTopicFilter (std::string const &topicfilt_)
 Set the TopicFilter for this subscriber. More...
 

Protected Member Functions

virtual OutPtr onMessage (InPtr msg)=0
 Callback called by the Blackboard when a relevant Message is posted. More...
 
 MessageSubscriberCore (std::string const &mod, std::string const &portna, std::string const &descr)
 Special constructor used only by dynamic ports (Parameter, split subscribers, etc)
 
virtual void notifySplitReceive (size_t const bitnum)
 Notification called by each sub-subscriber when it receives a split field.
 
virtual void abortSplitReceive ()
 Order to abort a split receive, e.g., upon destruction or stop()
 

Friends

class nrt::Blackboard
 
template<class T >
class nrt::ParameterCore
 

Additional Inherited Members

- Protected Attributes inherited from nrt::ModuleBase
boost::shared_mutex itsNamespaceMtx
 
std::string namespc
 
std::string logicalpath
 
- Protected Attributes inherited from nrt::MessageSubscriberCoreBase
std::string msgtype
 Type of Message we subscribe to.
 
std::string rettype
 Type of Message we return from our callback.
 
std::string module
 Module which we belong to.
 
std::string portname
 String name for our Subscription port class.
 
std::string description
 String human description for our Subscription.
 
std::string topicfilt
 TopicFilter that we subscribe to.
 
int sequence
 Subscriber sequence number within module used for ordering of ports in the GUI.
 
bool splittable
 Can this port be split into sub-ports?
 
boost::shared_mutex mtx
 
std::shared_ptr
< nrt::MessageSubscriberCallbackWrapperBase > 
callbackWrapperBase
 
std::shared_ptr
< nrt::MessageSubscriberCallbackWrapperBase > 
callbackAnyWrapperBase
 

Member Typedef Documentation

template<class Subscription>
typedef Subscription nrt::MessageSubscriberCore< Subscription >::InPtr

Type used for incoming messages in onMessage.

We just use Subscription and allow people to manipulate Subscription objects just as if they were shared_ptr to messages. This is so that we can define onMessage() with just one argument instead of 2 somewhet redundant ones.

Definition at line 1096 of file ModulePortHelpers.H.

Member Function Documentation

template<class Subscription>
template<typename... Args>
OutPtr nrt::MessageSubscriberCore< Subscription >::make_return_message ( Args &&...  args) const

Allocate a return message and return a unique_ptr to it, to be used in a callback as return value.

All given args are forwarded to the return message constructor.

template<class Subscription >
std::string nrt::MessageSubscriberCore< Subscription >::make_connector ( std::string const &  name,
std::string const &  namespc,
nrt::ConnectorType const  type,
std::string const &  topic,
std::string const &  topicfilter 
) const
inline

Create a connector for this port's Checking type on the master Blackboard.

Returns
The connector uid. This is the only way to "access" the connector, as it lives hidden deep inside the master Blackboard. The Blackboard class exposes functions that allow one to set connector topics, etc using the connector uid to address a particular connector.

Beware of the order of the topic and topicfilter arguments as they differ between the poster checker and subscriber version of make_connector. Think of the first one as directly connected to the physical port, and the other one as the other end of the connector.

Definition at line 1067 of file ModulePortImpl.H.

References nrt::Singleton< T >::instance(), and nrt::Subscriber.

template<class Subscription>
virtual OutPtr nrt::MessageSubscriberCore< Subscription >::onMessage ( InPtr  msg)
protectedpure virtual

Callback called by the Blackboard when a relevant Message is posted.

Derived classes must implement this function.

Implemented in nrt::SplitMessageSubscriber< T, false >, and nrt::SplitMessageSubscriber< T, true >.


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