Skip to content

Commit 1ade5e6

Browse files
author
trile965
committed
Merge commit 'dbf41f8' into HEAD
2 parents 07a11fa + dbf41f8 commit 1ade5e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4191
-1396
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export(Read10XH5Content)
4949
export(ReadColSumSpMt)
5050
export(ReadDoubleVector)
5151
export(ReadIntegerVector)
52-
export(ReadRootDataset)
5352
export(ReadRowSumSpMt)
5453
export(ReadSpMt)
5554
export(ReadSpMtAsS4)

R/RcppExports.R

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,6 @@ WriteRootDataset <- function(filePath, datasetName, datasetVal) {
165165
invisible(.Call(`_Signac_WriteRootDataset`, filePath, datasetName, datasetVal))
166166
}
167167

168-
#' ReadRootDataset
169-
#'
170-
#' Read a string vector from root group
171-
#'
172-
#' @param filePath A fiel path
173-
#' @param datasetName A dataset name
174-
#' @export
175-
ReadRootDataset <- function(filePath, datasetName) {
176-
.Call(`_Signac_ReadRootDataset`, filePath, datasetName)
177-
}
178-
179168
#' ReadIntegerVector
180169
#'
181170
#' This function is used to read a integer vector from hdf5 file

inst/highfive/H5Attribute.hpp

100755100644
Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,27 @@
1111

1212
#include <vector>
1313

14+
#include "H5DataSpace.hpp"
15+
#include "H5DataType.hpp"
1416
#include "H5Object.hpp"
17+
#include "bits/H5Path_traits.hpp"
1518

