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(SourceID::s_source_id_version == 2,
5 "This is intentionally designed to tell the developer to update the static_assert checks (including this "
6 "one) when the version is bumped");
7static_assert(sizeof(SourceID) == 8, "SourceID struct size different than expected!");
8static_assert(offsetof(SourceID, version) == 0, "SourceID version field not at expected offset");
9static_assert(offsetof(SourceID, subsystem) == 2, "SourceID subsystem field not at expected offset");
10static_assert(offsetof(SourceID, id) == 4, "SourceID id field not at expected offset");
11
18inline std::ostream&
19operator<<(std::ostream& o, SourceID::Subsystem const& type)
20{
21 return o << SourceID::subsystem_to_string(type);
22}
23
30inline std::ostream&
31operator<<(std::ostream& o, SourceID const& source_id)
32{
33 return o << "subsystem: " << source_id.subsystem << " id: " << source_id.id;
34}
35
42inline std::istream&
43operator>>(std::istream& is, SourceID::Subsystem& t)
44{
45 std::string tmp;
46 is >> tmp;
47
49
50 return is;
51}
52
59inline std::istream&
60operator>>(std::istream& is, SourceID& source_id)
61{
62 std::string tmp ;
63 is >> tmp >> source_id.subsystem >> tmp >> source_id.id; // Eat last three tokens, e.g. "-> (314, 159)"
64
65 return is;
66}
67
68
69bool
70SourceID::operator<(const SourceID& other) const noexcept
71{
72 return std::tuple(subsystem, id) < std::tuple(other.subsystem, other.id);
73}
74
75bool
76SourceID::operator!=(const SourceID& other) const noexcept
77{
78 return (*this) < other || other < (*this);
79}
80
81bool
82SourceID::operator==(const SourceID& other) const noexcept
83{
84 return !((*this) != other);
85}
86
87std::string
89{
90 switch (type) {
92 return "Unknown";
94 return "Detector_Readout";
96 return "HW_Signals_Interface";
98 return "Trigger";
100 return "TR_Builder";
101 }
102 return "Unknown";
103}
104
106SourceID::string_to_subsystem(const std::string& typestring)
107{
108 if (typestring == "Detector_Readout")
110 if (typestring == "HW_Signals_Interface")
112 if (typestring == "Trigger")
113 return Subsystem::kTrigger;
114 if (typestring == "TR_Builder")
116
117 return Subsystem::kUnknown;
118}
119
120} // namespace dunedaq::daqdataformats
std::ostream & operator<<(std::ostream &o, ComponentRequest const &cr)
Write out a ComponentRequest in human-readable form.
std::istream & operator>>(std::istream &is, ComponentRequest &cr)
Read a ComponentRequest from a string stream.
daqdataformats::SourceID SourceID
Copy daqdataformats::SourceID.
Definition Types.hpp:32
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
The version of this SourceID struct.
Definition SourceID.hpp:54
bool operator<(const SourceID &other) const noexcept
Comparison operators to allow SourceID to be used in std::map.
Definition SourceID.hxx:70
Subsystem subsystem
The general subsystem of the source of the data.
Definition SourceID.hpp:69
static std::string subsystem_to_string(const Subsystem &type)
Definition SourceID.hxx:88
static Subsystem string_to_subsystem(const std::string &typestring)
Definition SourceID.hxx:106
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:43
ID_t id
Unique identifier of the source of the data.
Definition SourceID.hpp:74
bool operator==(const SourceID &other) const noexcept
Definition SourceID.hxx:82
bool operator!=(const SourceID &other) const noexcept
Definition SourceID.hxx:76