DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::daqdataformats::SourceID Struct Reference

SourceID is a generalized representation of the source of a piece of data in the DAQ. That source could be a physical location in the detector, a running process in the DAQ (e.g. a dataflow app, the source of a data request), etc. More...

#include <SourceID.hpp>

Public Types

enum class  Subsystem : Subsystem_t {
  kUnknown = 0 , kDetectorReadout = 1 , kHwSignalsInterface = 2 , kTrigger = 3 ,
  kTRBuilder = 4
}
 The Subsystem enum describes the kind of source we're dealing with. More...
 
using Version_t = uint16_t
 
using Subsystem_t = uint16_t
 
using ID_t = uint32_t
 

Public Member Functions

 SourceID ()=default
 
 SourceID (const Subsystem &subsystem_arg, const ID_t &id_arg)
 
std::string to_string () const
 
bool is_in_valid_state () const noexcept
 
bool operator< (const SourceID &other) const noexcept
 Comparison operators to allow SourceID to be used in std::map.
 
bool operator!= (const SourceID &other) const noexcept
 
bool operator== (const SourceID &other) const noexcept
 

Static Public Member Functions

static std::string subsystem_to_string (const Subsystem &type)
 
static Subsystem string_to_subsystem (const std::string &typestring)
 

Public Attributes

Version_t version { s_source_id_version }
 Version number of the SourceID.
 
Subsystem subsystem { Subsystem::kUnknown }
 The general subsystem of the source of the data.
 
ID_t id { s_invalid_id }
 Unique identifier of the source of the data.
 

Static Public Attributes

static constexpr Version_t s_source_id_version
 The version of this SourceID struct.
 
static constexpr ID_t s_invalid_id = std::numeric_limits<ID_t>::max()
 A value for the id meant to convey that it doesn't identify a data source and shouldn't be worked with.
 

Detailed Description

SourceID is a generalized representation of the source of a piece of data in the DAQ. That source could be a physical location in the detector, a running process in the DAQ (e.g. a dataflow app, the source of a data request), etc.

Definition at line 31 of file SourceID.hpp.

Member Typedef Documentation

◆ ID_t

Definition at line 36 of file SourceID.hpp.

◆ Subsystem_t

Definition at line 35 of file SourceID.hpp.

◆ Version_t

Definition at line 34 of file SourceID.hpp.

Member Enumeration Documentation

◆ Subsystem

The Subsystem enum describes the kind of source we're dealing with.

Enumerator
kUnknown 
kDetectorReadout 
kHwSignalsInterface 
kTrigger 
kTRBuilder 

Definition at line 42 of file SourceID.hpp.

Constructor & Destructor Documentation

◆ SourceID() [1/2]

dunedaq::daqdataformats::SourceID::SourceID ( )
default

◆ SourceID() [2/2]

dunedaq::daqdataformats::SourceID::SourceID ( const Subsystem & subsystem_arg,
const ID_t & id_arg )
inline

Definition at line 78 of file SourceID.hpp.

79 : subsystem(subsystem_arg)
80 , id(id_arg)
81 {}
Subsystem subsystem
The general subsystem of the source of the data.
Definition SourceID.hpp:69
ID_t id
Unique identifier of the source of the data.
Definition SourceID.hpp:74

Member Function Documentation

◆ is_in_valid_state()

bool dunedaq::daqdataformats::SourceID::is_in_valid_state ( ) const
inlinenoexcept

Definition at line 90 of file SourceID.hpp.

90{ return subsystem != Subsystem::kUnknown && id != s_invalid_id; }
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

◆ operator!=()

bool dunedaq::daqdataformats::SourceID::operator!= ( const SourceID & other) const
inlinenoexcept

Definition at line 76 of file SourceID.hxx.

77{
78 return (*this) < other || other < (*this);
79}

◆ operator<()

bool dunedaq::daqdataformats::SourceID::operator< ( const SourceID & other) const
inlinenoexcept

Comparison operators to allow SourceID to be used in std::map.

Definition at line 69 of file SourceID.hxx.

71{
72 return std::tuple(subsystem, id) < std::tuple(other.subsystem, other.id);
73}

◆ operator==()

bool dunedaq::daqdataformats::SourceID::operator== ( const SourceID & other) const
inlinenoexcept

Definition at line 82 of file SourceID.hxx.

83{
84 return !((*this) != other);
85}

◆ string_to_subsystem()

SourceID::Subsystem dunedaq::daqdataformats::SourceID::string_to_subsystem ( const std::string & typestring)
inlinestatic

Definition at line 106 of file SourceID.hxx.

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}

◆ subsystem_to_string()

std::string dunedaq::daqdataformats::SourceID::subsystem_to_string ( const Subsystem & type)
inlinestatic

Definition at line 88 of file SourceID.hxx.

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}

◆ to_string()

std::string dunedaq::daqdataformats::SourceID::to_string ( ) const
inline

Definition at line 83 of file SourceID.hpp.

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 }
static std::string subsystem_to_string(const Subsystem &type)
Definition SourceID.hxx:88

Member Data Documentation

◆ id

ID_t dunedaq::daqdataformats::SourceID::id { s_invalid_id }

Unique identifier of the source of the data.

Definition at line 74 of file SourceID.hpp.

74{ s_invalid_id };

◆ s_invalid_id

ID_t dunedaq::daqdataformats::SourceID::s_invalid_id = std::numeric_limits<ID_t>::max()
staticconstexpr

A value for the id meant to convey that it doesn't identify a data source and shouldn't be worked with.

Definition at line 60 of file SourceID.hpp.

◆ s_source_id_version

Version_t dunedaq::daqdataformats::SourceID::s_source_id_version
staticconstexpr
Initial value:
=
2

The version of this SourceID struct.

Definition at line 54 of file SourceID.hpp.

◆ subsystem

Subsystem dunedaq::daqdataformats::SourceID::subsystem { Subsystem::kUnknown }

The general subsystem of the source of the data.

Definition at line 69 of file SourceID.hpp.

◆ version

Version_t dunedaq::daqdataformats::SourceID::version { s_source_id_version }

Version number of the SourceID.

Definition at line 65 of file SourceID.hpp.

static constexpr Version_t s_source_id_version
The version of this SourceID struct.
Definition SourceID.hpp:54

The documentation for this struct was generated from the following files: