ATLAS Offline Software
Loading...
Searching...
No Matches
ManualColumnData.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_TEST_FIXTURES_MANUAL_COLUMN_DATA_H
9#define COLUMNAR_TEST_FIXTURES_MANUAL_COLUMN_DATA_H
10
11#include <boost/core/demangle.hpp>
12
13#include <any>
14#include <memory>
15#include <span>
16#include <stdexcept>
17#include <string>
18#include <vector>
19
20namespace columnar
21{
22 namespace TestUtils
23 {
37
38 class ManualColumnData final
39 {
42 public:
43
45 ManualColumnData (std::vector<std::any>&& data);
46
47
49 void configureType (const std::string& columnName, const std::type_info& type);
50
52 [[nodiscard]] const std::type_info* type() const noexcept {
53 return m_type; }
54
56 template<typename T>
57 [[nodiscard]] std::span<const T> getSpan (const std::string& name) const
58 {
59 if (m_type == nullptr)
60 throw std::runtime_error ("column " + name + " not configured");
61 if (*m_type != typeid(T))
62 throw std::runtime_error ("column " + name + " has wrong type: " + boost::core::demangle(m_type->name()) + " != " + boost::core::demangle(typeid(T).name()));
63 return std::span<const T> (static_cast<const T*> (m_column.get()), m_data.size());
64 }
65
67 [[nodiscard]] std::size_t columnSize () const noexcept {
68 return m_data.size(); }
69
71 [[nodiscard]] void* columnVoidData() noexcept {
72 return m_column.get(); }
73
74
75
78 private:
79
81 std::vector<std::any> m_data;
82
84 const std::type_info *m_type = nullptr;
85
87 std::shared_ptr<void> m_column;
88 };
89 }
90}
91
92#endif
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
std::shared_ptr< void > m_column
the column created from m_data
const std::type_info * type() const noexcept
get the type we are configured for
const std::type_info * m_type
the actual type for the column
ManualColumnData(std::vector< std::any > &&data)
standard constructor
void configureType(const std::string &columnName, const std::type_info &type)
configure for the given type
std::vector< std::any > m_data
a vector of untyped data provided by the user
std::size_t columnSize() const noexcept
get the size of the column
void * columnVoidData() noexcept
get the data pointer for the column
std::span< const T > getSpan(const std::string &name) const
get the configured column as an std::span