23#ifndef IPM_INCLUDE_IPM_RECEIVER_HPP_
24#define IPM_INCLUDE_IPM_RECEIVER_HPP_
26#include "cetlib/BasicPluginFactory.h"
27#include "cetlib/compiler_macros.h"
30#include "nlohmann/json.hpp"
40ERS_DECLARE_ISSUE(ipm, KnownStateForbidsReceive,
"Receiver not in a state to receive data", )
42 UnexpectedNumberOfBytes,
43 "Expected " << bytes1 << " bytes in message but received " << bytes2,
44 ((
int)bytes1)((
int)bytes2))
47 "Unable to receive within timeout
period (timeout
period was " << timeout << " milliseconds)",
52#ifndef EXTERN_C_FUNC_DECLARE_START
54#define EXTERN_C_FUNC_DECLARE_START \
64#define DEFINE_DUNE_IPM_RECEIVER(klass) \
65 EXTERN_C_FUNC_DECLARE_START \
66 std::shared_ptr<dunedaq::ipm::Receiver> make() { return std::shared_ptr<dunedaq::ipm::Receiver>(new klass()); } \
77 static constexpr duration_t s_no_block = duration_t::zero();
97 std::string metadata{
"" };
98 std::vector<char> data{};
101 Response receive(
const duration_t& timeout, message_size_t num_bytes = s_any_size,
bool no_tmoexcept_mode =
false);
114 void generate_opmon_data()
override ;
119 mutable std::atomic<size_t> m_bytes = { 0 };
120 mutable std::atomic<size_t> m_messages = { 0 };
123inline std::shared_ptr<Receiver>
126 static cet::BasicPluginFactory bpf(
"duneIPM",
"make");
127 return bpf.makePlugin<std::shared_ptr<Receiver>>(plugin_name);
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
Receiver(const Receiver &)=delete
virtual void unregister_callback()=0
virtual ~Receiver()=default
std::chrono::milliseconds duration_t
Receiver(Receiver &&)=delete
Receiver & operator=(const Receiver &)=delete
virtual std::string connect_for_receives(const nlohmann::json &connection_info)=0
Receiver & operator=(Receiver &&)=delete
virtual Response receive_(const duration_t &timeout, bool no_tmoexcept_mode)=0
virtual bool can_receive() const noexcept=0
virtual void register_callback(std::function< void(Response &)>)=0
An ERS Error indicating that an exception was thrown from ZMQ while performing an operation.
std::shared_ptr< Receiver > make_ipm_receiver(std::string const &plugin_name)
Unable to receive within timeout period(timeout period was " << timeout << " milliseconds)"