DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
SourceID.hpp
Go to the documentation of this file.
1
9#ifndef DAQDATAFORMATS_INCLUDE_DAQDATAFORMATS_SOURCEID_HPP_
10#define DAQDATAFORMATS_INCLUDE_DAQDATAFORMATS_SOURCEID_HPP_
11
12#include <cassert>
13#include <cstddef>
14#include <cstdint>
15#include <iomanip>
16#include <istream>
17#include <limits>
18#include <ostream>
19#include <sstream>
20#include <string>
21#include <tuple>
22
24
32{
33
34 using Version_t = uint16_t; // NOLINT(build/unsigned)
35 using Subsystem_t = uint16_t; // NOLINT(build/unsigned)
36 using ID_t = uint32_t; // NOLINT(build/unsigned)
37
43 {
44 kUnknown = 0,
47 kTrigger = 3,
48 kTRBuilder = 4
49 };
50
54 static constexpr Version_t s_source_id_version =
55 2; // Taking SourceID as the direct successor of GeoID which had version 1
56
60 static constexpr ID_t s_invalid_id = std::numeric_limits<ID_t>::max();
61
70
75
76 SourceID() = default;
77
78 SourceID(const Subsystem& subsystem_arg, const ID_t& id_arg)
79 : subsystem(subsystem_arg)
80 , id(id_arg)
81 {}
82
83 std::string to_string() const
84 {
85 std::ostringstream ostr;
86 ostr << subsystem_to_string(subsystem) << "_0x" << std::hex << std::setfill('0') << std::setw(2 * sizeof(id)) << id;
87 return ostr.str();
88 }
89
90 bool is_in_valid_state() const noexcept { return subsystem != Subsystem::kUnknown && id != s_invalid_id; }
91
95 inline bool operator<(const SourceID& other) const noexcept;
96 inline bool operator!=(const SourceID& other) const noexcept;
97 inline bool operator==(const SourceID& other) const noexcept;
98
99 inline static std::string subsystem_to_string(const Subsystem& type);
100 inline static Subsystem string_to_subsystem(const std::string& typestring);
101};
102
103} // namespace dunedaq::daqdataformats
104
105#include "detail/SourceID.hxx"
106
107#endif // DAQDATAFORMATS_INCLUDE_DAQDATAFORMATS_SOURCEID_HPP_
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
Version_t version
Version number of the SourceID.
Definition SourceID.hpp:65
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
std::string to_string() const
Definition SourceID.hpp:83
static constexpr ID_t s_invalid_id
A value for the id meant to convey that it doesn't identify a data source and shouldn't be worked wit...
Definition SourceID.hpp:60
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:43
bool is_in_valid_state() const noexcept
Definition SourceID.hpp:90
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
SourceID(const Subsystem &subsystem_arg, const ID_t &id_arg)
Definition SourceID.hpp:78
bool operator!=(const SourceID &other) const noexcept
Definition SourceID.hxx:76