libpniio
h5dataspace.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2014 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpniio.
5 //
6 // libpniio is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpniio is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpniio. If not, see <http://www.gnu.org/licenses/>.
18 // ===========================================================================
19 //
20 // Created on: Jul 15, 2014
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 #pragma once
24 
25 #include "object_imp.hpp"
26 #include "type_imp.hpp"
27 
28 namespace pni{
29 namespace io{
30 namespace nx {
31 namespace h5 {
32 
33  //forward declaration of selection
34  class selection;
35 
69  {
70  public:
74  typedef type_imp::index_vector_type::const_iterator iterator;
75  private:
82 
83  //-----------------------------------------------------------------
87  void __init_buffers() noexcept;
88 
89  //-----------------------------------------------------------------
99  void __update_dataspace();
100 
101  //----------------------------------------------------------------
105  void __update_buffers();
106 
107  public:
108  //==============constructors and destructor========================
119  explicit h5dataspace();
120 
121  //-----------------------------------------------------------------
133  h5dataspace(object_imp &&o);
134 
135  //-----------------------------------------------------------------
147  explicit h5dataspace(const type_imp::index_vector_type &shape);
148 
149  //----------------------------------------------------------------
161  explicit h5dataspace(type_imp::index_vector_type &&shape);
162 
163  //=====================convenience methods========================
176  size_t rank() const;
177 
178  //-----------------------------------------------------------------
182  hid_t id() const noexcept;
183 
184  //-----------------------------------------------------------------
194  bool is_valid() const;
195 
196  //-----------------------------------------------------------------
208  size_t size() const;
209 
210  //----------------------------------------------------------------
220  bool has_selection() const;
221 
222  //----------------------------------------------------------------
226  const type_imp::index_vector_type &shape() const noexcept;
227 
228  //-----------------------------------------------------------------
244  void grow(size_t dim=0,size_t ext=1) ;
245 
246  //----------------------------------------------------------------
257  void apply_selection(const selection &s) const ;
258 
259  //----------------------------------------------------------------
263  void reset_selection() const noexcept;
264 
265  //----------------------------------------------------------------
273  const object_imp &object() const noexcept;
274 
275  };
276 
277  //--------------------------------------------------------------------
287  std::ostream &operator<<(std::ostream &o,const h5dataspace &s);
288 
289 //end of namespace
290 }
291 }
292 }
293 }
size_t rank() const
rank of dataset
Definition: h5dataspace.cpp:131
void apply_selection(const selection &s) const
apply selection
Definition: h5dataspace.cpp:190
dataspace object
Definition: h5dataspace.hpp:68
void __init_buffers() noexcept
initialize buffers
Definition: h5dataspace.cpp:69
object_imp _object
The HDF5 object representing the dataspace.
Definition: h5dataspace.hpp:77
type_imp::index_vector_type _maxdims
maximum number of elements dimensions
Definition: h5dataspace.hpp:81
type_imp::index_vector_type _dims
number of elements
Definition: h5dataspace.hpp:79
size_t size() const
total number of elements
Definition: h5dataspace.cpp:141
const type_imp::index_vector_type & shape() const noexcept
return reference to the current dimensions buffer
Definition: h5dataspace.cpp:153
void reset_selection() const noexcept
reset selection
Definition: h5dataspace.cpp:209
STL namespace.
provide implementation specific types
Definition: type_imp.hpp:46
void __update_buffers()
update the buffers
Definition: h5dataspace.cpp:58
Definition: cbf_reader.hpp:41
void grow(size_t dim=0, size_t ext=1)
grow dataspace
Definition: h5dataspace.cpp:174
basic HDF5 ID wrapper
Definition: object_imp.hpp:59
describe a selection in an HDF5 file
Definition: selection.hpp:37
type_imp::index_vector_type::const_iterator iterator
buffer iterator
Definition: h5dataspace.hpp:74
bool is_valid() const
check validity status
Definition: h5dataspace.cpp:125
type_imp::index_type value_type
value type for buffers
Definition: h5dataspace.hpp:72
std::vector< index_type > index_vector_type
container type for counters
Definition: type_imp.hpp:52
void __update_dataspace()
setup dataspace
Definition: h5dataspace.cpp:40
hsize_t index_type
index type
Definition: type_imp.hpp:49
bool has_selection() const
true if selection is set on this dataspace
Definition: h5dataspace.cpp:159