ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthContainersInterfaces
AthContainersInterfaces
AuxDataSpan.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
/*
3
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
*/
22
23
24
#ifndef ATHCONTAINERSINTERFACES_AUXDATASPAN_H
25
#define ATHCONTAINERSINTERFACES_AUXDATASPAN_H
26
27
28
#include "
CxxUtils/throw_out_of_range.h
"
29
#include <cstddef>
30
#include <stdexcept>
31
32
33
namespace
SG
{
34
35
39
struct
AuxDataSpanBase
40
{
46
// cppcheck-suppress uninitMemberVar; false positive
47
AuxDataSpanBase
(
void
* the_beg = 0,
size_t
the_size = 0)
48
:
beg
(the_beg),
size
(the_size)
49
{
50
}
51
52
54
void
*
beg
;
55
57
size_t
size
;
58
};
59
60
61
namespace
detail
{
62
63
71
template
<
class
T>
72
class
AuxDataSpan
73
{
74
public
:
79
AuxDataSpan
(
const
AuxDataSpanBase
&
span
) :
m_span
(
span
) {}
80
81
85
size_t
size
()
const
{
return
m_span
.size; }
86
87
91
bool
empty
()
const
{
return
m_span
.size == 0; }
92
93
97
T*
data
() {
return
reinterpret_cast<
T*
>
(
m_span
.beg); }
98
99
103
const
T*
data
()
const
{
return
reinterpret_cast<
T*
>
(
m_span
.beg); }
104
105
110
T&
operator[]
(
size_t
index
)
111
{
112
return
data
()[
index
];
113
}
114
115
120
const
T&
operator[]
(
size_t
index
)
const
121
{
122
return
data
()[
index
];
123
}
124
125
130
T&
at
(
size_t
index
)
131
{
132
if
(
index
>=
m_span
.size) {
133
CxxUtils::throw_out_of_range
(__PRETTY_FUNCTION__,
index
,
m_span
.size,
this
);
134
}
135
return
data
()[
index
];
136
}
137
138
143
const
T&
at
(
size_t
index
)
const
144
{
145
if
(
index
>=
m_span
.size) {
146
CxxUtils::throw_out_of_range
(__PRETTY_FUNCTION__,
index
,
m_span
.size,
this
);
147
}
148
return
data
()[
index
];
149
}
150
151
155
T&
front
() {
return
data
()[0]; }
156
157
161
const
T&
front
()
const
{
return
data
()[0]; }
162
163
167
T&
back
() {
return
data
()[
m_span
.size-1]; }
168
169
173
const
T&
back
()
const
{
return
data
()[
m_span
.size-1]; }
174
175
176
private
:
178
const
AuxDataSpanBase
&
m_span
;
179
};
180
181
189
template
<
class
T>
190
class
AuxDataConstSpan
191
{
192
public
:
197
AuxDataConstSpan
(
const
AuxDataSpanBase
&
span
)
198
:
m_span
(
span
) {}
199
200
204
size_t
size
()
const
{
return
m_span
.size; }
205
206
210
bool
empty
()
const
{
return
m_span
.size == 0; }
211
212
216
const
T*
data
()
const
{
return
reinterpret_cast<
const
T*
>
(
m_span
.beg); }
217
218
223
const
T&
operator[]
(
size_t
index
)
const
224
{
225
return
data
()[
index
];
226
}
227
228
233
const
T&
at
(
size_t
index
)
const
234
{
235
if
(
index
>=
m_span
.size) {
236
CxxUtils::throw_out_of_range
(__PRETTY_FUNCTION__,
index
,
m_span
.size,
this
);
237
}
238
return
data
()[
index
];
239
}
240
241
245
const
T&
front
()
const
{
return
data
()[0]; }
246
247
251
const
T&
back
()
const
{
return
data
()[
m_span
.size-1]; }
252
253
254
private
:
256
const
AuxDataSpanBase
&
m_span
;
257
};
258
259
260
} }
// namespace SG::detail
261
262
263
#endif
// not ATHCONTAINERSINTERFACES_AUXDATASPAN_H
SG::detail::AuxDataConstSpan::at
const T & at(size_t index) const
Bounds-checked element access.
Definition
AuxDataSpan.h:233
SG::detail::AuxDataConstSpan::data
const T * data() const
Return the start of the span.
Definition
AuxDataSpan.h:216
SG::detail::AuxDataConstSpan::empty
bool empty() const
Test to see if the span is empty.
Definition
AuxDataSpan.h:210
SG::detail::AuxDataConstSpan::size
size_t size() const
Return the size of the span.
Definition
AuxDataSpan.h:204
SG::detail::AuxDataConstSpan::back
const T & back() const
Return the last element in the range.
Definition
AuxDataSpan.h:251
SG::detail::AuxDataConstSpan::operator[]
const T & operator[](size_t index) const
Element access.
Definition
AuxDataSpan.h:223
SG::detail::AuxDataConstSpan::AuxDataConstSpan
AuxDataConstSpan(const AuxDataSpanBase &span)
Constructor.
Definition
AuxDataSpan.h:197
SG::detail::AuxDataConstSpan::front
const T & front() const
Return the first element in the range.
Definition
AuxDataSpan.h:245
SG::detail::AuxDataConstSpan< Payload_t >::m_span
const AuxDataSpanBase & m_span
Definition
AuxDataSpan.h:256
SG::detail::AuxDataSpan::size
size_t size() const
Return the size of the span.
Definition
AuxDataSpan.h:85
SG::detail::AuxDataSpan::at
T & at(size_t index)
Bounds-checked element access.
Definition
AuxDataSpan.h:130
SG::detail::AuxDataSpan::at
const T & at(size_t index) const
Bounds-checked element access (const).
Definition
AuxDataSpan.h:143
SG::detail::AuxDataSpan::AuxDataSpan
AuxDataSpan(const AuxDataSpanBase &span)
Constructor.
Definition
AuxDataSpan.h:79
SG::detail::AuxDataSpan::empty
bool empty() const
Test to see if the span is empty.
Definition
AuxDataSpan.h:91
SG::detail::AuxDataSpan::front
T & front()
Return the first element in the range.
Definition
AuxDataSpan.h:155
SG::detail::AuxDataSpan::operator[]
T & operator[](size_t index)
Element access.
Definition
AuxDataSpan.h:110
SG::detail::AuxDataSpan::front
const T & front() const
Return the first element in the range (const).
Definition
AuxDataSpan.h:161
SG::detail::AuxDataSpan::data
T * data()
Return the start of the span.
Definition
AuxDataSpan.h:97
SG::detail::AuxDataSpan::back
T & back()
Return the last element in the range.
Definition
AuxDataSpan.h:167
SG::detail::AuxDataSpan::back
const T & back() const
Return the last element in the range (const).
Definition
AuxDataSpan.h:173
SG::detail::AuxDataSpan::data
const T * data() const
Return the start of the span (const).
Definition
AuxDataSpan.h:103
SG::detail::AuxDataSpan< Payload_t >::m_span
const AuxDataSpanBase & m_span
Definition
AuxDataSpan.h:178
CxxUtils::throw_out_of_range
void throw_out_of_range(const std::string &what, size_t index, size_t size, const void *obj)
Throw an out_of_range exception.
Definition
throw_out_of_range.cxx:27
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::span
CxxUtils::transform_view_with_at< PackedLinkVector_span, ELSpanConverter > span
Definition
PackedLinkDecorator.h:429
detail
Definition
extract_histogram_tag.cxx:14
index
Definition
index.py:1
SG::AuxDataSpanBase
Minimal span-like object describing the range of an auxiliary variable.
Definition
AuxDataSpan.h:40
SG::AuxDataSpanBase::beg
void * beg
Pointer to the start of the variable's vector.
Definition
AuxDataSpan.h:54
SG::AuxDataSpanBase::size
size_t size
The length of the variable's vector.
Definition
AuxDataSpan.h:57
SG::AuxDataSpanBase::AuxDataSpanBase
AuxDataSpanBase(void *the_beg=0, size_t the_size=0)
Constructor.
Definition
AuxDataSpan.h:47
throw_out_of_range.h
Helpers for throwing out_of_range exceptions.
Generated on
for ATLAS Offline Software by
1.17.0