ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 More...
 
void configureType (const std::string &columnName, const std::type_info &type)
 configure for the given type More...
 
const std::type_info * type () const noexcept
 get the type we are configured for More...
 
template<typename T >
std::span< const T > getSpan (const std::string &name) const
 get the configured column as an std::span More...
 
std::size_t columnSize () const noexcept
 get the size of the column More...
 
void * columnVoidData () noexcept
 get the data pointer for the column More...
 

Private Attributes

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

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  }

Member Function Documentation

◆ columnSize()

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

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 ( )
inlinenoexcept

get the data pointer for the column

Definition at line 71 of file ManualColumnData.h.

71  {
72  return m_column.get(); }

◆ 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  }

◆ getSpan()

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

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  }

◆ type()

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

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:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:558
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
columnar::TestUtils::ManualColumnData::m_column
std::shared_ptr< void > m_column
the column created from m_data
Definition: ManualColumnData.h:87
columnar::TestUtils::ManualColumnData::m_type
const std::type_info * m_type
the actual type for the column
Definition: ManualColumnData.h:84
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
columnar::TestUtils::ManualColumnData::m_data
std::vector< std::any > m_data
a vector of untyped data provided by the user
Definition: ManualColumnData.h:81
columnar::TestUtils::ManualColumnData::type
const std::type_info * type() const noexcept
get the type we are configured for
Definition: ManualColumnData.h:52
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35