1619
namespace HighFive {
1720

18-
template <typename Derivate>
19-
class AnnotateTraits;
20-
class DataType;
21-
class DataSpace;
22-
23-
class Attribute : public Object {
21+
///
22+
/// \brief Class representing an attribute of a dataset or group
23+
///
24+
class Attribute : public Object,
25+
public PathTraits<Attribute> {
2426
public:
27+
28+
const static ObjectType type = ObjectType::Attribute;
29+
30+
///
31+
/// \brief return the name of the current attribute
32+
/// \return the name of the attribute
33+
std::string getName() const;
34+
2535
size_t getStorageSize() const;
2636

2737
///
@@ -53,6 +63,12 @@ class Attribute : public Object {
5363
template <typename T>
5464
void read(T& array) const;
5565

66+
///
67+
/// Read the attribute into a buffer
68+
///
69+
template <typename T>
70+
void read(T* array, const DataType& dtype = DataType()) const;
71+
5672
///
5773
/// Write the integrality N-dimension buffer to this attribute
5874
/// An exception is raised if the numbers of dimension of the buffer and of
@@ -63,13 +79,22 @@ class Attribute : public Object {
6379
template <typename T>
6480
void write(const T& buffer);
6581

82+
///
83+
/// Write a buffer to this attribute
84+
///
85+
template <typename T>
86+
void write_raw(const T* buffer, const DataType& dtype = DataType());
87+
88+
// No empty attributes
89+
Attribute() = delete;
90+
6691
private:
67-
Attribute();
68-
template <typename Derivate>
69-
friend class ::HighFive::AnnotateTraits;
92+
using Object::Object;
93+
94+
template <typename Derivate> friend class ::HighFive::AnnotateTraits;
7095
};
71-
}
7296

73-
#include "bits/H5Attribute_misc.hpp"
97+
} // namespace HighFive
98+
7499

75100
#endif // H5ATTRIBUTE_HPP

inst/highfive/H5DataSet.hpp

100755100644
Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,39 @@
1111

1212
#include <vector>
1313

14+
#include "H5DataSpace.hpp"
15+
#include "H5DataType.hpp"
1416
#include "H5Object.hpp"
17+
#include "bits/H5_definitions.hpp"
1518
#include "bits/H5Annotate_traits.hpp"
1619
#include "bits/H5Slice_traits.hpp"
20+
#include "bits/H5Path_traits.hpp"
21+
#include "bits/H5_definitions.hpp"
1722

1823
namespace HighFive {
1924

20-
template <typename Derivate>
21-
class NodeTraits;
22-
template <typename Derivate>
23-
class SliceTraits;
24-
class DataType;
25-
class DataSpace;
26-
25+
///
26+
/// \brief Class representing a dataset.
27+
///
2728
class DataSet : public Object,
2829
public SliceTraits<DataSet>,
29-
public AnnotateTraits<DataSet> {
30+
public AnnotateTraits<DataSet>,
31+
public PathTraits<DataSet> {
3032
public:
31-
size_t getStorageSize() const;
33+
34+
const static ObjectType type = ObjectType::Dataset;
35+
36+
///
37+
/// \brief getStorageSize
38+
/// \return returns the amount of storage allocated for a dataset.
39+
///
40+
uint64_t getStorageSize() const;
41+
42+
///
43+
/// \brief getOffset
44+
/// \return returns DataSet address in file
45+
///
46+
uint64_t getOffset() const;
3247

3348
///
3449
/// \brief getDataType
@@ -49,27 +64,45 @@ class DataSet : public Object,
4964
///
5065
DataSpace getMemSpace() const;
5166

52-
///
53-
/// \brief getOffset
54-
/// \return returns DataSet address in file
55-
/// class
56-
///
57-
size_t getOffset() const;
58-
67+
5968
/// \brief Change the size of the dataset
6069
///
6170
/// This requires that the dataset was created with chunking, and you would
6271
/// generally want to have set a larger maxdims setting
6372
/// \param dims New size of the dataset
6473
void resize(const std::vector<size_t>& dims);
6574

66-
private:
67-
DataSet();
68-
template <typename Derivate>
69-
friend class ::HighFive::NodeTraits;
75+
76+
/// \brief Get the dimensions of the whole DataSet.
77+
/// This is a shorthand for getSpace().getDimensions()
78+
/// \return The shape of the current HighFive::DataSet
79+
///
80+
inline std::vector<size_t> getDimensions() const {
81+
return getSpace().getDimensions();
82+
}
83+
84+
/// \brief Get the total number of elements in the current dataset.
85+
/// E.g. 2x2x2 matrix has size 8.
86+
/// This is a shorthand for getSpace().getTotalCount()
87+
/// \return The shape of the current HighFive::DataSet
88+
///
89+
inline size_t getElementCount() const {
90+
return getSpace().getElementCount();
91+
}
92+
93+
H5_DEPRECATED("Default constructor creates unsafe uninitialized objects")
94+
DataSet() = default;
95+
96+
protected:
97+
using Object::Object; // bring DataSet(hid_t)
98+
99+
DataSet(Object&& o) noexcept : Object(std::move(o)) {}
100+
101+
friend class Reference;
102+
template <typename Derivate> friend class NodeTraits;
103+
70104
};
71-
}
72105

73-
#include "bits/H5DataSet_misc.hpp"
106+
} // namespace HighFive
74107

75108
#endif // H5DATASET_HPP

inst/highfive/H5DataSpace.hpp

100755100644
Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,35 @@
1616
#include <initializer_list>
1717

1818
#ifdef H5_USE_BOOST
19-
20-
// In some versions of Boost (starting with 1.64), you have to include the serialization header before ublas
19+
// starting Boost 1.64, serialization header must come before ublas
2120
#include <boost/serialization/vector.hpp>
22-
2321
#include <boost/multi_array.hpp>
2422
#include <boost/numeric/ublas/matrix.hpp>
2523
#endif
2624

25+
#ifdef H5_USE_EIGEN
26+
#include <Eigen/Eigen>
27+
#endif
28+
2729
#include "H5Object.hpp"
30+
#include "bits/H5_definitions.hpp"
2831

2932
namespace HighFive {
3033

31-
class File;
32-
class DataSet;
33-
34+
///
35+
/// \brief Class representing the space (dimensions) of a dataset
36+
///
3437
class DataSpace : public Object {
3538
public:
3639

40+
const static ObjectType type = ObjectType::DataSpace;
41+
3742
static const size_t UNLIMITED = SIZE_MAX;
3843

3944
/// dataspace type
4045
enum DataspaceType {
41-
datascape_scalar,
42-
datascape_null
46+
dataspace_scalar,
47+
dataspace_null
4348
// simple dataspace are handle directly from their dimensions
4449
};
4550

@@ -50,10 +55,14 @@ class DataSpace : public Object {
5055
/// etc...
5156
explicit DataSpace(const std::vector<size_t>& dims);
5257

58+
// create a dataspace of N-dimensions
59+
template <size_t N>
60+
explicit DataSpace(const std::array<size_t, N>& dims);
61+
5362
/// Make sure that DataSpace({1,2,3}) works on GCC. This is
54-
/// the shortcut form of the vector initalizer, but one some compilers (gcc)
63+
/// the shortcut form of the vector initializer, but one some compilers (gcc)
5564
/// this does not resolve correctly without this constructor.
56-
explicit DataSpace(std::initializer_list<size_t> items);
65+
DataSpace(const std::initializer_list<size_t>& items);
5766

5867
/// Allow directly listing 1 or more dimensions to initialize,
5968
/// that is, DataSpace(1,2) means DataSpace(std::vector<size_t>{1,2}).
@@ -68,8 +77,8 @@ class DataSpace : public Object {
6877
const IT end);
6978

7079
/// \brief Create a resizable N-dimensional dataspace
71-
/// \params dims Initial size of dataspace
72-
/// \params maxdims Maximum size of the dataspace
80+
/// \param dims Initial size of dataspace
81+
/// \param maxdims Maximum size of the dataspace
7382
explicit DataSpace(const std::vector<size_t>& dims,
7483
const std::vector<size_t>& maxdims);
7584

@@ -93,48 +102,33 @@ class DataSpace : public Object {
93102
/// associated dataset dimension
94103
std::vector<size_t> getDimensions() const;
95104

105+
/// \brief getElementCount
106+
/// \return the total number of elements in the dataspace
107+
size_t getElementCount() const;
108+
96109
/// \brief getMaxDimensions
97110
/// \return return a vector of N-element, each element is the size of the
98111
/// associated dataset maximum dimension
99112
std::vector<size_t> getMaxDimensions() const;
100113

101-
/// Create a dataspace matching a single element of a basic type
102-
/// supported type are integrals (int,long), floating points (float,double)
103-
/// and std::string
104-
template <typename ScalarValue>
105-
static DataSpace From(const ScalarValue& scalar_value);
114+
/// Create a dataspace matching a type accepted by details::inspector
115+
template <typename T>
116+
static DataSpace From(const T& value);
106117

107-
/// Create a dataspace matching the container dimensions and size
108-
/// Supported Containers are:
109-
/// - vector of fundamental types
110-
/// - vector of std::string
111-
/// - boost::multi_array (with H5_USE_BOOST defined)
112-
template <typename Value>
113-
static DataSpace From(const std::vector<Value>& vec);
114-
115-
/// Create a dataspace matching the container dimensions for a
116-
/// std::array.
117-
template <typename Value, std::size_t N>
118-
static DataSpace From(const std::array<Value, N>&);
119-
120-
121-
#ifdef H5_USE_BOOST
122-
template <typename Value, std::size_t Dims>
123-
static DataSpace From(const boost::multi_array<Value, Dims>& container);
124-
125-
template <typename Value>
126-
static DataSpace From(const boost::numeric::ublas::matrix<Value>& mat);
127-
#endif
118+
template <std::size_t N, std::size_t Width>
119+
static DataSpace FromCharArrayStrings(const char(&)[N][Width]);
128120

129121
protected:
130-
explicit DataSpace();
122+
DataSpace() = default;
131123

132124
friend class Attribute;
133125
friend class File;
134126
friend class DataSet;
135127
};
136-
}
137128

129+
} // namespace HighFive
130+
131+
// We include bits right away since DataSpace is user-constructible
138132
#include "bits/H5Dataspace_misc.hpp"
139133

140134
#endif // H5DATASPACE_HPP

0 commit comments

Comments
 (0)