iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::MessageBase Class Reference

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

Base class for a message that can be passed from one Module to other(s) (via a Blackboard)

  Messages are containers for data that can be sent from one Module to others even if the Modules reside on
  different machines. This is all handled by the internal machinery of the Blackboard and Module, so Message
  creators only need to do the following to make a fully functional custom Message:

 - Create a new class which inherits from nrt::MessageBase
 - Overload the description() method to return a useful description of your new message
 - Overload the serialize() method to pack and unpack your Message's internal data

 Serializing Messages:

 In order to make a message capable of being transmitted to remote Modules,
 you must define which data members need to be packaged into the byte
 stream and shipped over the wire. This is done inside of the serialize
 method using the Cereal serialization library. For example:
namespace MyNamespace
{
class MyMessage : public nrt::MessageBase
{
public:
int myData1;
std::string myData2;
template<class Archive>
inline void serialize(Archive& ar)
{
ar( myData1, myData2, myImage );
}
};
}
This method is then called whenever your message type needs to be
serialized or de-serialized, and the function call on the Archive
will either pack or unpack your data appropriately. Any data type can
be stuffed into an Archive if it has a serialize() method defined.
There is a serialize method for every C++ built-in type, all of the
STL containers, as well as most of the NRT data structures. To make
your own custom data type serializable, just define a serialize()
method like the this one.

See the Cereal library documentation for more advanced usage.

TODO: Add cereal documentation link here  
Examples:
tests/test-Module.C, and tests/test-ResultsSyntax.C.

Definition at line 160 of file Message.H.

Inheritance diagram for nrt::MessageBase:
nrt::CompositeMessage< NRT_MESSAGEFIELD(mydata2::z), NRT_MESSAGEFIELD(mydata2::md)> nrt::CompositeMessage< NRT_MESSAGEFIELD(mydata::x), NRT_MESSAGEFIELD(mydata::y), NRT_MESSAGEFIELD(mydata::s), NRT_MESSAGEFIELD(mydata::m)> nrt::CompositeMessage< NRT_MESSAGEFIELD(rgbd::maxdepth), NRT_MESSAGEFIELD(rgbd::shadow), NRT_MESSAGEFIELD(rgbd::nosample), NRT_MESSAGEFIELD(rgbd::baseline), NRT_MESSAGEFIELD(rgbd::depthfocallen), NRT_MESSAGEFIELD(rgbd::rgbfocallen)> nrt::CompositeMessage< NRT_MESSAGEFIELD(rgbd::rgb), NRT_MESSAGEFIELD(rgbd::depth), NRT_MESSAGEFIELD(rgbd::meta)> nrt::AnyMessage nrt::BBNickTrigger nrt::CompositeMessage< Fields > nrt::GetParamMessage nrt::GetParamResponseMessage nrt::GraphicsMessage nrt::LoaderSummaryMessage nrt::Message< T > nrt::ModifyModuleTopicMessage nrt::ModifyParamMessage nrt::ModifyParamResponseMessage nrt::ParamPortMessage nrt::SetStateMessage nrt::SplitPortMessage nrt::TriggerMessage

Public Member Functions

 MessageBase ()
 Constructor.
 
virtual ~MessageBase ()
 Virtual destructor for safe inheritance.
 
virtual std::string description () const
 A short description of the Message type. More...
 

Static Public Attributes

static bool const isComposite = false
 Is this message composite and can it be split into parts? More...
 

Friends

template<class Posting >
class MessagePosterCore
 
template<class Subscription >
class MessageSubscriberCore
 

Member Function Documentation

std::string nrt::MessageBase::description ( ) const
inlinevirtual

A short description of the Message type.

This is for logging purposes and does not contain any of the Message's data

Definition at line 50 of file MessageImpl.H.

References nrt::demangle().

Member Data Documentation

bool const nrt::MessageBase::isComposite = false
static

Is this message composite and can it be split into parts?

By default, Message objects are atomic entities. But see CompositeMessage for messages that can be split into their parts.

Definition at line 176 of file Message.H.


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