libpniio
group_imp.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2011 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: Jan 10, 2012
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 #pragma once
24 
25 #include <pni/core/types.hpp>
26 
27 #include "object_imp.hpp"
28 #include "type_imp.hpp"
29 #include "hdf5_utilities.hpp"
30 #include "attribute_utils.hpp"
31 #include "attribute_imp.hpp"
32 
33 
34 namespace pni{
35 namespace io{
36 namespace nx{
37 namespace h5{
38 
47  class group_imp
48  {
49  private:
52  public:
53  //==========constructors and destructors===========================
57  explicit group_imp() noexcept;
58 
59  //-----------------------------------------------------------------
69  explicit group_imp(object_imp &&o);
70 
71  //-----------------------------------------------------------------
83  explicit group_imp(const group_imp &parent,
84  const pni::core::string &name);
85 
86  //=================methods to open objects==========================
106  object_imp at(const pni::core::string &name) const;
107 
108  //-----------------------------------------------------------------
123  object_imp at(size_t i) const;
124 
125  //----------------------------------------------------------------
129  const object_imp &object() const noexcept;
130 
131  //======================misc methods===============================
144  void remove(const pni::core::string &n) const;
145 
146  //----------------------------------------------------------------
158  void remove(size_t i) const;
159  //-----------------------------------------------------------------
174  bool has_child(const pni::core::string &name) const;
175 
176  //-----------------------------------------------------------------
188  size_t size() const;
189 
190  //----------------------------------------------------------------
203  pni::core::string name() const;
204 
205  //---------------------------------------------------------------
216  object_imp parent() const;
217 
218  //----------------------------------------------------------------
231  pni::core::string filename() const;
232 
233  //----------------------------------------------------------------
246  void close();
247 
248  //----------------------------------------------------------------
258  bool is_valid() const;
259 
260  //----------------------------------------------------------------
275  attribute_imp attr(const pni::core::string &name,
276  pni::core::type_id_t tid,
277  bool overwrite=false) const;
278 
279  //----------------------------------------------------------------
295  attribute_imp attr(const pni::core::string &name,
296  pni::core::type_id_t tid,
297  const type_imp::index_vector_type &shape,
298  bool overwrite=false) const;
299 
300  //----------------------------------------------------------------
311  attribute_imp attr(const pni::core::string &name) const;
312 
313  //----------------------------------------------------------------
324  attribute_imp attr(size_t i) const;
325 
326  //----------------------------------------------------------------
337  size_t nattr() const;
338 
339  //----------------------------------------------------------------
352  bool has_attr(const pni::core::string &name) const;
353 
354  //----------------------------------------------------------------
367  void del_attr(const pni::core::string &name) const;
368 
369 
370  };
371 
372 
373 
374 //end of namespace
375 }
376 }
377 }
378 }
void close()
close the group
Definition: group_imp.cpp:183
bool is_valid() const
check group validity
Definition: group_imp.cpp:189
pni::core::string name() const
get name
Definition: group_imp.cpp:171
size_t size() const
number of child nodes
Definition: group_imp.cpp:154
void del_attr(const pni::core::string &name) const
delete an attribute
Definition: group_imp.cpp:219
attribute implementation
Definition: attribute_imp.hpp:45
provide implementation specific types
Definition: type_imp.hpp:46
HDF5 group object.
Definition: group_imp.hpp:47
bool has_child(const pni::core::string &name) const
check for the existance of an object
Definition: group_imp.cpp:104
Definition: cbf_reader.hpp:41
object_imp parent() const
get parent object
Definition: group_imp.cpp:177
basic HDF5 ID wrapper
Definition: object_imp.hpp:59
object_imp _object
the HDF5 object representing the group
Definition: group_imp.hpp:51
object_imp at(const pni::core::string &name) const
get child by name
group_imp() noexcept
default constructor
Definition: group_imp.cpp:43
pni::core::string filename() const
get filename
Definition: group_imp.cpp:148
bool has_attr(const pni::core::string &name) const
check if attribute exists
Definition: group_imp.cpp:213
size_t nattr() const
get number of attributes
Definition: group_imp.cpp:207
void remove(const pni::core::string &n) const
remove an object
attribute_imp attr(const pni::core::string &name, pni::core::type_id_t tid, bool overwrite=false) const
create scalar attribute