hops
H5DataSpace.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3  *
4  * Distributed under the Boost Software License, Version 1.0.
5  * (See accompanying file LICENSE_1_0.txt or copy at
6  * http://www.boost.org/LICENSE_1_0.txt)
7  *
8  */
9 #ifndef H5DATASPACE_HPP
10 #define H5DATASPACE_HPP
11 
12 #include <vector>
13 #include <array>
14 #include <cstdint>
15 #include <type_traits>
16 #include <initializer_list>
17 
18 #ifdef H5_USE_BOOST
19 // starting Boost 1.64, serialization header must come before ublas
20 #include <boost/serialization/vector.hpp>
21 #include <boost/multi_array.hpp>
22 #include <boost/numeric/ublas/matrix.hpp>
23 #endif
24 
25 #ifdef H5_USE_EIGEN
26 #include <Eigen/Eigen>
27 #endif
28 
29 #include "H5Object.hpp"
30 #include "bits/H5_definitions.hpp"
31 
32 namespace HighFive {
33 
37 class DataSpace : public Object {
38  public:
39 
41 
42  static const size_t UNLIMITED = SIZE_MAX;
43 
48  // simple dataspace are handle directly from their dimensions
49  };
50 
56  explicit DataSpace(const std::vector<size_t>& dims);
57 
61  DataSpace(const std::initializer_list<size_t>& items);
62 
65  template<typename... Args>
66  explicit DataSpace(size_t dim1, Args... dims);
67 
71  template <typename IT, typename = typename std::enable_if<!std::is_integral<IT>::value,IT>::type>
72  DataSpace(const IT begin,
73  const IT end);
74 
78  explicit DataSpace(const std::vector<size_t>& dims,
79  const std::vector<size_t>& maxdims);
80 
84  explicit DataSpace(DataspaceType dtype);
85 
88  DataSpace clone() const;
89 
94  size_t getNumberDimensions() const;
95 
99  std::vector<size_t> getDimensions() const;
100 
103  size_t getElementCount() const;
104 
108  std::vector<size_t> getMaxDimensions() const;
109 
113  template <typename ScalarValue>
114  static DataSpace From(const ScalarValue& scalar_value);
115 
121  template <typename Value>
122  static DataSpace From(const std::vector<Value>& container);
123 
126  template <typename Value, std::size_t N>
127  static DataSpace From(const std::array<Value, N>&);
128 
129  template <typename ValueT, std::size_t N>
130  static DataSpace From(const ValueT(&container)[N]);
131 
132  template <std::size_t N, std::size_t Width>
133  static DataSpace FromCharArrayStrings(const char(&)[N][Width]);
134 
135 #ifdef H5_USE_BOOST
136  template <typename Value, std::size_t Dims>
137  static DataSpace From(const boost::multi_array<Value, Dims>& container);
138 
139  template <typename Value>
140  static DataSpace From(const boost::numeric::ublas::matrix<Value>& mat);
141 #endif
142 
143 #ifdef H5_USE_EIGEN
144  template <typename Value, int M, int N>
145  static DataSpace From(const Eigen::Matrix<Value, M, N>& mat);
146 
147  template <typename Value, int M, int N>
148  static DataSpace From(const std::vector<Eigen::Matrix<Value, M, N>>& vec);
149 #ifdef H5_USE_BOOST
150  template <typename Value, int M, int N, size_t Dims>
151  static DataSpace From(const boost::multi_array<Eigen::Matrix<Value, M, N>, Dims>& vec);
152 #endif
153 #endif
154 
155  protected:
156  DataSpace() = default;
157 
158  friend class Attribute;
159  friend class File;
160  friend class DataSet;
161 };
162 
163 } // namespace HighFive
164 
165 // We include bits right away since DataSpace is user-constructible
166 #include "bits/H5Dataspace_misc.hpp"
167 
168 #endif // H5DATASPACE_HPP
HighFive::DataSpace::DataspaceType
DataspaceType
dataspace type
Definition: H5DataSpace.hpp:45
HighFive::DataSpace::type
const static ObjectType type
Definition: H5DataSpace.hpp:40
H5Object.hpp
HighFive::DataSpace::UNLIMITED
static const size_t UNLIMITED
Definition: H5DataSpace.hpp:42
HighFive::DataSpace::getDimensions
std::vector< size_t > getDimensions() const
getDimensions
Definition: H5Dataspace_misc.hpp:99
HighFive::DataSpace::datascape_null
@ datascape_null
Definition: H5DataSpace.hpp:47
HighFive::DataSpace::DataSpace
DataSpace()=default
H5Dataspace_misc.hpp
HighFive::ObjectType::DataSpace
@ DataSpace
HighFive::DataSpace::From
static DataSpace From(const ScalarValue &scalar_value)
Definition: H5Dataspace_misc.hpp:129
HighFive::Object
Definition: H5Object.hpp:36
HighFive::ObjectType
ObjectType
Enum of the types of objects (H5O api)
Definition: H5Object.hpp:25
HighFive::DataSpace::getMaxDimensions
std::vector< size_t > getMaxDimensions() const
getMaxDimensions
Definition: H5Dataspace_misc.hpp:116
HighFive::File
File class.
Definition: H5File.hpp:24
HighFive::DataSpace::FromCharArrayStrings
static DataSpace FromCharArrayStrings(const char(&)[N][Width])
Definition: H5Dataspace_misc.hpp:162
HighFive::Attribute
Class representing an attribute of a dataset or group.
Definition: H5Attribute.hpp:23
HighFive::DataSpace::getElementCount
size_t getElementCount() const
getElementCount
Definition: H5Dataspace_misc.hpp:110
HighFive::DataSpace::datascape_scalar
@ datascape_scalar
Definition: H5DataSpace.hpp:46
HighFive::DataSpace
Class representing the space (dimensions) of a dataset.
Definition: H5DataSpace.hpp:37
HighFive::DataSpace::clone
DataSpace clone() const
Definition: H5Dataspace_misc.hpp:82
HighFive::DataSpace::getNumberDimensions
size_t getNumberDimensions() const
getNumberDimensions
Definition: H5Dataspace_misc.hpp:90
HighFive::DataSet
Class representing a dataset.
Definition: H5DataSet.hpp:27
HighFive
Definition: H5_definitions.hpp:15
H5_definitions.hpp