![]() |
4S Device Communication Module Collection
Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
|
|
Class enabling other classes to send messages. More...
#include <msgsender.h>
Public Member Functions | |
template<class T > | |
void | broadcast (T &msg) |
Template function to broadcast messages. More... | |
template<class T > | |
void | respond (T &msg, BaseMsg &received) |
Template function to respond to messages. More... | |
template<class T > | |
void | send (T &msg, const MsgAddr &destination) |
![]() | |
MsgAddrGenerator (void) | |
Constructor that creates an address. | |
operator MsgAddr & () | |
MsgAddr operator for type conversion of MsgAddrGenerator to a MsgAddr. More... | |
Additional Inherited Members | |
![]() | |
void | broadcast (std::shared_ptr< BaseMsg > &msg, const std::type_info &typeOfMsg, const MsgAddr &sender) |
Broadcast function, to broadcast messages. More... | |
void | send (std::shared_ptr< BaseMsg > &msg, const std::type_info &typeOfMsg, const FSYS::MsgAddr &sender, const MsgAddr &destination) |
Type independent respond function. More... | |
When inheriting from this class it becomes possible for the class inheriting to send all types of messages.
There are two ways to send messages, either as broadcasts or as responses to other messages.
Broadcasts will be send to all instances of classes that listen to the specific type of message.
Responses will only go the the instance of the class that sended the message that is given in the argument to the respond function.
For a class to be considered as a receiver of a message, the class needs to be instantiated at the time when the message was sent.
|
inline |
When a message is broadcasted it will be received by all classes listening on the specific message type at the time the message was sent.
msg | The message that should be sent |
|
inline |
When a message is recevied it is possible for at class to send a message back to the sender and only the sender. To do this you use the respond function.
You can use the respond function and another message to send several messages to the sender of that message.
A common use case for a flow where the respond function is used is: