ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Columnar
ColumnarTestFixtures
Root
ManualColumnData.cxx
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
//
9
// includes
10
//
11
12
#include <
ColumnarTestFixtures/ManualColumnData.h
>
13
14
#include <cstdint>
15
#include <stdexcept>
16
17
//
18
// method implementations
19
//
20
21
namespace
columnar
22
{
23
namespace
TestUtils
24
{
25
namespace
26
{
27
template
<
typename
T>
28
T
castGetAny (
const
std::string& columnName,
const
std::any& value)
29
{
30
if
(
value
.type() ==
typeid
(
float
))
31
return
std::any_cast<float> (value);
32
if
(
value
.type() ==
typeid
(
double
))
33
return
std::any_cast<double> (value);
34
if
(
value
.type() ==
typeid
(
char
))
35
return
std::any_cast<char> (value);
36
if
(
value
.type() ==
typeid
(
int
))
37
return
std::any_cast<int> (value);
38
if
(
value
.type() ==
typeid
(
unsigned
))
39
return
std::any_cast<unsigned> (value);
40
if
(
value
.type() ==
typeid
(std::size_t))
41
return
std::any_cast<std::size_t> (value);
42
throw
std::logic_error (columnName +
": received unsupported input type "
+ boost::core::demangle(
value
.type().name()) +
", cast value or extend test handler to support it"
);
43
}
44
template
<
typename
T>
45
std::vector<T> castGetAnyVector (
const
std::string& columnName,
const
std::vector<std::any>& value)
46
{
47
std::vector<T>
result
;
48
result
.reserve (
value
.size());
49
for
(
auto
& v : value)
50
result
.push_back (castGetAny<T> (columnName, v));
51
return
result
;
52
}
53
template
<
typename
T>
54
std::shared_ptr<void> castGetAnyColumn (
const
std::string& columnName,
const
std::vector<std::any>& value)
55
{
56
auto
vec
= std::make_shared<std::vector<T>> (castGetAnyVector<T> (columnName, value));
57
return
std::shared_ptr<void> (
vec
,
vec
->data());
58
}
59
}
60
61
62
63
ManualColumnData ::
64
ManualColumnData (std::vector<std::any>&& data)
65
:
m_data
(
std
::move (data))
66
{
67
}
68
69
70
71
void
ManualColumnData ::
72
configureType (
const
std::string& columnName,
const
std::type_info&
type
)
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
}
106
}
107
}
vec
std::vector< size_t > vec
Definition
CombinationsGeneratorTest.cxx:9
ManualColumnData.h
columnar::TestUtils::ManualColumnData::m_column
std::shared_ptr< void > m_column
the column created from m_data
Definition
ManualColumnData.h:87
columnar::TestUtils::ManualColumnData::type
const std::type_info * type() const noexcept
get the type we are configured for
Definition
ManualColumnData.h:52
columnar::TestUtils::ManualColumnData::m_type
const std::type_info * m_type
the actual type for the column
Definition
ManualColumnData.h:84
columnar::TestUtils::ManualColumnData::m_data
std::vector< std::any > m_data
a vector of untyped data provided by the user
Definition
ManualColumnData.h:81
TSU::T
unsigned long long T
Definition
L1TopoDataTypes.h:36
athena.value
value
Definition
athena.py:126
columnar::TestUtils
Definition
Benchmark.h:20
columnar
Definition
ClusterDef.h:16
get_generator_info.result
result
Definition
get_generator_info.py:21
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0