echelon  0.8.0
dataset_dimensions.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_DATASET_DIMENSIONS_HPP
7 #define ECHELON_DATASET_DIMENSIONS_HPP
8 
9 #include <echelon/type.hpp>
10 #include <echelon/dimension_scale.hpp>
11 
12 #include <echelon/hdf5/group.hpp>
13 #include <echelon/hdf5/type_factory.hpp>
14 
15 #include <hdf5.h> // hsize_t
16 
17 #include <string>
18 #include <cstddef>
19 
20 namespace echelon
21 {
22 
25 class dimension
26 {
27 public:
28  explicit dimension(hdf5::group containing_group_handle_, std::size_t index_);
29 
37  dimension_scale attach_dimension_scale(const std::string& name, const type& datatype);
38 
48  template <typename T>
49  dimension_scale attach_dimension_scale(const std::string& name)
50  {
51  return attach_dimension_scale(name, type(hdf5::get_hdf5_type<T>()));
52  }
53 
56  std::string label() const;
57 
62  void relabel(const std::string& new_label);
63 
66  hsize_t extend() const;
67 
68 private:
69  hdf5::group containing_group_handle_;
70  std::size_t index_;
71 };
72 
76 {
77 public:
78  explicit dataset_dimensions(hdf5::group containing_group_handle_);
79 
82  using iterator = std::vector<dimension>::iterator;
83 
86  using const_iterator = std::vector<dimension>::const_iterator;
87 
88  dataset_dimensions(dataset& associated_dataset_, std::size_t rank_);
89 
96  dimension& operator[](std::size_t index)
97  {
98  return dimensions_[index];
99  }
100 
107  const dimension& operator[](std::size_t index) const
108  {
109  return dimensions_[index];
110  }
111 
115  {
116  return dimensions_.begin();
117  }
118 
122  {
123  return dimensions_.end();
124  }
125 
129  {
130  return dimensions_.begin();
131  }
132 
136  {
137  return dimensions_.end();
138  }
139 
140 private:
141  std::vector<dimension> dimensions_;
142 };
143 }
144 
145 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
const_iterator begin() const
Iterator pointing to the first dimension.
Definition: dataset_dimensions.hpp:128
Accessor class for the dimensions of a dataset.
Definition: dataset_dimensions.hpp:75
std::vector< dimension >::iterator iterator
Type of the iterator over all dataset dimensions.
Definition: dataset_dimensions.hpp:82
iterator end()
Iterator pointing just after the last dimension.
Definition: dataset_dimensions.hpp:121
A handle to an HDF5 type.
Definition: type.hpp:21
A handle to an HDF5 group object.
Definition: hdf5/group.hpp:161
dimension_scale attach_dimension_scale(const std::string &name)
Attach a new dimension scale to this dimension.
Definition: dataset_dimensions.hpp:49
const_iterator end() const
Iterator pointing just after the last dimension.
Definition: dataset_dimensions.hpp:135
const dimension & operator[](std::size_t index) const
Access a dimension by index.
Definition: dataset_dimensions.hpp:107
hsize_t extend() const
The extend of the dimension.
Definition: dataset_dimensions.cpp:52
std::string label() const
The label of the dimension.
Definition: dataset_dimensions.cpp:38
void relabel(const std::string &new_label)
Relabel the dimension.
Definition: dataset_dimensions.cpp:45
std::vector< dimension >::const_iterator const_iterator
Type of the iterator over all dataset dimensions.
Definition: dataset_dimensions.hpp:86
Handle to a dataset dimension.
Definition: dataset_dimensions.hpp:25
A handle to an echelon dataset.
Definition: dataset.hpp:33
A handle to a dimension scale.
Definition: dimension_scale.hpp:21
dimension_scale attach_dimension_scale(const std::string &name, const type &datatype)
Attach a new dimension scale to this dimension.
Definition: dataset_dimensions.cpp:20
iterator begin()
Iterator pointing to the first dimension.
Definition: dataset_dimensions.hpp:114
dimension & operator[](std::size_t index)
Access a dimension by index.
Definition: dataset_dimensions.hpp:96