5#ifndef YAMICPP_AGENT_H_INCLUDED
6#define YAMICPP_AGENT_H_INCLUDED
8#include "agent_impl_base.h"
9#include "connection_event_generic_dispatcher.h"
10#include "event_callback.h"
11#include "incoming_message_generic_dispatcher.h"
12#include "io_error_generic_dispatcher.h"
13#include "outgoing_message.h"
14#include "outgoing_message_generic_dispatcher.h"
15#include "parameters.h"
16#include <yami4-core/dll.h>
115 template <
typename functor>
118 std::unique_ptr<details::incoming_message_dispatcher_base> object(
121 pimpl_base_->register_object(object_name,
object);
124 void register_raw_object(
const std::string & object_name,
218 std::unique_ptr<outgoing_message>
send(
219 const std::string & target,
220 const std::string & object_name,
221 const std::string & message_name,
223 std::size_t priority = 0,
224 bool auto_connect =
true);
235 const std::string & target,
236 const std::string & object_name,
237 const std::string & message_name,
239 std::size_t priority = 0,
240 bool auto_connect =
true);
252 template <
typename functor>
255 const std::string & target,
256 const std::string & object_name,
257 const std::string & message_name,
259 std::size_t priority = 0,
260 bool auto_connect =
true)
262 std::unique_ptr<details::outgoing_message_dispatcher_base>
263 outgoing_message_callback(
266 return pimpl_base_->send(outgoing_message_callback,
267 target, object_name, message_name,
268 content, priority, auto_connect);
297 std::unique_ptr<outgoing_message>
send(
298 const std::string & target,
302 std::size_t priority = 0,
303 bool auto_connect =
true);
314 const std::string & target,
318 std::size_t priority = 0,
319 bool auto_connect =
true);
331 template <
typename functor>
334 const std::string & target,
338 std::size_t priority = 0,
339 bool auto_connect =
true)
341 std::unique_ptr<details::outgoing_message_dispatcher_base>
342 outgoing_message_callback(
345 pimpl_base_->send(outgoing_message_callback,
346 target, header, content, message_id,
347 priority, auto_connect);
370 std::size_t priority = 0,
371 bool auto_connect =
true);
381 const std::string & object_name,
382 const std::string & message_name,
384 std::size_t priority = 0,
385 bool auto_connect =
true);
405 std::size_t priority = 0);
430 template <
typename functor>
433 std::unique_ptr<details::connection_event_dispatcher_base> monitor(
436 pimpl_base_->register_connection_event_monitor(monitor);
451 template <
typename functor>
454 std::unique_ptr<details::io_error_dispatcher_base> logger(
457 pimpl_base_->register_io_error_logger(logger);
472 std::size_t & high_water_mark, std::size_t & low_water_mark)
const;
518 void operator=(
const agent &);
520 details::agent_impl * pimpl_;
Message broker.
Definition: agent.h:45
void register_object(const std::string &object_name, functor &f)
Registers the new logical destination object.
Definition: agent.h:116
void register_connection_event_monitor(functor &f)
Registers the monitor for connection-related events.
Definition: agent.h:431
void remove_listener(const std::string &listener)
Removes existing listener.
void register_io_error_logger(functor &f)
Registers the logger for I/O errors.
Definition: agent.h:452
std::unique_ptr< outgoing_message > send(const std::string &target, const std::string &object_name, const std::string &message_name, const serializable &content=parameters(), std::size_t priority=0, bool auto_connect=true)
Sends the new outgoing message.
void send_one_way(const std::string &target, const std::string &object_name, const std::string &message_name, const serializable &content=parameters(), std::size_t priority=0, bool auto_connect=true)
Sends the new outgoing message with custom header.
void send(functor &f, const std::string &target, const serializable &header, const serializable &content, outgoing_message_id message_id, std::size_t priority=0, bool auto_connect=true)
Sends the outgoing message with a custom header.
Definition: agent.h:332
void send_one_way(const std::string &target, const serializable &header, const serializable &content, outgoing_message_id message_id, std::size_t priority=0, bool auto_connect=true)
Sends the new outgoing message.
void close_connection(const std::string &target, std::size_t priority=0)
Closes the given communication channel.
void unregister_object(const std::string &object_name)
Unregisters the logical destination object.
void run_worker()
Runs the internal worker activities.
agent(event_callback &event_listener, const parameters &options=parameters())
Constructor.
long long outgoing_message_id
Outgoing message identifier type.
Definition: agent.h:49
outgoing_message_id get_next_message_id()
Obtains unique message id.
std::size_t get_pending_outgoing_bytes(const std::string &target)
Returns the size of outgoing queue for the given channel.
agent(const parameters &options=parameters())
Constructor.
void get_outgoing_flow_state(std::size_t ¤t_level, std::size_t &high_water_mark, std::size_t &low_water_mark) const
Obtains the state of overall outgoing flow.
void get_channel_usage(std::size_t &max_allowed, std::size_t &used)
Returns the selector's channel usage counters.
void hard_close_connection(const std::string &target)
Immediately closes the given communication channel.
void register_value_publisher(const std::string &object_name, value_publisher &publisher)
Registers the value publisher as a new logical object.
void open_connection(const std::string &target)
Opens the new connection.
void clean_outgoing_message_callback(outgoing_message_id id)
Cleans internal resources for the given message callback.
outgoing_message_id send(functor &f, const std::string &target, const std::string &object_name, const std::string &message_name, const serializable &content=parameters(), std::size_t priority=0, bool auto_connect=true)
Sends the outgoing message.
Definition: agent.h:253
std::unique_ptr< outgoing_message > send(const std::string &target, const serializable &header, const serializable &content, outgoing_message_id message_id, std::size_t priority=0, bool auto_connect=true)
Sends the new outgoing message with a custom header.
void send(outgoing_message &message, const std::string &target, const serializable &header, const serializable &content, outgoing_message_id message_id, std::size_t priority=0, bool auto_connect=true)
Sends the outgoing message with a custom header.
void open_connection(const std::string &target, const parameters &options)
Opens the new connection with overriding options.
void send(outgoing_message &message, const std::string &target, const std::string &object_name, const std::string &message_name, const serializable &content=parameters(), std::size_t priority=0, bool auto_connect=true)
Sends the outgoing message.
void run_dispatcher(std::size_t dispatcher_index)
Runs the message dispatching activities.
std::string add_listener(const std::string &listener)
Adds new listener.
Definition: agent_impl_base.h:26
Definition: connection_event_generic_dispatcher.h:20
Definition: incoming_message_generic_dispatcher.h:23
Definition: io_error_generic_dispatcher.h:19
Definition: outgoing_message_generic_dispatcher.h:22
Event notification callback interface.
Definition: event_callback.h:26
Incoming message.
Definition: incoming_message.h:37
Outgoing message.
Definition: outgoing_message.h:33
Collection of message parameters.
Definition: parameters.h:62
Common interface for serializable data source.
Definition: serializable.h:21
Simple subscription publisher.
Definition: value_publisher.h:36
Namespace devoted to everything related to YAMI4.
Definition: agent.h:21