ATLAS Offline Software
Loading...
Searching...
No Matches
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 <boost/container/small_vector.hpp>
12#include <iostream>
13
14class 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//-----------------------------------------------
106public:
107
109 using element_type = int;
110 using element_vector = boost::container::small_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 = boost::container::small_vector<element_type,12>::size_type ;
116#endif
117
118 static constexpr element_type max_value = 0x3FFFFFFF;
119
121
124
126 ExpandedIdentifier (const std::string& text);
127
129 void add (element_type value);
132
134 void set (const std::string& text);
135
137 void clear ();
138
141
142 // Size of the fields vector.
144
146 auto operator <=>( const ExpandedIdentifier& other) const;
147
148 bool operator == (const ExpandedIdentifier& other) const;
149
150
155 bool match (const ExpandedIdentifier& other) const;
156
158 operator std::string () const;
160 bool isValid() const;
162 void show (std::ostream & out = std::cout) const;
164 void show (MsgStream & out) const;
165private:
166
168};
169
170std::ostream & operator << (std::ostream &out, const ExpandedIdentifier & x);
171
172
173
175
176#endif
std::ostream & operator<<(std::ostream &out, const ExpandedIdentifier &x)
#define x
auto operator<=>(const ExpandedIdentifier &other) const
Comparison operators.
ExpandedIdentifier(const ExpandedIdentifier &other, size_type start)
Constructor from a subset of another ExpandedIdentifier.
size_type fields() const
element_type & operator[](size_type index)
ExpandedIdentifier & operator<<(element_type value)
bool isValid() const
Returns whether the expanded Identifier contains any information.
bool operator==(const ExpandedIdentifier &other) const
void show(std::ostream &out=std::cout) const
Display detail to ostream.
void set(const std::string &text)
build from a textual description
ExpandedIdentifier()=default
boost::container::small_vector< element_type, 12 >::size_type size_type
void add(element_type value)
Append a value into a new field.
bool match(const ExpandedIdentifier &other) const
Test if the shorter of two ids is identical to the equivalent sub-id extracted from the longer.
boost::container::small_vector< element_type, 12 > element_vector
void clear()
Erase all fields.
Definition index.py:1