ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
Identifier
Identifier
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef IDENTIFIER_EXPANDEDIDENTIFIER_H
6
#define IDENTIFIER_EXPANDEDIDENTIFIER_H
7
8
9
#include <string>
10
#include <algorithm>
//for lexicographical_compare in the .icc file
11
#include "
CxxUtils/inplace_vector.h
"
12
#include <iosfwd>
13
14
class
MsgStream;
15
16
//-----------------------------------------------
17
//
18
//
19
//
20
// ExpandedIdentifier :
21
//
22
// Stores a set of numbers.
23
//
24
// ---------------------------------------------------
25
//
26
// ------------------------
27
// Possible operations :
28
// ------------------------
29
//
30
// ------------------------
31
// Constructors:
32
// ------------------------
33
//
34
// ExpandedIdentifier () : default constructor
35
//
36
// ExpandedIdentifier (const std::string& text) : build an identifier from a textual
37
// description following the syntax
38
// <value> [ "/" <value> ... ]
39
//
40
// ExpandedIdentifier (const ExpandedIdentifier& other) : copy constructor
41
//
42
// ExpandedIdentifier (const ExpandedIdentifier& other,
43
// size_type start) : subset constructor
44
//
45
// ------------------------
46
// Initialisations:
47
// ------------------------
48
//
49
// void clear () : clears up the identifier
50
//
51
// void set (const std::string& text) : set from a textual description
52
//
53
// ------------------------
54
// Modifications:
55
// ------------------------
56
//
57
// void add (element_type value) : appends a numeric value to
58
// an identifier (adds a field).
59
//
60
// ExpandedIdentifier& operator << (element_type value) : appends a numeric value to
61
// an identifier (adds a field).
62
//
63
// ------------------------
64
// Accessors:
65
// ------------------------
66
//
67
// size_type fields () : returns the number of fields
68
// currently stored into the
69
// identifier.
70
//
71
// element_type operator [] (size_type field) : gets the value stored at the
72
// specified field number.
73
//
74
// ------------------------
75
// Comparison operators:
76
// ------------------------
77
//
78
// operator < (id_type& other) : absolute comparison,
79
//
80
// e.g. :
81
//
82
// /1/2 < /1/3
83
// /1 < /1/3
84
// /1 is implicitly /1/0...
85
//
86
87
//
88
//
89
// ----------------------------------------------------
90
//
91
// Example of how to use an identifier :
92
//
93
// #include <ExpandedIdentifier.h>
94
//
95
// ExpandedIdentifier id;
96
//
97
// id << 125 << 236 << 306 << 2222;
98
//
99
// for (size_type i = 0; i < id.fields (); ++i)
100
// {
101
// cout << "id[" << i << "] = " << id[i] << endl;
102
// }
103
//
104
//-----------------------------------------------
105
class
ExpandedIdentifier
{
106
public
:
107
108
using
id_type
=
ExpandedIdentifier
;
109
using
element_type
= int;
110
using
element_vector
=
CxxUtils::inplace_vector<element_type,12>
;
111
#ifdef __CPPCHECK__
112
// Otherwise cppcheck warns about passing this type by value.
113
using
size_type
= size_t ;
114
#else
115
using
size_type
= element_vector::size_type ;
116
#endif
117
118
static
constexpr
element_type
max_value
= 0x3FFFFFFF;
119
120
ExpandedIdentifier
() =
default
;
121
123
ExpandedIdentifier
(
const
ExpandedIdentifier
& other,
size_type
start);
124
126
ExpandedIdentifier
(
const
std::string& text);
127
129
void
add
(
element_type
value);
130
ExpandedIdentifier
&
operator <<
(
element_type
value);
131
friend
std::ostream &
operator <<
(std::ostream &out,
const
ExpandedIdentifier
&
id
);
132
element_type
&
operator []
(
size_type
index
);
133
135
void
set
(
const
std::string& text);
136
138
void
clear
();
139
141
element_type
operator []
(
size_type
index
)
const
;
142
143
// Size of the fields vector.
144
size_type
fields
()
const
;
145
147
auto
operator <=>
(
const
ExpandedIdentifier
& other)
const
;
148
149
bool
operator ==
(
const
ExpandedIdentifier
& other)
const
;
150
151
156
bool
match
(
const
ExpandedIdentifier
& other)
const
;
157
159
operator
std::string ()
const
;
161
bool
isValid
()
const
;
163
void
show
(std::ostream & out)
const
;
165
void
show
(MsgStream & out)
const
;
166
private
:
167
168
element_vector
m_fields
;
169
};
170
171
172
173
#include "
Identifier/ExpandedIdentifier.icc
"
174
175
#endif
ExpandedIdentifier.icc
ExpandedIdentifier::max_value
static constexpr element_type max_value
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:118
ExpandedIdentifier::operator<=>
auto operator<=>(const ExpandedIdentifier &other) const
Comparison operators.
ExpandedIdentifier::show
void show(std::ostream &out) const
Display detail to ostream.
Definition
DetectorDescription/Identifier/src/ExpandedIdentifier.cxx:63
ExpandedIdentifier::ExpandedIdentifier
ExpandedIdentifier(const ExpandedIdentifier &other, size_type start)
Constructor from a subset of another ExpandedIdentifier.
ExpandedIdentifier::fields
size_type fields() const
ExpandedIdentifier::size_type
element_vector::size_type size_type
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:115
ExpandedIdentifier::m_fields
element_vector m_fields
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:168
ExpandedIdentifier::operator[]
element_type & operator[](size_type index)
ExpandedIdentifier::id_type
ExpandedIdentifier id_type
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:108
ExpandedIdentifier::operator<<
ExpandedIdentifier & operator<<(element_type value)
ExpandedIdentifier::isValid
bool isValid() const
Returns whether the expanded Identifier contains any information.
ExpandedIdentifier::operator==
bool operator==(const ExpandedIdentifier &other) const
ExpandedIdentifier::set
void set(const std::string &text)
build from a textual description
Definition
DetectorDescription/Identifier/src/ExpandedIdentifier.cxx:32
ExpandedIdentifier::ExpandedIdentifier
ExpandedIdentifier()=default
ExpandedIdentifier::add
void add(element_type value)
Append a value into a new field.
ExpandedIdentifier::match
bool match(const ExpandedIdentifier &other) const
Test if the shorter of two ids is identical to the equivalent sub-id extracted from the longer.
ExpandedIdentifier::clear
void clear()
Erase all fields.
ExpandedIdentifier::element_type
int element_type
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:109
ExpandedIdentifier::element_vector
CxxUtils::inplace_vector< element_type, 12 > element_vector
Definition
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:110
inplace_vector.h
Wrapper for C++26 std::inplace_vector.
CxxUtils::inplace_vector
boost::container::small_vector< T, N > inplace_vector
Definition
inplace_vector.h:39
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0