ATLAS Offline Software
Loading...
Searching...
No Matches
VariantAccessor.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_VARIANT_VARIANT_ACCESSOR_H
9#define COLUMNAR_VARIANT_VARIANT_ACCESSOR_H
10
13#include <boost/mp11/tuple.hpp>
14
15namespace columnar
16{
17 // the column accessor for variant objects in array columnar modes
18 //
19 // This internally contains a tuple of accessors, one for each
20 // variant. This is probably not the best way to implement it, but it
21 // fits best with the current accessor infrastructure.
24 class AccessorTemplate<VariantContainerId<CIBase,CIList...>,CT,CAM,CM> final
25 {
28 public:
29
30 static_assert (!std::is_const_v<CT>, "CT must not be const");
31
32 using CI = VariantContainerId<CIBase,CIList...>;
33
34 AccessorTemplate () noexcept = default;
35
36 AccessorTemplate (ColumnarTool<CM>& columnarTool, const std::string& name, ColumnAccessorOptions&& options = {})
37 {
38 for (std::size_t index = 0u; index < CI::numVariants; ++index)
39 m_accessors[index] = detail::ContainerFreeAccessor<CT,CAM,CM>(columnarTool, ColumnAccessorOptions(options), detail::ColumnAccessorOptionsArray {.offsetName = CI::idNameArray[index], .baseName = std::string (CI::idNameArray[index]) + "." + name});
40 }
41
42 [[nodiscard]] decltype(auto) operator () (ObjectId<CI,CM> id) const
43 {
44 if (id.getVariantIndex() >= CI::numVariants)
45 throw std::out_of_range ("invalid variant index in VariantContainerId accessor");
46 return m_accessors[id.getVariantIndex()](id.getDataArea(), id.getObjectIndex());
47 }
48
49 [[nodiscard]] bool isAvailable (ObjectId<CI,CM> id) const
50 {
51 if (id.getVariantIndex() >= CI::numVariants)
52 throw std::out_of_range ("invalid variant index in VariantContainerId accessor");
53 return m_accessors[id.getVariantIndex()].isAvailable(id.getDataArea());
54 }
55
58 private:
59
60 std::array<detail::ContainerFreeAccessor<CT,CAM,CM>, CI::numVariants> m_accessors;
61 };
62}
63
64#endif
std::array< detail::ContainerFreeAccessor< CT, CAM, CM >, CI::numVariants > m_accessors
the base class for all columnar components
a class representing a single object (electron, muons, etc.)
the backend implementation for AccessorTemplate
ColumnAccessMode
an enum for the different access modes for a column
Definition ColumnInfo.h:19
Definition index.py:1
STL namespace.
a "variant" ContainerId
Definition VariantDef.h:98