ATLAS Offline Software
Loading...
Searching...
No Matches
LArG4Identifier.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// LArG4Identifier.hh
6// 01-Jul-2002 Bill Seligman
7
8// This is code copied (dare I use the word stolen?) from the Athena
9// Identifier class, as implemented by RD Schaffer and Christian
10// Arnault. It was slightly modified by Bill Seligman for ROOT/G4
11// compatibility.
12
13// If you're an Athena user, you're probably wondering: why steal the
14// code? Why not just include the files from the Athena libraries?
15// The answer is that I still want the LArG4Sim application to run in
16// stand-alone mode, without any access to the Athena libraries. If
17// this ever becomes an Athena-only application, we can make the
18// switch.
19
20#ifndef LARG4CODE_LARG4IDENTIFIER_H
21#define LARG4CODE_LARG4IDENTIFIER_H
22
23// LArG4Identifier :
24//
25// Stores a set of numbers.
26//
27// ---------------------------------------------------
28//
29// ------------------------
30// Possible operations :
31// ------------------------
32//
33// ------------------------
34// Constructors:
35// ------------------------
36//
37// LArG4Identifier () : default constructor
38//
39// LArG4Identifier (const std::string& text) : build an identifier from a textual
40// description following the syntax
41// <value> [ "/" <value> ... ]
42//
43// LArG4Identifier (const LArG4Identifier& other) : copy constructor
44//
45// LArG4Identifier (const LArG4Identifier& other,
46// size_type start) : subset constructor
47//
48// ------------------------
49// Initialisations:
50// ------------------------
51//
52// void clear () : clears up the identifier
53//
54// void set (const std::string& text) : set from a textual description
55//
56// ------------------------
57// Modifications:
58// ------------------------
59//
60// void add (element_type value) : appends a numeric value to
61// an identifier (adds a field).
62//
63// LArG4Identifier& operator << (element_type value) : appends a numeric value to
64// an identifier (adds a field).
65//
66// ------------------------
67// Accessors:
68// ------------------------
69//
70// size_type fields () : returns the number of fields
71// currently stored into the
72// identifier.
73//
74// element_type operator [] (size_type field) : gets the value stored at the
75// specified field number.
76//
77// ------------------------
78// Comparison operators:
79// ------------------------
80//
81// operator < (id_type& other) : absolute comparison,
82//
83// e.g. :
84//
85// /1/2 < /1/3
86// /1 < /1/3
87// /1 is implicitly /1/0...
88//
89// prefix_less (id_type& other) : comparison on the equal length
90// prefix parts of two ids,
91//
92// e.g. :
93//
94// /1/2 < /1/3,
95// but now
96// /1 == /1/3
97//
98//
99// ----------------------------------------------------
100//
101// Example of how to use an identifier :
102//
103// #include <LArG4Identifier.h>
104//
105// LArG4Identifier id;
106//
107// id << 125 << 236 << 306 << 2222;
108//
109// for (size_type i = 0; i < id.fields (); ++i)
110// {
111// cout << "id[" << i << "] = " << id[i] << endl;
112// }
113//
114//-----------------------------------------------
115
116#include <vector>
117#include <string>
118#include <limits.h>
119
121{
122public:
123
124
125 //----------------------------------------------------------------
126 // Define public typedefs
127 //----------------------------------------------------------------
128 typedef short element_type; // WGS
129 typedef std::vector<element_type> element_vector;
130 typedef std::vector<element_type>::size_type size_type;
131
132 typedef enum
133 {
134 max_value = SHRT_MAX
136
137 //----------------------------------------------------------------
138 // Constructors
139 //----------------------------------------------------------------
140
141 //----------------------------------------------------------------
142 // Default constructor
143 //----------------------------------------------------------------
145
146 //----------------------------------------------------------------
147 // Copy constructor
148 //----------------------------------------------------------------
150 LArG4Identifier (LArG4Identifier&& other) = default;
151
152 //----------------------------------------------------------------
153 // Constructor from a subset of another LArG4Identifier
154 //----------------------------------------------------------------
156
157 //----------------------------------------------------------------
158 // Constructor from a textual description
159 //----------------------------------------------------------------
160 LArG4Identifier (const std::string& text);
161
162 virtual ~LArG4Identifier() {};
163
164 //----------------------------------------------------------------
165 // Modifications
166 //----------------------------------------------------------------
167 LArG4Identifier& operator=(const LArG4Identifier&);//coverity issue fix.
169
170 //----------------------------------------------------------------
171 // Append a value into a new field.
172 //----------------------------------------------------------------
173 void add (element_type value);
176
177 //----------------------------------------------------------------
178 // build from a textual description
179 //----------------------------------------------------------------
180 void set (const std::string& text);
181
182 //----------------------------------------------------------------
183 // Erase all fields.
184 // All previously stored data is lost.
185 //----------------------------------------------------------------
186 void clear ();
187
188 //----------------------------------------------------------------
189 // Accessors
190 //----------------------------------------------------------------
191
192 //----------------------------------------------------------------
193 // Get the value stored into the specified field.
194 //----------------------------------------------------------------
196
197 //----------------------------------------------------------------
198 // Count the number of fields.
199 //----------------------------------------------------------------
201
202 //----------------------------------------------------------------
203 // Comparison operators
204 //----------------------------------------------------------------
205
206 int operator == (const LArG4Identifier& other) const;
207 int operator != (const LArG4Identifier& other) const;
208 int operator < (const LArG4Identifier& other) const;
209 int operator > (const LArG4Identifier& other) const;
210 int prefix_less (const LArG4Identifier& other) const;
211
216 int match (const LArG4Identifier& other) const;
217
218 //----------------------------------------------------------------
219 // Utilities
220 //----------------------------------------------------------------
221
222 //----------------------------------------------------------------
223 // Send a textual representation of the identifier using the input format
224 //----------------------------------------------------------------
225 operator std::string () const;
226
227 void show () const;
228
229private:
230
231
232 //----------------------------------------------------------------
233 // The actual identifier data.
234 //----------------------------------------------------------------
236
237};
238
239#endif // LARG4CODE_LARG4IDENTIFIER_H
void show() const
LArG4Identifier(const LArG4Identifier &other)
LArG4Identifier(const LArG4Identifier &other, size_type start)
LArG4Identifier(const std::string &text)
void add(element_type value)
virtual ~LArG4Identifier()
LArG4Identifier & operator=(const LArG4Identifier &)
std::vector< element_type > element_vector
size_type fields() const
int prefix_less(const LArG4Identifier &other) const
std::vector< element_type >::size_type size_type
int match(const LArG4Identifier &other) const
Test if the shorter of two ids is identical to the equivalent sub-id extracted from the longer.
int operator<(const LArG4Identifier &other) const
int operator==(const LArG4Identifier &other) const
element_type & operator[](size_type index)
void set(const std::string &text)
int operator!=(const LArG4Identifier &other) const
LArG4Identifier & operator<<(element_type value)
LArG4Identifier(LArG4Identifier &&other)=default
element_vector m_fields
LArG4Identifier & operator=(LArG4Identifier &&)=default
int operator>(const LArG4Identifier &other) const
Definition index.py:1