echelon  0.8.0
hdf5/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_HDF5_DATASET_DIMENSIONS_HPP
7 #define ECHELON_HDF5_DATASET_DIMENSIONS_HPP
8 
9 #include <echelon/hdf5/type.hpp>
10 #include <echelon/hdf5/type_factory.hpp>
11 #include <echelon/hdf5/object.hpp>
12 #include <echelon/hdf5/dimension_scale.hpp>
13 
14 #include <hdf5.h> // hsize_t
15 
16 #include <vector>
17 #include <string>
18 #include <cstddef>
19 
20 namespace echelon
21 {
22 namespace hdf5
23 {
26 class dimension
27 {
28 public:
29  dimension(const dataset& associated_dataset_, std::size_t index_);
30 
41  dimension_scale attach_dimension_scale(const std::string& scale_name, object location,
42  const std::string& dataset_name, const type& datatype,
43  const std::vector<hsize_t>& extent);
44 
57  template <typename T>
58  dimension_scale attach_dimension_scale(const std::string& scale_name, object location,
59  const std::string& dataset_name,
60  const std::vector<hsize_t>& extent)
61  {
62  return attach_dimension_scale(scale_name, location, dataset_name, get_hdf5_type<T>(),
63  extent);
64  }
65 
68  std::string label() const;
69 
74  void relabel(const std::string& new_label);
75 
78  hsize_t extend() const;
79 
80 private:
81  const dataset* associated_dataset_;
82  std::size_t index_;
83 };
84 
88 {
89 public:
92  typedef std::vector<dimension>::iterator iterator;
93 
96  typedef std::vector<dimension>::const_iterator const_iterator;
97 
98  dataset_dimensions(const dataset& associated_dataset_, std::size_t rank_);
99 
106  dimension& operator[](std::size_t index)
107  {
108  return dimensions_[index];
109  }
110 
117  const dimension& operator[](std::size_t index) const
118  {
119  return dimensions_[index];
120  }
121 
124  iterator begin()
125  {
126  return dimensions_.begin();
127  }
128 
131  iterator end()
132  {
133  return dimensions_.end();
134  }
135 
138  const_iterator begin() const
139  {
140  return dimensions_.begin();
141  }
142 
145  const_iterator end() const
146  {
147  return dimensions_.end();
148  }
149 
150  std::size_t count() const;
151 
152 private:
153  std::vector<dimension> dimensions_;
154 };
155 }
156 }
157 
158 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
A handle to an HDF5 dataset.
Definition: hdf5/dataset.hpp:62
dimension_scale attach_dimension_scale(const std::string &scale_name, object location, const std::string &dataset_name, const std::vector< hsize_t > &extent)
Attach a new dimension scale to this dimension.
Definition: hdf5/dataset_dimensions.hpp:58
Accessor class for the dimensions of a dataset.
Definition: hdf5/dataset_dimensions.hpp:87
iterator end()
Iterator pointing just after the last dimension.
Definition: hdf5/dataset_dimensions.hpp:131
Handle to a dataset dimension.
Definition: hdf5/dataset_dimensions.hpp:26
const_iterator end() const
Iterator pointing just after the last dimension.
Definition: hdf5/dataset_dimensions.hpp:145
const dimension & operator[](std::size_t index) const
Access a dimension by index.
Definition: hdf5/dataset_dimensions.hpp:117
std::vector< dimension >::const_iterator const_iterator
Type of the iterator over all dataset dimensions.
Definition: hdf5/dataset_dimensions.hpp:96
std::vector< dimension >::iterator iterator
Type of the iterator over all dataset dimensions.
Definition: hdf5/dataset_dimensions.hpp:92
dimension_scale attach_dimension_scale(const std::string &scale_name, object location, const std::string &dataset_name, const type &datatype, const std::vector< hsize_t > &extent)
Attach a new dimension scale to this dimension.
Definition: hdf5/dataset_dimensions.cpp:21
dimension & operator[](std::size_t index)
Access a dimension by index.
Definition: hdf5/dataset_dimensions.hpp:106
hsize_t extend() const
The extend of the dimension.
Definition: hdf5/dataset_dimensions.cpp:44
const_iterator begin() const
Iterator pointing to the first dimension.
Definition: hdf5/dataset_dimensions.hpp:138
A handle to an HDF5 type.
Definition: hdf5/type.hpp:23
A handle to a dimension scale.
Definition: hdf5/dimension_scale.hpp:26
std::string label() const
The label of the dimension.
Definition: hdf5/dataset_dimensions.cpp:34
void relabel(const std::string &new_label)
Relabel the dimension.
Definition: hdf5/dataset_dimensions.cpp:39
iterator begin()
Iterator pointing to the first dimension.
Definition: hdf5/dataset_dimensions.hpp:124