ATLAS Offline Software
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 //-----------------------------------------------
103 public:
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 
117  ExpandedIdentifier() = default;
118 
121 
123  ExpandedIdentifier (const std::string& text);
124 
129 
131  void set (const std::string& text);
132 
134  void clear ();
135 
138 
139  // Size of the fields vector.
140  size_type fields () const;
141 
143  auto operator <=>( const ExpandedIdentifier& other) const;
144 
146 
147 
152  bool match (const ExpandedIdentifier& other) const;
153 
155  operator std::string () const;
157  void show () const;
158 
159 private:
160 
162 };
163 
164 std::ostream & operator << (std::ostream &out, const ExpandedIdentifier & x);
165 
166 
167 
169 
170 #endif
ExpandedIdentifier::operator[]
element_type & operator[](size_type index)
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
index
Definition: index.py:1
ExpandedIdentifier::operator==
bool operator==(const ExpandedIdentifier &other) const
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
ExpandedIdentifier::add
void add(element_type value)
Append a value into a new field.
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:102
ExpandedIdentifier::show
void show() const
Send to std::cout.
Definition: DetectorDescription/Identifier/src/ExpandedIdentifier.cxx:60
athena.value
value
Definition: athena.py:124
ExpandedIdentifier::fields
size_type fields() const
x
#define x
ExpandedIdentifier::max_value
static constexpr element_type max_value
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:115
ExpandedIdentifier.icc
operator<<
std::ostream & operator<<(std::ostream &out, const ExpandedIdentifier &x)
Definition: DetectorDescription/Identifier/src/ExpandedIdentifier.cxx:64
ExpandedIdentifier::operator<<
ExpandedIdentifier & operator<<(element_type value)
ExpandedIdentifier::set
void set(const std::string &text)
build from a textual description
Definition: DetectorDescription/Identifier/src/ExpandedIdentifier.cxx:32
ExpandedIdentifier::size_type
boost::container::small_vector< element_type, 12 >::size_type size_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:112
ExpandedIdentifier::m_fields
element_vector m_fields
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:161
ExpandedIdentifier::ExpandedIdentifier
ExpandedIdentifier(const ExpandedIdentifier &other, size_type start)
Constructor from a subset of another ExpandedIdentifier.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
ExpandedIdentifier::ExpandedIdentifier
ExpandedIdentifier()=default
ExpandedIdentifier::clear
void clear()
Erase all fields.
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
ExpandedIdentifier::element_type
int element_type
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:106
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::element_vector
boost::container::small_vector< element_type, 12 > element_vector
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:107