ATLAS Offline Software
Loading...
Searching...
No Matches
DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef IDENTIFIER_EXPANDEDIDENTIFIER_H
6#define IDENTIFIER_EXPANDEDIDENTIFIER_H
7
8#include <string>
9#include <algorithm>//for lexicographical_compare in the .icc file
10#include <boost/container/small_vector.hpp>
11#include <iosfwd>
12
13//-----------------------------------------------
14//
15//
16//
17// ExpandedIdentifier :
18//
19// Stores a set of numbers.
20//
21// ---------------------------------------------------
22//
23// ------------------------
24// Possible operations :
25// ------------------------
26//
27// ------------------------
28// Constructors:
29// ------------------------
30//
31// ExpandedIdentifier () : default constructor
32//
33// ExpandedIdentifier (const std::string& text) : build an identifier from a textual
34// description following the syntax
35// <value> [ "/" <value> ... ]
36//
37// ExpandedIdentifier (const ExpandedIdentifier& other) : copy constructor
38//
39// ExpandedIdentifier (const ExpandedIdentifier& other,
40// size_type start) : subset constructor
41//
42// ------------------------
43// Initialisations:
44// ------------------------
45//
46// void clear () : clears up the identifier
47//
48// void set (const std::string& text) : set from a textual description
49//
50// ------------------------
51// Modifications:
52// ------------------------
53//
54// void add (element_type value) : appends a numeric value to
55// an identifier (adds a field).
56//
57// ExpandedIdentifier& operator << (element_type value) : appends a numeric value to
58// an identifier (adds a field).
59//
60// ------------------------
61// Accessors:
62// ------------------------
63//
64// size_type fields () : returns the number of fields
65// currently stored into the
66// identifier.
67//
68// element_type operator [] (size_type field) : gets the value stored at the
69// specified field number.
70//
71// ------------------------
72// Comparison operators:
73// ------------------------
74//
75// operator < (id_type& other) : absolute comparison,
76//
77// e.g. :
78//
79// /1/2 < /1/3
80// /1 < /1/3
81// /1 is implicitly /1/0...
82//
83
84//
85//
86// ----------------------------------------------------
87//
88// Example of how to use an identifier :
89//
90// #include <ExpandedIdentifier.h>
91//
92// ExpandedIdentifier id;
93//
94// id << 125 << 236 << 306 << 2222;
95//
96// for (size_type i = 0; i < id.fields (); ++i)
97// {
98// cout << "id[" << i << "] = " << id[i] << endl;
99// }
100//
101//-----------------------------------------------
103public:
104
106 using element_type = int;
107 using element_vector = boost::container::small_vector<element_type,12>;
108#ifdef __CPPCHECK__
109 // Otherwise cppcheck warns about passing this type by value.
110 using size_type = size_t ;
111#else
112 using size_type = boost::container::small_vector<element_type,12>::size_type ;
113#endif
114
115 static constexpr element_type max_value = 0x3FFFFFFF;
116
118
121
123 ExpandedIdentifier (const std::string& text);
124
126 void add (element_type value);
129
131 void set (const std::string& text);
132
134 void clear ();
135
138
139 // Size of the fields vector.
141
143 auto operator <=>( const ExpandedIdentifier& other) const;
144
145 bool operator == (const ExpandedIdentifier& other) const;
146
147
152 bool match (const ExpandedIdentifier& other) const;
153
155 operator std::string () const;
157 bool isValid() const;
159 void show () const;
160
161private:
162
164};
165
166std::ostream & operator << (std::ostream &out, const ExpandedIdentifier & x);
167
168
169
171
172#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 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