h5cpp  0.6.1
A modern C++ wrapper for the HDF5 C library
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 #include <sstream>
35 
36 namespace hdf5 {
37 namespace dataspace {
38 
52 class DLL_EXPORT Hyperslab : public Selection {
53  public:
67 
71  ~Hyperslab() override;
72 
78  Hyperslab(const Hyperslab &) = default;
79 
92  Hyperslab(size_t rank);
93 
105  Hyperslab(const Dimensions &offset,
106  const Dimensions &block,
107  const Dimensions &count,
108  const Dimensions &stride);
109 
119  Hyperslab(const Dimensions &offset,
120  const Dimensions &block);
121 
131  //1
132  Hyperslab(const Dimensions &offset,
133  const Dimensions &count,
134  const Dimensions &stride);
135 
140  size_t rank() const noexcept;
141 
153  void offset(size_t index, size_t value);
154 
164  void offset(const Dimensions &values);
165 
171  const Dimensions &offset() const;
172 
180  void stride(size_t index, size_t value);
181 
188  void stride(const Dimensions &values);
189 
195  const Dimensions &stride() const;
196 
204  void count(size_t index, size_t value);
205 
211  void count(const Dimensions &values);
212 
222  const Dimensions &count() const;
223 
230  //1
231  void block(size_t index, size_t value);
232 
240  void block(const Dimensions &values);
241 
249  const Dimensions &block() const;
250 
251  virtual void apply(const Dataspace &space,
252  SelectionOperation ops) const override;
253 
264  virtual Dimensions dimensions() const override;
265 
275  virtual size_t size() const override;
276 
284  virtual SelectionType type() const override;
285 
286  private:
287  inline void check_dimension_index(size_t index, const std::string &what) const {
288  if (index >= rank()) {
289  std::stringstream ss;
290  ss << "Cannot set " << what << " value at dimension " << index << " for a Hyperslab"
291  << " of rank " << rank() << "!";
292  throw std::runtime_error(ss.str());
293  }
294  }
295 
296  inline void check_container_size(const Dimensions &container, const std::string &what) const {
297  if (container.size() != rank()) {
298  std::stringstream ss;
299  ss << "Cannot assign " << container.size() << " " << what << " values to a Hyperslab"
300  << " of rank " << rank() << "!";
301  throw std::runtime_error(ss.str());
302  }
303  }
304 
305 #ifdef _MSC_VER
306 #pragma warning(push)
307 #pragma warning(disable:4251)
308 #endif
309  Dimensions start_;
310  Dimensions stride_;
311  Dimensions count_;
312  Dimensions block_;
313 #ifdef _MSC_VER
314 #pragma warning(pop)
315 #endif
316 
317 };
318 
319 DLL_EXPORT Dataspace operator||(const Dataspace &space, const Hyperslab &selection);
320 
322 
324 
325 } // namespace dataspace
326 } // namespace hdf5
dataspace base class
Definition: dataspace.hpp:41
hyperslab selection class
Definition: hyperslab.hpp:52
Hyperslab(const Dimensions &offset, const Dimensions &count, const Dimensions &stride)
constructor
size_t rank() const noexcept
get rank
Hyperslab(const Dimensions &offset, const Dimensions &block, const Dimensions &count, const Dimensions &stride)
constructor
~Hyperslab() override
destructor
Hyperslab(const Hyperslab &)=default
copy constructor
Hyperslab()
default constructor
Hyperslab(size_t rank)
constructor
Hyperslab(const Dimensions &offset, const Dimensions &block)
constructor
selection base class
Definition: selection.hpp:42
Dataspace operator||(const Dataspace &space, const Hyperslab &selection)
std::list< OperationWithSelection > SelectionList
Definition: selection.hpp:130
SelectionOperation
selection operator
Definition: type.hpp:95
SelectionList operator|(const Hyperslab &a, const Hyperslab &b)
SelectionType
selection type
Definition: type.hpp:71
top-level namespace of the entire library
Definition: attribute.hpp:45
std::vector< hsize_t > Dimensions
Definition: types.hpp:32
#define DLL_EXPORT
Definition: windows.hpp:29