DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TriggerRecordHeader_serialization.hpp
Go to the documentation of this file.
1
9#ifndef DFMESSAGES_INCLUDE_DFMESSAGES_TRIGGERRECORDHEADER_SERIALIZATION_HPP_
10#define DFMESSAGES_INCLUDE_DFMESSAGES_TRIGGERRECORDHEADER_SERIALIZATION_HPP_
11
14#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
15
16#include <vector>
17
18namespace dunedaq {
19// Disable coverage collection LCOV_EXCL_START
20ERS_DECLARE_ISSUE(dfmessages,
21 CannotDeserializeTriggerRecordHeader,
22 "Cannot deserialize TriggerRecordHeader from JSON due to type mismatch", )
23// Re-enable coverage collection LCOV_EXCL_STOP
24} // namespace dunedaq
25
26// MsgPack serialization functions (which just put the raw bytes of
27// the fragment array into a MsgPack message)
28namespace msgpack {
29MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
30{
31 namespace adaptor {
32
33 template<>
34 struct pack<dunedaq::daqdataformats::TriggerRecordHeader>
35 {
36 template<typename Stream>
37 packer<Stream>& operator()(msgpack::packer<Stream>& o,
39 {
40 size_t size = trh.get_total_size_bytes();
41 o.pack_bin(size); // pack header and size
42 o.pack_bin_body(static_cast<const char*>(trh.get_storage_location()), size); // pack payload
43 return o;
44 }
45 };
46
47 // Typically we use convert<> for deserialization, but TriggerRecordHeader isn't
48 // default constructible, so we have to use as<>. See:
49 // https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_adaptor#non-default-constructible-class-support-c11-only-since-120
50 template<>
51 struct as<dunedaq::daqdataformats::TriggerRecordHeader>
52 {
53 dunedaq::daqdataformats::TriggerRecordHeader operator()(msgpack::object const& o) const
54 {
55 return dunedaq::daqdataformats::TriggerRecordHeader(const_cast<char*>(o.via.bin.ptr), true);
56 }
57 };
58
59 } // namespace adaptor
60} // namespace MSGPACK_DEFAULT_API_NS
61} // namespace msgpack
62
64
65#endif // DFMESSAGES_INCLUDE_DFMESSAGES_TRIGGERRECORDHEADER_SERIALIZATION_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define DUNE_DAQ_SERIALIZABLE(Type, typestring)
C++ representation of a TriggerRecordHeader, which wraps a flat array that is the TriggerRecordHeader...
size_t get_total_size_bytes() const
Get the total size of the TriggerRecordHeader.
const void * get_storage_location() const
Get the location of the flat data array for output.
Including Qt Headers.
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)