23#ifndef IPM_INCLUDE_IPM_SENDER_HPP_
24#define IPM_INCLUDE_IPM_SENDER_HPP_
26#include "cetlib/BasicPluginFactory.h"
27#include "cetlib/compiler_macros.h"
30#include "nlohmann/json.hpp"
40ERS_DECLARE_ISSUE(ipm, KnownStateForbidsSend,
"Sender not in a state to send data", )
41ERS_DECLARE_ISSUE(ipm, NullPointerPassedToSend, "An null pointer to memory was passed to Sender::send", )
44 "Unable to send within timeout
period (timeout
period was " << timeout << " milliseconds)",
50#ifndef EXTERN_C_FUNC_DECLARE_START
52#define EXTERN_C_FUNC_DECLARE_START \
62#define DEFINE_DUNE_IPM_SENDER(klass) \
63 EXTERN_C_FUNC_DECLARE_START \
64 std::shared_ptr<dunedaq::ipm::Sender> make() { return std::shared_ptr<dunedaq::ipm::Sender>(new klass()); } \
75 static constexpr duration_t s_no_block = duration_t::zero();
91 bool send(const
void* message,
94 std::
string const& metadata = "",
95 bool no_tmoexcept_mode = false);
105 void generate_opmon_data() override;
107 virtual
bool send_(const
void* message,
110 std::
string const& metadata,
111 bool no_tmoexcept_mode) = 0;
114 mutable
std::atomic<
size_t> m_bytes = { 0 };
115 mutable std::atomic<size_t> m_messages = { 0 };
118inline std::shared_ptr<Sender>
121 static cet::BasicPluginFactory bpf(
"duneIPM",
"make");
122 return bpf.makePlugin<std::shared_ptr<Sender>>(plugin_name);
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
std::chrono::milliseconds duration_t
virtual ~Sender()=default
virtual std::string connect_for_sends(const nlohmann::json &connection_info)=0
virtual bool can_send() const noexcept=0
An ERS Error indicating that an exception was thrown from ZMQ while performing an operation.
std::shared_ptr< Sender > make_ipm_sender(std::string const &plugin_name)
Unable to receive within timeout period(timeout period was " << timeout << " milliseconds)"