echelon  0.8.0
hdf5/dimension_scale.hpp
1 // Copyright (c) 2013-2014 Christopher Hinz
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef ECHELON_HDF5_DIMENSION_SCALE_HPP
7 #define ECHELON_HDF5_DIMENSION_SCALE_HPP
8 
9 #include <echelon/hdf5/storage_layer.hpp>
10 #include <echelon/hdf5/container_adaption.hpp> //for shape_adl
11 #include <echelon/object.hpp>
12 
13 #include <echelon/hdf5/precursor/dimension_scale.hpp>
14 
15 #include <string>
16 
17 namespace echelon
18 {
19 namespace hdf5
20 {
21 class dataset;
22 class type;
23 
27 {
28 public:
31  using native_handle_type = hdf5::precursor::dimension_scale;
32 
33  dimension_scale(object location, const std::string& dataset_name, const type& datatype,
34  const std::vector<hsize_t>& extent, const std::string& scale_name);
35 
38  std::vector<hsize_t> shape() const;
39 
50  template <typename T>
51  friend void operator<<=(dimension_scale& sink, const T& source)
52  {
53  auto current_shape = shape_adl(source);
54 
55  std::vector<hsize_t> mem_shape(begin(current_shape), end(current_shape));
56 
57  hdf5::precursor::dataspace mem_space(mem_shape);
58  hdf5::precursor::dataspace file_space = sink.dim_scale_.get_space();
59  hdf5::precursor::type datatype = sink.dim_scale_.datatype();
60 
61  write(sink.dim_scale_, datatype, mem_space, file_space, source);
62  }
63 
72  template <typename T>
73  friend void operator<<=(T& sink, const dimension_scale& source)
74  {
75  auto current_shape = shape_adl(sink);
76 
77  std::vector<hsize_t> mem_shape(begin(current_shape), end(current_shape));
78 
79  hdf5::precursor::dataspace mem_space(mem_shape);
80  hdf5::precursor::dataspace file_space = source.dim_scale_.get_space();
81  hdf5::precursor::type datatype = source.dim_scale_.datatype();
82 
83  read(source.dim_scale_, datatype, mem_space, file_space, sink);
84  }
85 
88  const native_handle_type& native_handle() const;
89 
90 private:
91  hdf5::precursor::dimension_scale dim_scale_;
92 };
93 }
94 }
95 
96 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
std::vector< hsize_t > shape() const
The shape of the dimension scale.
Definition: hdf5/dimension_scale.cpp:26
friend void operator<<=(dimension_scale &sink, const T &source)
Writes the content of a data source into the dimension scale.
Definition: hdf5/dimension_scale.hpp:51
friend void operator<<=(T &sink, const dimension_scale &source)
Reads the content of the dimension scale into a data sink.
Definition: hdf5/dimension_scale.hpp:73
A handle to an HDF5 type.
Definition: hdf5/type.hpp:23
const native_handle_type & native_handle() const
The underlying HDF5 low-level handle.
Definition: hdf5/dimension_scale.cpp:31
A handle to a dimension scale.
Definition: hdf5/dimension_scale.hpp:26
hdf5::precursor::dimension_scale native_handle_type
Type of the underlying HDF5 low-level handle.
Definition: hdf5/dimension_scale.hpp:31