YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yami::value_publisher Class Reference

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...
 

Detailed Description

Simple subscription publisher.

The subscription publisher that notifies remote listeners with published value updates.

Remote listeners can subscribe and unsubscribe at any time.

Constructor & Destructor Documentation

◆ value_publisher() [1/3]

yami::value_publisher::value_publisher ( )

Constructor.

Creates the subscription publisher that is not registered at any agent.

◆ ~value_publisher()

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.

◆ value_publisher() [2/3]

template<typename functor >
yami::value_publisher::value_publisher ( functor &  f)
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.

Parameters
fThe callable entity that can accept the incoming_message as the invocation parameter.

◆ value_publisher() [3/3]

template<typename incoming_message_functor , typename queue_overflow_functor >
yami::value_publisher::value_publisher ( incoming_message_functor &  f,
std::size_t  max_queue_length,
queue_overflow_functor &  qof 
)
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.

Parameters
fThe callable entity that can accept the incoming_message as the invocation parameter.
max_queue_lengthLength of message queue for each subscriber.
qofThe callable entity that can accept the server_name, object_name and value as invocation parameters.

Member Function Documentation

◆ get_subscribers()

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.

◆ publish()

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.

Parameters
valueNew value that is to be sent as update to all listeners.
priorityThe priority of the update message.

◆ register_at()

void yami::value_publisher::register_at ( agent controlling_agent,
const std::string &  object_name 
)

Registers the publisher at the given agent.

Parameters
controlling_agentThe agent which should manage the communication for this publisher.
object_nameThe name of object that should be visible to remote subscribers.

◆ subscribe()

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.

Parameters
destination_targetTarget of the remote listener.
destination_objectName of the remote listener's object.

◆ unsubscribe()

void yami::value_publisher::unsubscribe ( const std::string &  destination_target)

Unsubscribes the given listener.

Parameters
destination_targetTarget of the remote listener.

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