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
94 std::vector<std::string> internalLinkTargetNames {};
95
97 {
98 ColumnInfo info;
99 info.replacesColumn = replacesColumn;
100 info.isOptional = isOptional;
101 info.linkTargetNames = internalLinkTargetNames;
102 return info;
103 }
104 };
105
106
107
108 template<ColumnAccessMode CAM> struct ColumnAccessModeTraits;
109
111 {
112 template<typename T> using XAODAccessor = SG::ConstAccessor<T>;
113 template<typename T> using ColumnType = const T;
114 };
115
117 {
118 template<typename T> using XAODAccessor = SG::Decorator<T>;
119 template<typename T> using ColumnType = T;
120 };
121
123 {
124 template<typename T> using XAODAccessor = SG::Accessor<T>;
125 template<typename T> using ColumnType = T;
126 };
127
128
129
130 namespace detail
131 {
149
150 template<typename CT,ColumnAccessMode CAM,ColumnarMode CM> class ContainerFreeAccessor final
151 {
152 public:
153 static constexpr bool isDefined = false;
154 };
155
156
157
171
172 template<typename CT,ColumnarMode CM> class MemoryAccessor final
173 {
174 public:
175 static constexpr bool isDefined = false;
176 };
177
178
179
180 template<typename CT,ColumnarMode CM>
181 requires ((std::is_integral_v<CT> || std::is_floating_point_v<CT>) && !std::is_same_v<CT,bool>)
183 {
184 public:
185 static constexpr bool isDefined = true;
186 static constexpr bool viewIsReference = true;
187 static constexpr bool hasSetter = false;
188 using MemoryType = CT;
189
190 static void updateColumnInfo (ColumnInfo& /*info*/) {}
191 };
192 }
193
194
195
231 template<ContainerIdConcept CI,typename CT,ColumnAccessMode CAM,typename CM> class AccessorTemplate;
232
233
240 template<typename CT> struct NativeColumn final {};
241 namespace detail
242 {
243 template<typename CT,ColumnarMode CM>
244 class MemoryAccessor<NativeColumn<CT>,CM> final
245 {
246 public:
247 static constexpr bool isDefined = true;
248 static constexpr bool viewIsReference = true;
249 static constexpr bool hasSetter = false;
250 using MemoryType = CT;
251
252 static void updateColumnInfo (ColumnInfo& /*info*/) {}
253 };
254 }
255
256
262 template<typename UT,typename CT> struct RetypeColumn final
263 {
264 static_assert (!std::is_const_v<CT>, "CT must not be const");
265 static_assert (!std::is_const_v<UT>, "UT must not be const");
266 };
267
268 namespace detail
269 {
270 template<typename UT,typename CT,ColumnarMode CM>
271 class MemoryAccessor<RetypeColumn<UT,CT>,CM> final
272 {
273 public:
274 static constexpr bool isDefined = true;
275 static constexpr bool viewIsReference = false;
276 static constexpr bool hasSetter = false;
277 using MemoryType = CT;
278
279 static void updateColumnInfo (ColumnInfo& /*info*/) {}
280 static auto makeViewer (auto&&)
281 {
282 return [] (const auto& value) {return static_cast<UT>(value);};
283 }
284 };
285 }
286
287
288
289
297
298 template<ContainerIdConcept CI,typename CT,ColumnAccessMode CAM,typename CM>
299 void resetAccessor (AccessorTemplate<CI,CT,CAM,CM>& accessor, ColumnarTool<CM>& columnBase, const std::string& name, ColumnAccessorOptions&& options = {})
300 {
301 accessor = AccessorTemplate<CI,CT,CAM,CM> (columnBase, name, std::move (options));
302 }
303
304
305
306
307
308 template<ContainerIdConcept CI,typename CT,typename CM=ColumnarModeDefault> using ColumnAccessor = AccessorTemplate<CI,CT,ColumnAccessMode::input,CM>;
309 template<ContainerIdConcept CI,typename CT,typename CM=ColumnarModeDefault> using ColumnDecorator = AccessorTemplate<CI,CT,ColumnAccessMode::output,CM>;
310 template<ContainerIdConcept CI,typename CT,typename CM=ColumnarModeDefault> using ColumnUpdater = AccessorTemplate<CI,CT,ColumnAccessMode::update,CM>;
311}
312
313#include "ColumnAccessorXAOD.icc"
315
316#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.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
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
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
std::vector< std::string > internalLinkTargetNames
for link columns: the name(s) of the container(s) we link to
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