libpniio
object_imp.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. ee 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 14, 2014
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 
24 #pragma once
25 
26 extern "C"{
27 #include <hdf5.h>
28 }
29 
30 #include <pni/core/types.hpp>
31 #include "../../exceptions.hpp"
32 #include "h5object_types.hpp"
33 #include "../nxobject_type.hpp"
34 
35 namespace pni{
36 namespace io{
37 namespace nx{
38 namespace h5{
39 
59  class object_imp
60  {
61  private:
62  hid_t _id;
63  protected:
64 
65  //-----------------------------------------------------------------
72  void reset_id() noexcept { _id = 0; }
73 
74  //----------------------------------------------------------------
84  void inc_ref();
85 
86  public:
87  //================constructors and destructors=====================
97 
104 
112  explicit object_imp(hid_t &&id);
119 
120  //-----------------------------------------------------------------
127  explicit object_imp() noexcept;
128 
129  //-----------------------------------------------------------------
142  object_imp(const object_imp &o);
143 
144  //-----------------------------------------------------------------
154  object_imp(object_imp &&o) noexcept;
155 
156  //-----------------------------------------------------------------
164  ~object_imp();
165 
166 
167  //================assignment operators=============================
181  object_imp &operator=(const object_imp &o);
182 
183  //-----------------------------------------------------------------
196  object_imp &operator=(object_imp &&o) noexcept;
197 
198 
199  //=====================basic object maniuplation====================
212  void close();
213 
214  //------------------------------------------------------------------
226  bool is_valid() const;
227 
228  //------------------------------------------------------------------
236  const hid_t &id() const noexcept;
237 
238  //-----------------------------------------------------------------
248  pni::io::nx::nxobject_type nxobject_type() const;
249  };
250 
251  //===================equality operators for H5Object instances=============
268  bool operator==(const object_imp &a,const object_imp &b);
269 
270  //-------------------------------------------------------------------------
284  bool operator!=(const object_imp &a,const object_imp &b);
285 
286 
287 //end of namespace
288 }
289 }
290 }
291 }
bool is_valid() const
check validity
Definition: object_imp.cpp:117
nxobject_type
Nexus typd ids.
Definition: nxobject_type.hpp:39
Definition: cbf_reader.hpp:41
basic HDF5 ID wrapper
Definition: object_imp.hpp:59
void inc_ref()
increments reference counter
Definition: object_imp.cpp:37
object_imp() noexcept
default constructor
Definition: object_imp.cpp:57
void close()
close the object
Definition: object_imp.cpp:136
void reset_id() noexcept
reset the ID
Definition: object_imp.hpp:72
hid_t _id
ID of the object.
Definition: object_imp.hpp:62