h5cpp  0.4.1
A modern C++ wrapper for the HDF5 C library
object_handle.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5pp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Authors:
23 // Eugen Wintersberger <eugen.wintersberger@desy.de>
24 // Martin Shetty <martin.shetty@esss.se>
25 // Created on: Aug 07, 2017
26 //
27 
28 #pragma once
29 
30 #include <h5cpp/core/hdf5_capi.hpp>
31 #include <iostream>
32 
33 #include <h5cpp/core/windows.hpp>
34 
35 namespace hdf5
36 {
37 
67 {
68  public:
69  enum class Type
70  {
71  UNINITIALIZED,
72  BADOBJECT,
73  FILE,
74  GROUP,
75  DATATYPE,
76  DATASPACE,
77  DATASET,
78  ATTRIBUTE,
79  PROPERTY_LIST,
80  VIRTUAL_FILE_LAYER,
81  PROPERTY_LIST_CLASS,
82  ERROR_CLASS,
83  ERROR_MESSAGE,
84  ERROR_STACK
85  };
86 
87  enum class Policy
88  {
89  WITH_WARD = 1,
90  WITHOUT_WARD = 2
91  };
92  private:
93  hid_t handle_;
94 
95  //------------------------------------------------------------------------
103  void increment_reference_count() const;
104 
105  //------------------------------------------------------------------------
113  void decrement_reference_count() const;
114  public:
115  //================constructors and destructors=====================
125 
132  explicit ObjectHandle(hid_t id, Policy policy=Policy::WITH_WARD);
140 
141  //-----------------------------------------------------------------
148  explicit ObjectHandle() noexcept;
149 
150  //-----------------------------------------------------------------
160  ObjectHandle(const ObjectHandle &o);
161 
162  //-----------------------------------------------------------------
171  ObjectHandle(ObjectHandle &&o) noexcept;
172 
173  //-----------------------------------------------------------------
177  ~ObjectHandle() noexcept;
178 
179  //================assignment operators=============================
190  ObjectHandle &operator=(const ObjectHandle &o);
191 
192  //-----------------------------------------------------------------
203  ObjectHandle &operator=(ObjectHandle &&o) noexcept;
204 
205 
209  explicit operator hid_t() const
210  {
211  return handle_;
212  }
213 
214  //=====================static member functions ====================
224  void close();
225 
226  //------------------------------------------------------------------
237  bool is_valid() const;
238 
239  //------------------------------------------------------------------------
245  ObjectHandle::Type get_type() const;
246 
247 
248 
249  //------------------------------------------------------------------------
256  int get_reference_count() const;
257 };
258 
259 
267 DLL_EXPORT bool operator==(const ObjectHandle &lhs,const ObjectHandle &rhs);
268 
274 DLL_EXPORT bool operator!=(const ObjectHandle &lhs,const ObjectHandle &rhs);
275 
279 DLL_EXPORT std::ostream &operator<<(std::ostream &stream,
280  const ObjectHandle::Type &type);
281 
282 } // namespace hdf5
bool operator!=(const ObjectHandle &lhs, const ObjectHandle &rhs)
not equal to operator
bool operator==(const ObjectHandle &lhs, const ObjectHandle &rhs)
equality operator
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:66
Policy
Definition: object_handle.hpp:87
Definition: attribute.hpp:43
Type
Definition: object_handle.hpp:69
#define DLL_EXPORT
Definition: windows.hpp:35
std::ostream & operator<<(std::ostream &stream, const IterationOrder &order)
ouput stream for iteration order enumeration