h5cpp  0.3.3
A modern C++ wrapper for the HDF5 C library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hyperslab.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5cpp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Authors:
23 // Eugen Wintersberger <eugen.wintersberger@desy.de>
24 // Martin Shetty <martin.shetty@esss.se>
25 // Created on: Aug 25, 2017
26 //
27 #pragma once
28 
30 #include <h5cpp/core/types.hpp>
31 #include <h5cpp/core/windows.hpp>
32 #include <memory>
33 #include <list>
34 
35 namespace hdf5 {
36 namespace dataspace {
37 
51 class DLL_EXPORT Hyperslab : public Selection {
52  public:
65  Hyperslab();
66 
70  ~Hyperslab();
71 
77  Hyperslab(const Hyperslab &) = default;
78 
91  Hyperslab(size_t rank);
92 
104  Hyperslab(const Dimensions &offset,
105  const Dimensions &block,
106  const Dimensions &count,
107  const Dimensions &stride);
108 
118  Hyperslab(const Dimensions &offset,
119  const Dimensions &block);
120 
130  //1
131  Hyperslab(const Dimensions &offset,
132  const Dimensions &count,
133  const Dimensions &stride);
134 
139  size_t rank() const noexcept;
140 
152  void offset(size_t index, size_t value);
153 
163  void offset(const Dimensions &values);
164 
170  const Dimensions &offset() const;
171 
179  void stride(size_t index, size_t value);
180 
187  void stride(const Dimensions &values);
188 
194  const Dimensions &stride() const;
195 
203  void count(size_t index, size_t value);
204 
210  void count(const Dimensions &values);
211 
221  const Dimensions &count() const;
222 
229  //1
230  void block(size_t index, size_t value);
231 
239  void block(const Dimensions &values);
240 
248  const Dimensions &block() const;
249 
250  virtual void apply(const Dataspace &space,
251  SelectionOperation ops) const;
252 
253  private:
254  inline void check_dimension_index(size_t index, const std::string &what) const {
255  if (index >= rank()) {
256  std::stringstream ss;
257  ss << "Cannot set " << what << " value at dimension " << index << " for a Hyperslab"
258  << " of rank " << rank() << "!";
259  throw std::runtime_error(ss.str());
260  }
261  }
262 
263  inline void check_container_size(const Dimensions &container, const std::string &what) const {
264  if (container.size() != rank()) {
265  std::stringstream ss;
266  ss << "Cannot assign " << container.size() << " " << what << " values to a Hyperslab"
267  << " of rank " << rank() << "!";
268  throw std::runtime_error(ss.str());
269  }
270  }
271 
272 #ifdef _MSC_VER
273 #pragma warning(push)
274 #pragma warning(disable:4251)
275 #endif
276  Dimensions start_;
277  Dimensions stride_;
278  Dimensions count_;
279  Dimensions block_;
280 #ifdef _MSC_VER
281 #pragma warning(pop)
282 #endif
283 
284 };
285 
286 DLL_EXPORT Dataspace operator||(const Dataspace &space, const Hyperslab &selection);
287 
288 } // namespace dataspace
289 } // namespace hdf5
dataspace base class
Definition: dataspace.hpp:41
selection base class
Definition: selection.hpp:42
hyperslab selection class
Definition: hyperslab.hpp:51
Definition: attribute.hpp:43
SelectionOperation
selection operator
Definition: type.hpp:95
DLL_EXPORT Dataspace operator||(const Dataspace &space, const Hyperslab &selection)
std::vector< hsize_t > Dimensions
Definition: types.hpp:36
#define DLL_EXPORT
Definition: windows.hpp:35