ATLAS Offline Software
Loading...
Searching...
No Matches
columnar::TestUtils::ManualColumnData Class Referencefinal

a class that holds manually specified column data More...

#include <ManualColumnData.h>

Collaboration diagram for columnar::TestUtils::ManualColumnData:

Public Member Functions

 ManualColumnData (std::vector< std::any > &&data)
 standard constructor
void configureType (const std::string &columnName, const std::type_info &type)
 configure for the given type
const std::type_info * type () const noexcept
 get the type we are configured for
template<typename T>
std::span< const T > getSpan (const std::string &name) const
 get the configured column as an std::span
std::size_t columnSize () const noexcept
 get the size of the column
void * columnVoidData () noexcept
 get the data pointer for the column

Private Attributes

std::vector< std::any > m_data
 a vector of untyped data provided by the user
const std::type_info * m_type = nullptr
 the actual type for the column
std::shared_ptr< void > m_column
 the column created from m_data

Detailed Description

a class that holds manually specified column data

This is for use in unit test code to allow users specifying a column as a simple list of values, e.g.

columnMap.addColumn ({1.0f, 2, 3u});

Internally this represents the user data as a vector of std::any, and then converts it to the appropriate type when asked. This is not particularly efficient, but it is only meant for use in unit tests, where ease of use is more important than efficiency.

Definition at line 38 of file ManualColumnData.h.

Constructor & Destructor Documentation

◆ ManualColumnData()

columnar::TestUtils::ManualColumnData::ManualColumnData ( std::vector< std::any > && data)

standard constructor

Public Members

Definition at line 63 of file ManualColumnData.cxx.

65 : m_data (std::move (data))
66 {
67 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
std::vector< std::any > m_data
a vector of untyped data provided by the user

Member Function Documentation

◆ columnSize()

std::size_t columnar::TestUtils::ManualColumnData::columnSize ( ) const
inlinenodiscardnoexcept

get the size of the column

Definition at line 67 of file ManualColumnData.h.

67 {
68 return m_data.size(); }

◆ columnVoidData()

void * columnar::TestUtils::ManualColumnData::columnVoidData ( )
inlinenodiscardnoexcept

get the data pointer for the column

Definition at line 71 of file ManualColumnData.h.

71 {
72 return m_column.get(); }
std::shared_ptr< void > m_column
the column created from m_data

◆ configureType()

void columnar::TestUtils::ManualColumnData::configureType ( const std::string & columnName,
const std::type_info & type )

configure for the given type

Definition at line 71 of file ManualColumnData.cxx.

73 {
74 // I could check whether the type matches an already configured
75 // type, but by not doing so I allow the user to reset the column
76 // data if it got overwritten by the tool.
77
78 if (type == typeid(float))
79 {
80 m_column = castGetAnyColumn<float> (columnName, m_data);
81 } else if (type == typeid(char))
82 {
83 m_column = castGetAnyColumn<char> (columnName, m_data);
84 } else if (type == typeid(int))
85 {
86 m_column = castGetAnyColumn<int> (columnName, m_data);
87 } else if (type == typeid(std::uint8_t))
88 {
89 m_column = castGetAnyColumn<std::uint8_t> (columnName, m_data);
90 } else if (type == typeid(std::uint16_t))
91 {
92 m_column = castGetAnyColumn<std::uint16_t> (columnName, m_data);
93 } else if (type == typeid(std::uint32_t))
94 {
95 m_column = castGetAnyColumn<std::uint32_t> (columnName, m_data);
96 } else if (type == typeid(std::uint64_t))
97 {
98 m_column = castGetAnyColumn<std::uint64_t> (columnName, m_data);
99 } else
100 throw std::runtime_error (
101 columnName + ": column has unsupported type " +
102 boost::core::demangle(type.name()) +
103 ", extend test handler to support it");
104 m_type = &type;
105 }
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

◆ getSpan()

template<typename T>
std::span< const T > columnar::TestUtils::ManualColumnData::getSpan ( const std::string & name) const
inlinenodiscard

get the configured column as an std::span

Definition at line 57 of file ManualColumnData.h.

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 }
unsigned long long T

◆ type()

const std::type_info * columnar::TestUtils::ManualColumnData::type ( ) const
inlinenodiscardnoexcept

get the type we are configured for

Definition at line 52 of file ManualColumnData.h.

52 {
53 return m_type; }

Member Data Documentation

◆ m_column

std::shared_ptr<void> columnar::TestUtils::ManualColumnData::m_column
private

the column created from m_data

Definition at line 87 of file ManualColumnData.h.

◆ m_data

std::vector<std::any> columnar::TestUtils::ManualColumnData::m_data
private

a vector of untyped data provided by the user

Private Members

Definition at line 81 of file ManualColumnData.h.

◆ m_type

const std::type_info* columnar::TestUtils::ManualColumnData::m_type = nullptr
private

the actual type for the column

Definition at line 84 of file ManualColumnData.h.


The documentation for this class was generated from the following files: