echelon  0.8.0
dataset.hpp
1 // Copyright (c) 2012-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_DATASET_HPP
7 #define ECHELON_DATASET_HPP
8 
9 #include <echelon/object.hpp>
10 #include <echelon/type.hpp>
11 #include <echelon/object_reference.hpp>
12 #include <echelon/slice.hpp>
13 #include <echelon/range.hpp>
14 #include <echelon/attribute_repository.hpp>
15 #include <echelon/dataset_dimensions.hpp>
16 #include <echelon/utility/macros.hpp>
17 
18 #include <echelon/hdf5/dataset.hpp>
19 #include <echelon/hdf5/group.hpp>
20 
21 #include <vector>
22 #include <tuple>
23 #include <string>
24 #include <type_traits>
25 #include <cassert>
26 #include <iterator>
27 
28 namespace echelon
29 {
30 
33 class dataset
34 {
35 public:
37 
40  dataset() = default;
41 
42  explicit dataset(native_handle_type native_handle_);
43 
54  template <typename T>
55  friend void operator<<=(dataset& sink, const T& source)
56  {
57  sink.dataset_handle_ <<= source;
58  }
59 
68  template <typename T>
69  friend void operator<<=(T& sink, const dataset& source)
70  {
71  sink <<= source.dataset_handle_;
72  }
73 
74  template <typename T>
75  friend void operator<<=(const hdf5::array_slice<T>& sink, const dataset& source)
76  {
77  sink <<= source.dataset_handle_;
78  }
79 
88  template<typename Container>
89  void extend_along(std::size_t dimension_index, const Container& container)
90  {
91  dataset_handle_.extend_along(dimension_index, container);
92  }
93 
96  std::vector<hsize_t> shape() const;
97 
100  std::size_t rank() const;
101 
104  type datatype() const;
105 
161  template <typename... Args>
162  slice operator()(Args... args) const
163  {
164  return slice(dataset_handle_(args...));
165  }
166 
169  object_reference ref() const;
170 
174 
177  explicit operator bool() const;
178 private:
179  hdf5::group group_handle_;
180  hdf5::dataset dataset_handle_;
181 
182 public:
186 
190 };
191 }
192 
193 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
Accessor class for the dimensions of a dataset.
Definition: dataset_dimensions.hpp:75
Attribute manager, which should be embedded into a parent object, which supports attributes.
Definition: attribute_repository.hpp:27
A handle to an HDF5 dataset.
Definition: hdf5/dataset.hpp:62
type datatype() const
The value type of the dataset.
Definition: dataset.cpp:35
native_handle_type native_handle() const
The underlying HDF5 low-level handle.
Definition: dataset.cpp:45
A handle to an HDF5 type.
Definition: type.hpp:21
void extend_along(std::size_t dimension_index, const Container &container)
Extends the dataset along a given dimension.
Definition: dataset.hpp:89
slice operator()(Args...args) const
Slices the dataset.
Definition: dataset.hpp:162
friend void operator<<=(T &sink, const dataset &source)
Reads the content of the dataset into a data sink.
Definition: dataset.hpp:69
A handle to an HDF5 group object.
Definition: hdf5/group.hpp:161
attribute_repository< dataset > attributes() const
The attributes, which are attached to the dataset.
Definition: dataset.cpp:55
std::size_t rank() const
The rank of the dataset.
Definition: dataset.cpp:30
friend void operator<<=(dataset &sink, const T &source)
Writes the content of a data source into the dataset.
Definition: dataset.hpp:55
void extend_along(std::size_t dimension_index, const Container &container) const
Extends the dataset along a given dimension.
Definition: hdf5/dataset.hpp:210
dataset_dimensions dimensions() const
The dimensions of the dataset.
Definition: dataset.cpp:60
std::vector< hsize_t > shape() const
The shape of the dataset.
Definition: dataset.cpp:25
A slice (rectangular portion) of an HDF5 dataset.
Definition: slice.hpp:22
A reference to an HDF5 object.
Definition: object_reference.hpp:24
A handle to an echelon dataset.
Definition: dataset.hpp:33
object_reference ref() const
A echelon object reference to this dataset.
Definition: dataset.cpp:40
dataset()=default
Initializes the handle with its null state.