VTK
9.6.20260311
Main Page
Related Pages
Topics
Namespaces
Classes
Files
File List
File Members
IO
HDFTools
vtkHDF5ScopedHandle.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2
// SPDX-License-Identifier: BSD-3-Clause
3
#ifndef vtkHDF5ScopedHandle_h
4
#define vtkHDF5ScopedHandle_h
5
6
#include "vtkABINamespace.h"
7
#include "vtk_hdf5.h"
8
9
#include <algorithm>
10
11
namespace
vtkHDF
12
{
13
VTK_ABI_NAMESPACE_BEGIN
14
18
#define DefineScopedHandle(name) \
19
class ScopedH5##name##Handle \
20
{ \
21
public: \
22
ScopedH5##name##Handle() \
23
: Handle(H5I_INVALID_HID) \
24
{ \
25
} \
26
ScopedH5##name##Handle(ScopedH5##name##Handle&& other) noexcept \
27
{ \
28
this->Handle = other.Handle; \
29
other.Handle = H5I_INVALID_HID; \
30
} \
31
ScopedH5##name##Handle& operator=(ScopedH5##name##Handle&& other) noexcept \
32
{ \
33
std::swap(this->Handle, other.Handle); \
34
return *this; \
35
} \
36
ScopedH5##name##Handle(const ScopedH5##name##Handle& other) = delete; \
37
ScopedH5##name##Handle& operator=(const ScopedH5##name##Handle&) = delete; \
38
ScopedH5##name##Handle(hid_t handle) \
39
: Handle(handle) \
40
{ \
41
} \
42
virtual ~ScopedH5##name##Handle() \
43
{ \
44
if (this->Handle >= 0) \
45
{ \
46
H5##name##close(this->Handle); \
47
} \
48
} \
49
\
50
operator hid_t() const \
51
{ \
52
return this->Handle; \
53
} \
54
\
55
private: \
56
hid_t Handle; \
57
};
58
59
// Defines ScopedH5AHandle closed with H5Aclose
60
DefineScopedHandle
(A);
61
62
// Defines ScopedH5DHandle closed with H5Dclose
63
DefineScopedHandle
(D);
64
65
// Defines ScopedH5FHandle closed with H5Fclose
66
DefineScopedHandle
(F);
67
68
// Defines ScopedH5GHandle closed with H5Gclose
69
DefineScopedHandle
(G);
70
71
// Defines ScopedH5PHandle closed with H5Pclose
72
DefineScopedHandle
(P);
73
74
// Defines ScopedH5SHandle closed with H5Sclose
75
DefineScopedHandle
(S);
76
77
// Defines ScopedH5THandle closed with H5Tclose
78
DefineScopedHandle
(T);
79
80
VTK_ABI_NAMESPACE_END
81
}
82
83
#endif
84
// VTK-HeaderTest-Exclude: vtkHDF5ScopedHandle.h
vtkHDF
Definition
vtkHDF5ScopedHandle.h:12
DefineScopedHandle
#define DefineScopedHandle(name)
RAII class for automatically closing H5 handles.
Definition
vtkHDF5ScopedHandle.h:18
Generated on Wed Mar 11 2026 07:36:05 for VTK by
1.13.2