YAMI4 - C++ general-purpose interface
|
Simple subscription publisher. More...
#include <value_publisher.h>
Public Member Functions | |
value_publisher () | |
Constructor. | |
~value_publisher () | |
Destructor. | |
template<typename functor > | |
value_publisher (functor &f) | |
Constructor. | |
template<typename incoming_message_functor , typename queue_overflow_functor > | |
value_publisher (incoming_message_functor &f, std::size_t max_queue_length, queue_overflow_functor &qof) | |
Constructor. | |
void | register_at (agent &controlling_agent, const std::string &object_name) |
Registers the publisher at the given agent. | |
void | unregister () |
Unregisters the publisher from its associated agent. | |
void | subscribe (const std::string &destination_target, const std::string &destination_object) |
Subscribes the new listener. | |
void | unsubscribe (const std::string &destination_target) |
Unsubscribes the given listener. | |
void | publish (const serializable &value, std::size_t priority=0) |
Publishes the new value. | |
std::size_t | get_number_of_subscribers () const |
Returns the number of active subscribers. | |
std::vector< std::pair < std::string, std::string > > | get_subscribers () const |
Returns the information about all active subscribers. |
The subscription publisher that notifies remote listeners with published value updates.
Remote listeners can subscribe and unsubscribe at any time.
value_publisher::value_publisher | ( | ) |
Creates the subscription publisher that is not registered at any agent.
value_publisher::~value_publisher | ( | ) |
Note: The destructor automatically unregisters the publisher from the agent it was registered at, which might cause hazards if some updates are pending in the incoming message queue.
yami::value_publisher::value_publisher | ( | functor & | f | ) | [inline] |
Creates the subscription publisher that is not registered at any agent and that has a handler for arbitrary remote commands.
Note: The "subscribe" and "unsubscribe" messages are also forwarded to the user-provided callback, but these two messages are already "replied-to" by the publisher's implementation.
f | The callable entity that can accept the incoming_message as the invocation parameter. |
yami::value_publisher::value_publisher | ( | incoming_message_functor & | f, |
std::size_t | max_queue_length, | ||
queue_overflow_functor & | qof | ||
) | [inline] |
Creates the subscription publisher that is not registered at any agent and that has a handler for arbitrary remote commands as well as for the queue overflow conditions.
Note: The "subscribe" and "unsubscribe" messages are also forwarded to the user-provided callback, but these two messages are already processed by the publisher's implementation.
f | The callable entity that can accept the incoming_message as the invocation parameter. |
max_queue_length | Length of message queue for each subscriber. |
qof | The callable entity that can accept the server_name , object_name and value as invocation parameters. |
void value_publisher::register_at | ( | agent & | controlling_agent, |
const std::string & | object_name | ||
) |
controlling_agent | The agent which should manage the communication for this publisher. |
object_name | The name of object that should be visible to remote subscribers. |
void value_publisher::subscribe | ( | const std::string & | destination_target, |
const std::string & | destination_object | ||
) |
This function is usually called internally as a result of processing the remote "subscribe" message, but can be also used locally if the listener's location is obtained via other means.
destination_target | Target of the remote listener. |
destination_object | Name of the remote listener's object. |
void value_publisher::unsubscribe | ( | const std::string & | destination_target | ) |
destination_target | Target of the remote listener. |
void value_publisher::publish | ( | const serializable & | value, |
std::size_t | priority = 0 |
||
) |
Sends the update message to all active listeners with the given value. In case of any errors or communication problems, the problematic listener is automatically unsubscribed.
value | New value that is to be sent as update to all listeners. |
priority | The priority of the update message. |
std::vector< std::pair< std::string, std::string > > value_publisher::get_subscribers | ( | ) | const |
The first component of each vector entry is a destination target and the second component is a destination object for the given subscriber.