h5cpp  0.3.3
A modern C++ wrapper for the HDF5 C library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  REFERENCE,
81  VIRTUAL_FILE_LAYER,
82  PROPERTY_LIST_CLASS,
83  ERROR_CLASS,
84  ERROR_MESSAGE,
85  ERROR_STACK
86  };
87 
88  enum class Policy
89  {
90  WITH_WARD = 1,
91  WITHOUT_WARD = 2
92  };
93  private:
94  hid_t handle_;
95 
96  //------------------------------------------------------------------------
104  void increment_reference_count() const;
105 
106  //------------------------------------------------------------------------
114  void decrement_reference_count() const;
115  public:
116  //================constructors and destructors=====================
126 
133  explicit ObjectHandle(hid_t id, Policy policy=Policy::WITH_WARD);
139 
140  //-----------------------------------------------------------------
147  explicit ObjectHandle() noexcept;
148 
149  //-----------------------------------------------------------------
159  ObjectHandle(const ObjectHandle &o);
160 
161  //-----------------------------------------------------------------
170  ObjectHandle(ObjectHandle &&o) noexcept;
171 
172  //-----------------------------------------------------------------
176  ~ObjectHandle() noexcept;
177 
178  //================assignment operators=============================
189  ObjectHandle &operator=(const ObjectHandle &o);
190 
191  //-----------------------------------------------------------------
202  ObjectHandle &operator=(ObjectHandle &&o) noexcept;
203 
204 
208  explicit operator hid_t() const
209  {
210  return handle_;
211  }
212 
213  //=====================static member functions ====================
223  void close();
224 
225  //------------------------------------------------------------------
236  bool is_valid() const;
237 
238  //------------------------------------------------------------------------
244  ObjectHandle::Type get_type() const;
245 
246 
247 
248  //------------------------------------------------------------------------
255  int get_reference_count() const;
256 };
257 
258 
266 DLL_EXPORT bool operator==(const ObjectHandle &lhs,const ObjectHandle &rhs);
267 
273 DLL_EXPORT bool operator!=(const ObjectHandle &lhs,const ObjectHandle &rhs);
274 
278 DLL_EXPORT std::ostream &operator<<(std::ostream &stream,
279  const ObjectHandle::Type &type);
280 
281 } // namespace hdf5
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:66
DLL_EXPORT std::ostream & operator<<(std::ostream &stream, const IterationIndex &index)
DLL_EXPORT bool operator!=(const ObjectHandle &lhs, const ObjectHandle &rhs)
not equal to operator
Policy
Definition: object_handle.hpp:88
Definition: attribute.hpp:43
Type
Definition: object_handle.hpp:69
#define DLL_EXPORT
Definition: windows.hpp:35
DLL_EXPORT bool operator==(const ObjectHandle &lhs, const ObjectHandle &rhs)
equality operator