-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathhdfdataset.hpp
121 lines (109 loc) · 3.43 KB
/
hdfdataset.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef hdfdatasetH
#define hdfdatasetH
#include <hdf5/slab.hpp>
#include <hdf5/hdf5/traits.hpp>
#include <stdexcept>
namespace hdf {
template<class HDFImpl=HDF5Traits>
class HDFDataSet : std::enable_shared_from_this<HDFDataSet<HDFImpl> > {
public:
HDFDataSet(std::shared_ptr<typename HDFImpl::dataset_type> dataset)
: dataset(dataset) {
}
template<typename Type>
std::shared_ptr<HDFDataSet<HDFImpl> >
selectSubset(const std::vector<Type> & mapping) {
if(mapping.empty()) throw std::runtime_error("No mapping available");
dataset = dataset->selectSubset(mapping);
return this->shared_from_this();
}
template<typename Type>
void
writeData(const Type &data) {
HDFImpl::write_dataset(*dataset, data);
}
#ifdef H5_HAVE_PARALLEL
template<typename Type>
void
writeParallelData(const Type &data) {
HDFImpl::write_parallel_dataset(*dataset, data);
}
#endif
template<int order, typename Type>
void
writeData(const Type &data, const Slab<order, HDFImpl> & mem) {
HDFImpl::write_dataset(*dataset, data, mem);
}
template<int order, typename Type>
void
writeData(const Type &data,
const Slab<order, HDFImpl> & mem,
const Slab<order, HDFImpl> & filespace) {
HDFImpl::write_dataset(*dataset, data, mem, filespace);
}
#ifdef H5_HAVE_PARALLEL
template<int order, typename Type>
void
writeParallelData(const Type &data, const Slab<order, HDFImpl> & mem) {
HDFImpl::write_parallel_dataset(*dataset, data, mem);
}
template<int order, typename Type>
void
writeParallelData(const Type &data,
const Slab<order, HDFImpl> & memSpace,
const Slab<order, HDFImpl> & fileSpace) {
HDFImpl::write_parallel_dataset(*dataset, data, memSpace, fileSpace);
}
#endif
template<int order, typename Type>
void
writeData(const std::vector<Type> &data, const Slab<order, HDFImpl> & mem) {
HDFImpl::write_dataset(*dataset, &data[0], mem);
}
template<typename Type>
void
readData(std::vector<Type> & data) {
HDFImpl::read_dataset(*dataset, data);
}
template<int order, typename Type>
void
readData(Type *data, const Slab<order, HDFImpl> & mem) {
HDFImpl::read_dataset(*dataset, data, mem);
}
template<int order, typename Type>
void
readData(Type *data, const Slab<order, HDFImpl> & mem,
const Slab<order, HDFImpl> & filespace) {
HDFImpl::read_dataset(*dataset, data, mem,filespace);
}
#ifdef H5_HAVE_PARALLEL
template<int order, typename Type>
void
readParallelData(Type *data, const Slab<order, HDFImpl> & mem) {
HDFImpl::read_parallel_dataset(*dataset, data, mem);
}
template<int order, typename Type>
void
readParallelData(const Type &data,
const Slab<order, HDFImpl> & memSpace,
const Slab<order, HDFImpl> & fileSpace) {
HDFImpl::read_parallel_dataset(*dataset, data, memSpace, fileSpace);
}
#endif
std::vector<hsize_t>
getDimensions() const {
return dataset->getDataSpace()->getDimensions();
}
template<typename Type>
void
readData(Type *data) {
HDFImpl::read_dataset(*dataset, data);
}
template<class Type>
operator Type() {
}
private:
std::shared_ptr<typename HDFImpl::dataset_type> dataset;
};
}
#endif