|
YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
|
Simple subscription publisher. More...
#include <value_publisher.h>
Public Member Functions | |
| value_publisher () | |
| Constructor. More... | |
| ~value_publisher () | |
| Destructor. More... | |
| template<typename functor > | |
| value_publisher (functor &f) | |
| Constructor. More... | |
| 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. More... | |
| void | register_at (agent &controlling_agent, const std::string &object_name) |
| Registers the publisher at the given agent. More... | |
| 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. More... | |
| void | unsubscribe (const std::string &destination_target) |
| Unsubscribes the given listener. More... | |
| void | publish (const serializable &value, std::size_t priority=0) |
| Publishes the new value. More... | |
| 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. More... | |
Simple subscription publisher.
The subscription publisher that notifies remote listeners with published value updates.
Remote listeners can subscribe and unsubscribe at any time.
| yami::value_publisher::value_publisher | ( | ) |
Constructor.
Creates the subscription publisher that is not registered at any agent.
| yami::value_publisher::~value_publisher | ( | ) |
Destructor.
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.
|
inline |
Constructor.
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. |
|
inline |
Constructor.
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. |
| std::vector< std::pair< std::string, std::string > > yami::value_publisher::get_subscribers | ( | ) | const |
Returns the information about all active subscribers.
The first component of each vector entry is a destination target and the second component is a destination object for the given subscriber.
| void yami::value_publisher::publish | ( | const serializable & | value, |
| std::size_t | priority = 0 |
||
| ) |
Publishes the new value.
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. |
| void yami::value_publisher::register_at | ( | agent & | controlling_agent, |
| const std::string & | object_name | ||
| ) |
Registers the publisher at the given agent.
| 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 yami::value_publisher::subscribe | ( | const std::string & | destination_target, |
| const std::string & | destination_object | ||
| ) |
Subscribes the new listener.
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 yami::value_publisher::unsubscribe | ( | const std::string & | destination_target | ) |
Unsubscribes the given listener.
| destination_target | Target of the remote listener. |