10#ifndef SNBMODULES_INCLUDE_SNBMODULES_NOTIFICATION_INTERFACE_HPP_
11#define SNBMODULES_INCLUDE_SNBMODULES_NOTIFICATION_INTERFACE_HPP_
41 NotificationData(std::string source_id, std::string target_id, std::string notification, std::string data =
"")
49 std::string target_id,
51 std::string data =
"")
72 int timeout_send = 10,
73 int timeout_receive = 100)
81 std::set<std::string> client_conn,
82 const std::string& connection_prefix =
"snbmodules",
83 int timeout_send = 10,
84 int timeout_receive = 100)
90 TLOG() <<
"CCC " << __LINE__ <<
" client_conn size=" << client_conn.size();
101 const std::string& expected_from =
"",
113 const std::string& src,
114 const std::string& dst,
115 const std::string& id_conn,
116 const std::string& data =
"",
130 TLOG() <<
"LAB " << __LINE__ <<
" " <<
id.
uid <<
" " <<
id.data_type <<
" " <<
id.session;
135 TLOG() <<
"CCC " << __LINE__ <<
" adding bookkeeper conn.uid=" << conn.uid;
140 TLOG() <<
"LAB " << __LINE__;
144 TLOG() <<
"LAB " << __LINE__ <<
" " <<
id.uid <<
" " <<
id.data_type <<
" " <<
id.session;
147 TLOG() <<
"CCC " << __LINE__ <<
" adding transfer conn.uid=" << conn.uid;
152 TLOG() <<
"LAB " << __LINE__;
162 virtual inline void add_connection(
const IPFormat &ip,
const std::string &connection_name,
const std::string &data_type,
bool is_client)
168 TLOG() <<
"CCC " << __LINE__ <<
" adding connection_name=" << connection_name;
#define DUNE_DAQ_SERIALIZABLE(Type, typestring)
Macro to define a type as serializable, so it can be sent over the network.
static IOManagerWrapper & get()
iomanager::ConnectionResponse lookups_connection(const iomanager::ConnectionId &conn_id, bool restrict_single)
init IOManager instance, Only used for stand alone application
std::optional< NotificationData > listen_for_notification(const std::string &id, const std::string &expected_from="", int timeout=-1, int tries=-1)
Listen for a notification.
virtual ~NotificationInterface()=default
int m_timeout_send
Timeout for sending a notification in ms.
std::set< std::string > m_clients_conn
List of clients connections.
NotificationInterface(std::string connection_prefix="snbmodules", int timeout_send=10, int timeout_receive=100)
int m_timeout_receive
Timeout for receiving a notification in ms.
void lookups_connections()
Get the list of every connections, must have the prefix first in the name of the connection and the n...
bool send_notification(const notification_type::e_notification_type ¬if, const std::string &src, const std::string &dst, const std::string &id_conn, const std::string &data="", int tries=-1)
Send a notification during m_timeout_send ms.
const std::vector< std::string > & get_bookkeepers_conn() const
Init the connection interface, Only used for standalone application.
std::vector< std::string > m_bookkeepers_conn
List of bookkeepers connections.
virtual bool action_on_receive_notification(NotificationData notif)=0
Action to do when receiving a notification.
NotificationInterface(std::vector< std::string > bk_conn, std::set< std::string > client_conn, const std::string &connection_prefix="snbmodules", int timeout_send=10, int timeout_receive=100)
const std::set< std::string > & get_clients_conn() const
std::string m_connection_prefix
Prefix for the connection name.
std::vector< ConnectionInfo > connections
NotificationData class, represent a notification.
NotificationData(NotificationData const &)=default
NotificationData(NotificationData &&)=default
NotificationData(std::string source_id, std::string target_id, notification_type::e_notification_type notification, std::string data="")
std::string m_data
Data of the notification, can be empty.
std::string m_source_id
Source ID.
NotificationData(std::string source_id, std::string target_id, std::string notification, std::string data="")
NotificationData & operator=(NotificationData &&)=default
NotificationData & operator=(NotificationData const &)=default
std::string m_target_id
Target ID.
virtual ~NotificationData()=default
std::string m_notification
Notification type.
NotificationData()=default
DUNE_DAQ_SERIALIZE(NotificationData, m_source_id, m_target_id, m_notification, m_data)
e_notification_type
Different type of notifications possible to send.