ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
AnalysisCommon
HDF5Utils
HDF5Utils
HdfTuple.h
Go to the documentation of this file.
1
// this is -*- C++ -*-
2
/*
3
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4
*/
5
6
#ifndef HDF_TUPLE_HH
7
#define HDF_TUPLE_HH
8
18
19
#include "
H5Traits.h
"
20
21
#include "H5Cpp.h"
22
23
#include <functional>
24
#include <vector>
25
#include <memory>
26
27
namespace
H5Utils
{
28
31
32
namespace
internal
{
33
34
41
template
<
typename
T>
42
data_buffer_t
get_buffer_from_func
(
const
std::function<T()>& func) {
43
data_buffer_t
buffer;
44
H5Traits<T>::ref
(buffer) = func();
45
return
buffer;
46
}
47
56
class
IVariableFiller
57
{
58
public
:
59
virtual
~IVariableFiller
() {}
60
virtual
data_buffer_t
get_buffer
()
const
= 0;
61
virtual
H5::DataType
get_type
()
const
= 0;
62
virtual
std::string
name
()
const
= 0;
63
};
64
66
template
<
typename
T>
67
class
VariableFiller
:
public
IVariableFiller
68
{
69
public
:
70
VariableFiller
(
const
std::string&,
const
std::function<T()>&);
71
internal::data_buffer_t
get_buffer
()
const
;
72
H5::DataType
get_type
()
const
;
73
std::string
name
()
const
;
74
private
:
75
std::function<T()>
m_getter
;
76
std::string
m_name
;
77
};
78
template
<
typename
T>
79
VariableFiller<T>::VariableFiller
(
const
std::string&
name
,
80
const
std::function<T()>& func):
81
m_getter
(func),
82
m_name
(
name
)
83
{
84
}
85
template
<
typename
T>
86
data_buffer_t
VariableFiller<T>::get_buffer
()
const
{
87
return
get_buffer_from_func<T>
(
m_getter
);
88
}
89
template
<
typename
T>
90
H5::DataType
VariableFiller<T>::get_type
()
const
{
91
return
H5Traits<T>::type
;
92
}
93
template
<
typename
T>
94
std::string
VariableFiller<T>::name
()
const
{
95
return
m_name
;
96
}
97
98
}
100
101
102
116
class
VariableFillers
:
117
public
std::vector<std::shared_ptr<internal::IVariableFiller> >
118
{
119
public
:
126
template
<
typename
T>
127
void
add
(
const
std::string& name,
const
std::function<T()>&);
128
};
129
130
template
<
typename
T>
131
void
VariableFillers::add
(
const
std::string& name,
132
const
std::function<T()>& fun) {
133
using
internal::VariableFiller
;
134
this->push_back(std::make_shared<VariableFiller<T> >(name, fun));
135
}
136
137
138
153
154
class
WriterXd
{
155
public
:
156
WriterXd
(H5::Group& group,
const
std::string& name,
157
VariableFillers
fillers,
158
std::vector<hsize_t> dataset_dimensions,
159
hsize_t chunk_size = 2048);
160
WriterXd
(
const
WriterXd
&) =
delete
;
161
WriterXd
&
operator=
(
WriterXd
&) =
delete
;
162
~WriterXd
();
163
void
fillWhileIncrementing
(
164
std::vector<size_t>& indices);
165
void
flush
();
166
size_t
index
()
const
;
167
private
:
168
hsize_t
buffer_size
()
const
;
169
H5::CompType
m_type
;
170
std::vector<hsize_t>
m_max_length
;
171
std::vector<hsize_t>
m_dim_stride
;
172
hsize_t
m_batch_size
;
173
hsize_t
m_offset
;
174
std::vector<internal::data_buffer_t>
m_buffer
;
175
VariableFillers
m_fillers
;
176
H5::DataSet
m_ds
;
177
};
178
179
}
180
#endif
H5Traits.h
H5Utils::VariableFillers
Variable filler arrays.
Definition
HdfTuple.h:118
H5Utils::VariableFillers::add
void add(const std::string &name, const std::function< T()> &)
Variable add method.
Definition
HdfTuple.h:131
H5Utils::WriterXd::fillWhileIncrementing
void fillWhileIncrementing(std::vector< size_t > &indices)
Definition
HdfTuple.cxx:90
H5Utils::WriterXd::m_type
H5::CompType m_type
Definition
HdfTuple.h:169
H5Utils::WriterXd::~WriterXd
~WriterXd()
Definition
HdfTuple.cxx:80
H5Utils::WriterXd::m_fillers
VariableFillers m_fillers
Definition
HdfTuple.h:175
H5Utils::WriterXd::WriterXd
WriterXd(H5::Group &group, const std::string &name, VariableFillers fillers, std::vector< hsize_t > dataset_dimensions, hsize_t chunk_size=2048)
Definition
HdfTuple.cxx:51
H5Utils::WriterXd::m_dim_stride
std::vector< hsize_t > m_dim_stride
Definition
HdfTuple.h:171
H5Utils::WriterXd::buffer_size
hsize_t buffer_size() const
Definition
HdfTuple.cxx:144
H5Utils::WriterXd::m_max_length
std::vector< hsize_t > m_max_length
Definition
HdfTuple.h:170
H5Utils::WriterXd::operator=
WriterXd & operator=(WriterXd &)=delete
H5Utils::WriterXd::m_ds
H5::DataSet m_ds
Definition
HdfTuple.h:176
H5Utils::WriterXd::index
size_t index() const
Definition
HdfTuple.cxx:140
H5Utils::WriterXd::m_offset
hsize_t m_offset
Definition
HdfTuple.h:173
H5Utils::WriterXd::m_buffer
std::vector< internal::data_buffer_t > m_buffer
Definition
HdfTuple.h:174
H5Utils::WriterXd::m_batch_size
hsize_t m_batch_size
Definition
HdfTuple.h:172
H5Utils::WriterXd::flush
void flush()
Definition
HdfTuple.cxx:115
H5Utils::WriterXd::WriterXd
WriterXd(const WriterXd &)=delete
H5Utils::internal::IVariableFiller
Variable fillers.
Definition
HdfTuple.h:57
H5Utils::internal::IVariableFiller::~IVariableFiller
virtual ~IVariableFiller()
Definition
HdfTuple.h:59
H5Utils::internal::IVariableFiller::get_type
virtual H5::DataType get_type() const =0
H5Utils::internal::IVariableFiller::get_buffer
virtual data_buffer_t get_buffer() const =0
H5Utils::internal::IVariableFiller::name
virtual std::string name() const =0
H5Utils::internal::VariableFiller
implementation for variable filler
Definition
HdfTuple.h:68
H5Utils::internal::VariableFiller::m_getter
std::function< T()> m_getter
Definition
HdfTuple.h:75
H5Utils::internal::VariableFiller::get_buffer
internal::data_buffer_t get_buffer() const
Definition
HdfTuple.h:86
H5Utils::internal::VariableFiller::name
std::string name() const
Definition
HdfTuple.h:94
H5Utils::internal::VariableFiller::VariableFiller
VariableFiller(const std::string &, const std::function< T()> &)
Definition
HdfTuple.h:79
H5Utils::internal::VariableFiller::get_type
H5::DataType get_type() const
Definition
HdfTuple.h:90
H5Utils::internal::VariableFiller::m_name
std::string m_name
Definition
HdfTuple.h:76
H5Utils::internal
clssses to add type traits for H5
Definition
CompressedTypes.h:18
H5Utils::internal::get_buffer_from_func
data_buffer_t get_buffer_from_func(const std::function< T()> &func)
Buffer element harvester.
Definition
HdfTuple.h:42
H5Utils
HDF5 Tuple Writer.
Definition
CompressedTypes.h:16
H5Utils::internal::H5Traits
We have lots of code to get around HDF5's rather weak typing.
Definition
H5Traits.h:54
H5Utils::internal::data_buffer_t
data_buffer_t
Definition
H5Traits.h:34
Generated on
for ATLAS Offline Software by
1.17.0