1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-09 21:50:45 +01:00

Hdf5Type does not need to be a pointer anymore

This commit is contained in:
Antonin Portelli 2017-01-19 18:23:55 -08:00
parent 6eea9e4da7
commit ade1058e5f
3 changed files with 11 additions and 11 deletions

View File

@ -12,7 +12,7 @@ Hdf5Writer::Hdf5Writer(const std::string &fileName)
{ {
group_ = file_.openGroup("/"); group_ = file_.openGroup("/");
writeSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold", writeSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
*Hdf5Type<unsigned int>::type()); Hdf5Type<unsigned int>::type());
} }
void Hdf5Writer::push(const std::string &s) void Hdf5Writer::push(const std::string &s)
@ -62,7 +62,7 @@ Hdf5Reader::Hdf5Reader(const std::string &fileName)
{ {
group_ = file_.openGroup("/"); group_ = file_.openGroup("/");
readSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold", readSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold",
*Hdf5Type<unsigned int>::type()); Hdf5Type<unsigned int>::type());
} }
void Hdf5Reader::push(const std::string &s) void Hdf5Reader::push(const std::string &s)

View File

@ -92,7 +92,7 @@ namespace Grid
template <typename U> template <typename U>
void Hdf5Writer::writeDefault(const std::string &s, const U &x) void Hdf5Writer::writeDefault(const std::string &s, const U &x)
{ {
writeSingleAttribute(x, s, *Hdf5Type<U>::type()); writeSingleAttribute(x, s, Hdf5Type<U>::type());
} }
template <> template <>
@ -122,7 +122,7 @@ namespace Grid
{ {
H5NS::DataSet dataSet; H5NS::DataSet dataSet;
dataSet = group_.createDataSet(s, *Hdf5Type<Element>::type(), dataSpace); dataSet = group_.createDataSet(s, Hdf5Type<Element>::type(), dataSpace);
dataSet.write(flatx.data(), *Hdf5Type<Element>::type()); dataSet.write(flatx.data(), *Hdf5Type<Element>::type());
} }
else else
@ -140,7 +140,7 @@ namespace Grid
{ {
push(s); push(s);
writeSingleAttribute(x.size(), HDF5_GRID_GUARD "vector_size", writeSingleAttribute(x.size(), HDF5_GRID_GUARD "vector_size",
*Hdf5Type<uint64_t>::type()); Hdf5Type<uint64_t>::type());
for (hsize_t i = 0; i < x.size(); ++i) for (hsize_t i = 0; i < x.size(); ++i)
{ {
write(s + "_" + std::to_string(i), x[i]); write(s + "_" + std::to_string(i), x[i]);
@ -162,7 +162,7 @@ namespace Grid
template <typename U> template <typename U>
void Hdf5Reader::readDefault(const std::string &s, U &output) void Hdf5Reader::readDefault(const std::string &s, U &output)
{ {
readSingleAttribute(output, s, *Hdf5Type<U>::type()); readSingleAttribute(output, s, Hdf5Type<U>::type());
} }
template <> template <>
@ -210,14 +210,14 @@ namespace Grid
H5NS::DataSet dataSet; H5NS::DataSet dataSet;
dataSet = group_.openDataSet(s); dataSet = group_.openDataSet(s);
dataSet.read(buf.data(), *Hdf5Type<Element>::type()); dataSet.read(buf.data(), Hdf5Type<Element>::type());
} }
else else
{ {
H5NS::Attribute attribute; H5NS::Attribute attribute;
attribute = group_.openAttribute(s); attribute = group_.openAttribute(s);
attribute.read(*Hdf5Type<Element>::type(), buf.data()); attribute.read(Hdf5Type<Element>::type(), buf.data());
} }
// reconstruct the multidimensional vector // reconstruct the multidimensional vector
@ -234,7 +234,7 @@ namespace Grid
push(s); push(s);
readSingleAttribute(size, HDF5_GRID_GUARD "vector_size", readSingleAttribute(size, HDF5_GRID_GUARD "vector_size",
*Hdf5Type<uint64_t>::type()); Hdf5Type<uint64_t>::type());
x.resize(size); x.resize(size);
for (hsize_t i = 0; i < x.size(); ++i) for (hsize_t i = 0; i < x.size(); ++i)
{ {

View File

@ -12,9 +12,9 @@
template <>\ template <>\
struct Hdf5Type<cType>\ struct Hdf5Type<cType>\
{\ {\
static inline const H5NS::PredType *type(void)\ static inline const H5NS::PredType & type(void)\
{\ {\
return &H5NS::PredType::predType;\ return H5NS::PredType::predType;\
}\ }\
static constexpr bool isNative = true;\ static constexpr bool isNative = true;\
}; };