h5cpp 0.7.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
31#include <iostream>
32
34
35namespace hdf5
36{
37
67{
68 public:
72 enum class Type
73 {
74 Uninitialized,
75 BadObject,
76 File,
77 Group,
78 Datatype,
79 Dataspace,
80 Dataset,
81 Attribute,
82 PropertyList,
83 VirtualFileLayer,
84 PropertyListClass,
85 ErrorClass,
86 ErrorMessage,
87 ErrorStack
88 };
89
93 enum class Policy
94 {
95 WithWard = 1,
96 WithoutWard= 2
97 };
98 private:
99 hid_t handle_;
100
101 //------------------------------------------------------------------------
109 void increment_reference_count() const;
110
111 //------------------------------------------------------------------------
119 void decrement_reference_count() const;
120 public:
121 //================constructors and destructors=====================
131
145 explicit ObjectHandle(hid_t id, Policy policy=Policy::WithWard);
146
147 //-----------------------------------------------------------------
154 explicit ObjectHandle() noexcept;
155
156 //-----------------------------------------------------------------
167
168 //-----------------------------------------------------------------
178
179 //-----------------------------------------------------------------
183 ~ObjectHandle() noexcept;
184
185 //================assignment operators=============================
196 ObjectHandle &operator=(const ObjectHandle &o);
197
198 //-----------------------------------------------------------------
209 ObjectHandle &operator=(ObjectHandle &&o) noexcept;
210
211
215 explicit operator hid_t() const
216 {
217 return handle_;
218 }
219
220 //=====================static member functions ====================
230 void close();
231
232 //------------------------------------------------------------------
243 bool is_valid() const;
244
245 //------------------------------------------------------------------------
252
253
254
255 //------------------------------------------------------------------------
263};
264
265
273DLL_EXPORT bool operator==(const ObjectHandle &lhs,const ObjectHandle &rhs);
274
280DLL_EXPORT bool operator!=(const ObjectHandle &lhs,const ObjectHandle &rhs);
281
285DLL_EXPORT std::ostream &operator<<(std::ostream &stream,
286 const ObjectHandle::Type &type);
287
288} // namespace hdf5
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:67
bool is_valid() const
check validity
int get_reference_count() const
return reference counter value
ObjectHandle(hid_t id, Policy policy=Policy::WithWard)
construct from HDF5 ID
ObjectHandle::Type get_type() const
get nexus object type
void close()
close the object
Policy
type of the ward policy
Definition: object_handle.hpp:94
ObjectHandle() noexcept
default constructor
Type
type of the object handle
Definition: object_handle.hpp:73
top-level namespace of the entire library
Definition: attribute.hpp:45
bool operator!=(const ObjectHandle &lhs, const ObjectHandle &rhs)
not equal to operator
std::ostream & operator<<(std::ostream &stream, const IterationOrder &order)
ouput stream for iteration order enumeration
bool operator==(const ObjectHandle &lhs, const ObjectHandle &rhs)
equality operator
#define DLL_EXPORT
Definition: windows.hpp:29