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
64 {
65 ColumnInfo info;
66 info.replacesColumn = replacesColumn;
67 info.isOptional = isOptional;
68 return info;
69 }
70 };
71
72
73
74 template<ColumnAccessMode CAM> struct ColumnAccessModeTraits;
75
77 {
78 template<typename T> using XAODAccessor = SG::ConstAccessor<T>;
79 template<typename T> using ColumnType = const T;
80 };
81
83 {
84 template<typename T> using XAODAccessor = SG::Decorator<T>;
85 template<typename T> using ColumnType = T;
86 };
87
89 {
90 template<typename T> using XAODAccessor = SG::Accessor<T>;
91 template<typename T> using ColumnType = T;
92 };
93
94
95
96 namespace detail
97 {
115
116 template<typename CT,ColumnAccessMode CAM,ColumnarMode CM> class ContainerFreeAccessor final
117 {
118 public:
119 static constexpr bool isDefined = false;
120 };
121
122
123
137
138 template<typename CT,ColumnarMode CM> class MemoryAccessor final
139 {
140 public:
141 static constexpr bool isDefined = false;
142 };
143
144
145
146 template<typename CT,ColumnarMode CM>
147 requires ((std::is_integral_v<CT> || std::is_floating_point_v<CT>) && !std::is_same_v<CT,bool>)
149 {
150 public:
151 static constexpr bool isDefined = true;
152 static constexpr bool viewIsReference = true;
153 static constexpr bool hasSetter = false;
154 using MemoryType = CT;
155
156 static void updateColumnInfo (ColumnInfo& /*info*/) {}
157 };
158 }
159
160
161
197 template<ContainerIdConcept CI,typename CT,ColumnAccessMode CAM,typename CM> class AccessorTemplate;
198
199
206 template<typename CT> struct NativeColumn final {};
207 namespace detail
208 {
209 template<typename CT,ColumnarMode CM>
210 class MemoryAccessor<NativeColumn<CT>,CM> final
211 {
212 public:
213 static constexpr bool isDefined = true;
214 static constexpr bool viewIsReference = true;
215 static constexpr bool hasSetter = false;
216 using MemoryType = CT;
217
218 static void updateColumnInfo (ColumnInfo& /*info*/) {}
219 };
220 }
221
222
228 template<typename UT,typename CT> struct RetypeColumn final
229 {
230 static_assert (!std::is_const_v<CT>, "CT must not be const");
231 static_assert (!std::is_const_v<UT>, "UT must not be const");
232 };
233
234 namespace detail
235 {
236 template<typename UT,typename CT,ColumnarMode CM>
237 class MemoryAccessor<RetypeColumn<UT,CT>,CM> final
238 {
239 public:
240 static constexpr bool isDefined = true;
241 static constexpr bool viewIsReference = false;
242 static constexpr bool hasSetter = false;
243 using MemoryType = CT;
244
245 static void updateColumnInfo (ColumnInfo& /*info*/) {}
246 static auto makeViewer (auto&&)
247 {
248 return [] (const auto& value) {return static_cast<UT>(value);};
249 }
250 };
251 }
252
253
254
255
263
264 template<ContainerIdConcept CI,typename CT,ColumnAccessMode CAM,typename CM>
265 void resetAccessor (AccessorTemplate<CI,CT,CAM,CM>& accessor, ColumnarTool<CM>& columnBase, const std::string& name, ColumnAccessorOptions&& options = {})
266 {
267 accessor = AccessorTemplate<CI,CT,CAM,CM> (columnBase, name, std::move (options));
268 }
269
270
271
272
273
274 template<ContainerIdConcept CI,typename CT,typename CM=ColumnarModeDefault> using ColumnAccessor = AccessorTemplate<CI,CT,ColumnAccessMode::input,CM>;
275 template<ContainerIdConcept CI,typename CT,typename CM=ColumnarModeDefault> using ColumnDecorator = AccessorTemplate<CI,CT,ColumnAccessMode::output,CM>;
276 template<ContainerIdConcept CI,typename CT,typename CM=ColumnarModeDefault> using ColumnUpdater = AccessorTemplate<CI,CT,ColumnAccessMode::update,CM>;
277}
278
279#include "ColumnAccessorXAOD.icc"
281
282#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
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:19
@ update
an updateable column
Definition ColumnInfo.h:27
@ output
an output column
Definition ColumnInfo.h:24
@ input
an input column
Definition ColumnInfo.h:21
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
ColumnInfo makeColumnInfo() const
a struct that contains meta-information about each column that's needed to interface the column with ...
Definition ColumnInfo.h:35
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