DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SourceID.hxx
Go to the documentation of this file.
1
3
4static_assert(std::is_trivially_copyable<SourceID>::value,
5 "SourceID isn't trivially copyable and can't be safely std::memcpy'd");
6
7static_assert(std::is_standard_layout<SourceID>::value,
8 "SourceID isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
9
10static_assert(SourceID::s_source_id_version == 2,
11 "This is intentionally designed to tell the developer to update the static_assert checks (including this "
12 "one) when the version is bumped");
13static_assert(sizeof(SourceID) == 8, "SourceID struct size different than expected!");
14static_assert(offsetof(SourceID, version) == 0, "SourceID version field not at expected offset");
15static_assert(offsetof(SourceID, subsystem) == 2, "SourceID subsystem field not at expected offset");
16static_assert(offsetof(SourceID, id) == 4, "SourceID id field not at expected offset");
17
18inline std::ostream&
19operator<<(std::ostream& o, SourceID::Subsystem const& type)
20{
22}
23
24inline std::ostream&
25operator<<(std::ostream& o, SourceID const& source_id)
26{
27 return o << "subsystem: " << source_id.subsystem << " id: " << source_id.id;
28}
29
30inline std::istream&
31operator>>(std::istream& is, SourceID::Subsystem& t)
32{
33 std::string tmp;
34 is >> tmp;
35
37
38 return is;
39}
40
41inline std::istream&
42operator>>(std::istream& is, SourceID& source_id)
43{
44 std::string tmp;
45 is >> tmp >> source_id.subsystem >> tmp >> source_id.id; // Eat last three tokens, e.g. "-> (314, 159)"
46
47 return is;
48}
49
50inline bool
51SourceID::operator!=(const SourceID& other) const noexcept
52{
53 return (*this) < other || other < (*this);
54}
55
56inline bool
57SourceID::operator==(const SourceID& other) const noexcept
58{
59 return !((*this) != other);
60}
61
62inline std::string
64{
65 switch (type) {
67 return "Unknown";
69 return "Detector_Readout";
71 return "HW_Signals_Interface";
73 return "Trigger";
75 return "TR_Builder";
76 }
77 return "Unknown";
78}
79
81SourceID::string_to_subsystem(const std::string& typestring)
82{
83 if (typestring == "Detector_Readout")
85 if (typestring == "HW_Signals_Interface")
87 if (typestring == "Trigger")
89 if (typestring == "TR_Builder")
91
93}
94
95} // namespace dunedaq::daqdataformats
std::istream & operator>>(std::istream &is, SourceID::Subsystem &t)
Definition SourceID.hxx:31
std::ostream & operator<<(std::ostream &o, ComponentRequest const &cr)
SourceID is a generalized representation of the source of a piece of data in the DAQ....
Definition SourceID.hpp:32
static constexpr Version_t s_source_id_version
Definition SourceID.hpp:49
Subsystem subsystem
The general subsystem of the source of the data.
Definition SourceID.hpp:56
static std::string subsystem_to_string(const Subsystem &type)
Definition SourceID.hxx:63
static Subsystem string_to_subsystem(const std::string &typestring)
Definition SourceID.hxx:81
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:40
ID_t id
Unique identifier of the source of the data.
Definition SourceID.hpp:59
bool operator==(const SourceID &other) const noexcept
Definition SourceID.hxx:57
bool operator!=(const SourceID &other) const noexcept
Definition SourceID.hxx:51