2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 /// @author Nils Krumnack
8 #include <ColumnarCore/ColumnarTool.h>
9 #include <ColumnarCore/ColumnAccessorDataArray.h>
10 #include <ColumnarCore/ObjectId.h>
11 #include <ColumnarCore/ObjectRange.h>
12 #include <ColumnarCore/ContainerId.h>
17 template<ContainerIdConcept CI>
18 class AccessorTemplate<CI,ObjectColumn,ColumnAccessMode::input,ColumnarModeArray> final
20 /// Common Public Members
21 /// =====================
24 static_assert (CI::perEventRange || CI::perEventId, "ObjectColumn can only be used with per-event ranges or IDs");
26 using CM = ColumnarModeArray;
28 AccessorTemplate (ColumnarTool<CM>& columnBase,
29 const std::string& name)
30 : m_columnBase (&columnBase),
33 columnBase.setContainerStoreName (CI::idName, name);
34 m_offsetsData = std::make_unique<ColumnAccessorDataArray> (&m_offsetsIndex, &m_offsetsData, &typeid (ColumnarOffsetType), ColumnAccessMode::input);
35 columnBase.addColumn (name, m_offsetsData.get(), {.offsetName = (CI::perEventRange ? numberOfEventsName : ""), .isOffset = true});
38 AccessorTemplate (AccessorTemplate&& that)
40 moveAccessor (m_offsetsIndex, m_offsetsData, that.m_offsetsIndex, that.m_offsetsData);
43 // cppcheck-suppress operatorEqVarError; m_columnBase not copied
44 AccessorTemplate& operator = (AccessorTemplate&& that)
47 moveAccessor (m_offsetsIndex, m_offsetsData, that.m_offsetsIndex, that.m_offsetsData);
51 AccessorTemplate (const AccessorTemplate&) = delete;
52 AccessorTemplate& operator = (const AccessorTemplate&) = delete;
54 ObjectRange<CI,CM> operator() (ObjectId<ContainerId::eventContext,CM> eventId) const
55 requires (CI::perEventRange)
57 auto *offsets = static_cast<const ColumnarOffsetType*>(eventId.getData()[m_offsetsIndex]);
58 return ObjectRange<CI,CM> (eventId.getData(), offsets[eventId.getIndex()], offsets[eventId.getIndex() + 1]);
61 ObjectRange<CI,CM> operator() (ObjectRange<ContainerId::eventContext,CM> eventRange) const
62 requires (CI::perEventRange)
64 auto *offsets = static_cast<const ColumnarOffsetType*>(eventRange.getData()[m_offsetsIndex]);
65 return ObjectRange<CI,CM> (eventRange.getData(), offsets[eventRange.beginIndex()], offsets[eventRange.endIndex()]);
68 ObjectId<CI,CM> operator() (ObjectId<ContainerId::eventContext,CM> eventId) const
69 requires (CI::perEventId)
71 return ObjectId<CI,CM> (eventId.getData(), eventId.getIndex());
74 ObjectRange<CI,CM> operator() (ObjectRange<ContainerId::eventContext,CM> eventRange) const
75 requires (CI::perEventId)
77 return ObjectRange<CI,CM> (eventRange.getData(), eventRange.beginIndex(), eventRange.endIndex());
86 ColumnarTool<CM> *m_columnBase = nullptr;
89 unsigned m_offsetsIndex = 0;
90 std::unique_ptr<ColumnAccessorDataArray> m_offsetsData;