ATLAS Offline Software
Loading...
Searching...
No Matches
ColumnAccessor.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef COLUMNAR_CORE_COLUMN_ACCESSOR_H
9#define COLUMNAR_CORE_COLUMN_ACCESSOR_H
10
19#include <span>
20#include <type_traits>
21
22namespace columnar
23{
25 {
33 std::string replacesColumn {};
34
35
52 bool isOptional = false;
53
54
61 bool addMTDependency = false;
62
63
74 bool isSignAgnostic = false;
75
77 {
78 ColumnInfo info;
79 info.replacesColumn = replacesColumn;
80 info.isOptional = isOptional;
81 return info;
82 }
83 };
84
85
86
87 template<ColumnAccessMode CAM> struct ColumnAccessModeTraits;
88
90 {
91 template<typename T> using XAODAccessor = SG::ConstAccessor<T>;
92 template<typename T> using ColumnType = const T;
93 };
94
96 {
97 template<typename T> using XAODAccessor = SG::Decorator<T>;
98 template<typename T> using ColumnType = T;
99 };
100
102 {
103 template<typename T> using XAODAccessor = SG::Accessor<T>;
104 template<typename T> using ColumnType = T;
105 };
106
107
108
109 namespace detail
110 {
128
129 template<typename CT,ColumnAccessMode CAM,ColumnarModeConcept CM> class ContainerFreeAccessor final
130 {
131 public:
132 static constexpr bool isDefined = false;
133 };
134
135
136
150
151 template<typename CT,ColumnarModeConcept CM> class MemoryAccessor final
152 {
153 public:
154 static constexpr bool isDefined = false;
155 };
156
157
158
159 template<typename CT,ColumnarModeConcept CM>
160 requires ((std::is_integral_v<CT> || std::is_floating_point_v<CT>) && !std::is_same_v<CT,bool>)
162 {
163 public:
164 static constexpr bool isDefined = true;
165 static constexpr bool viewIsReference = true;
166 static constexpr bool hasSetter = false;
167 using MemoryType = CT;
168
169 };
170
171
172
185 template<typename MT,typename Setter>
186 class OutputProxy final
187 {
188 public:
189 OutputProxy (MT& memory, Setter setter) noexcept
190 : m_memory (memory), m_setter (std::move (setter))
191 {}
192
193 OutputProxy (const OutputProxy&) = delete;
195
196 template<typename T>
197 requires requires (const Setter setter, MT& memory, T&& value) {setter (memory, std::forward<T>(value));}
198 const OutputProxy& operator = (T&& value) const
199 {
200 m_setter (m_memory, std::forward<T>(value));
201 return *this;
202 }
203
204 private:
206 [[no_unique_address]] Setter m_setter;
207 };
208 }
209
210
211
247 template<ContainerIdConcept CI,typename CT,ColumnAccessMode CAM,ColumnarModeConcept CM> class AccessorTemplate;
248
249
256 template<typename CT> struct NativeColumn final {};
257 namespace detail
258 {
259 template<typename CT,ColumnarModeConcept CM>
260 class MemoryAccessor<NativeColumn<CT>,CM> final
261 {
262 public:
263 static constexpr bool isDefined = true;
264 static constexpr bool viewIsReference = true;
265 static constexpr bool hasSetter = false;
266 using MemoryType = CT;
267
268 };
269 }
270
271
277 template<typename UT,typename CT> struct RetypeColumn final
278 {
279 static_assert (!std::is_const_v<CT>, "CT must not be const");
280 static_assert (!std::is_const_v<UT>, "UT must not be const");
281 };
282
283 namespace detail
284 {
285 template<typename UT,typename CT,ColumnarModeConcept CM>
286 class MemoryAccessor<RetypeColumn<UT,CT>,CM> final
287 {
288 public:
289 static constexpr bool isDefined = true;
290 static constexpr bool viewIsReference = false;
291 static constexpr bool hasSetter = false;
292 using MemoryType = CT;
293
294 static auto makeViewer (auto&&)
295 {
296 return [] (const auto& value) {return static_cast<UT>(value);};
297 }
298 };
299 }
300
301
302
303
311
312 template<ContainerIdConcept CI,typename CT,ColumnAccessMode CAM,ColumnarModeConcept CM>
313 void resetAccessor (AccessorTemplate<CI,CT,CAM,CM>& accessor, ColumnarTool<CM>& columnBase, const std::string& name, ColumnAccessorOptions&& options = {})
314 {
315 accessor = AccessorTemplate<CI,CT,CAM,CM> (columnBase, name, std::move (options));
316 }
317
318
319
320
321
322 template<ContainerIdConcept CI,typename CT,ColumnarModeConcept CM=ColumnarMode> using ColumnAccessor = AccessorTemplate<CI,CT,ColumnAccessMode::input,CM>;
323 template<ContainerIdConcept CI,typename CT,ColumnarModeConcept CM=ColumnarMode> using ColumnDecorator = AccessorTemplate<CI,CT,ColumnAccessMode::output,CM>;
324 template<ContainerIdConcept CI,typename CT,ColumnarModeConcept CM=ColumnarMode> using ColumnUpdater = AccessorTemplate<CI,CT,ColumnAccessMode::update,CM>;
325}
326
327#include "ColumnAccessorXAOD.icc"
329
330#endif
Helper class to provide constant type-safe access to aux data.
Helper class to provide type-safe access to aux data.
Helper class to provide type-safe access to aux data.
Helper class to provide type-safe access to aux data.
Helper class to provide constant type-safe access to aux data.
the raw column accessor template class
the base class for all columnar components
the backend implementation for AccessorTemplate
a help implementation of AccessorTemplate that handles type conversions
OutputProxy & operator=(const OutputProxy &)=delete
OutputProxy(MT &memory, Setter setter) noexcept
OutputProxy(const OutputProxy &)=delete
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
AccessorTemplate< CI, CT, ColumnAccessMode::input, CM > ColumnAccessor
AccessorTemplate< CI, CT, ColumnAccessMode::output, CM > ColumnDecorator
ColumnAccessMode
an enum for the different access modes for a column
Definition ColumnInfo.h:20
@ update
an updateable column
Definition ColumnInfo.h:28
@ output
an output column
Definition ColumnInfo.h:25
@ input
an input column
Definition ColumnInfo.h:22
AccessorTemplate< CI, CT, ColumnAccessMode::update, CM > ColumnUpdater
void resetAccessor(AccessorTemplate< CI, CT, CAM, CM > &accessor, ColumnarTool< CM > &columnBase, const std::string &name, ColumnAccessorOptions &&options={})
reset a column accessor to point to a new column
std::string replacesColumn
whether this replaces another column
bool addMTDependency
whether to add data dependencies in AthenaMT
bool isOptional
whether this column is optional
bool isSignAgnostic
whether this (integer) column accepts data of the same size but different sign
ColumnInfo makeColumnInfo() const
a struct that contains meta-information about each column that's needed to interface the column with ...
Definition ColumnInfo.h:73
a type wrapper to force AccessorTemplate to treat the type as native
a type wrapper to make AccessorTemplate convert the underlying column type to a different type