VTK
9.4.20241109
Main Page
Related Pages
Modules
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 "vtk_hdf5.h"
7
8
#include <algorithm>
9
10
namespace
vtkHDF
11
{
12
VTK_ABI_NAMESPACE_BEGIN
13
17
#define DefineScopedHandle(name) \
18
class ScopedH5##name##Handle \
19
{ \
20
public: \
21
ScopedH5##name##Handle() \
22
: Handle(H5I_INVALID_HID) \
23
{ \
24
} \
25
ScopedH5##name##Handle(ScopedH5##name##Handle&& other) noexcept \
26
{ \
27
this->Handle = other.Handle; \
28
other.Handle = H5I_INVALID_HID; \
29
} \
30
ScopedH5##name##Handle& operator=(ScopedH5##name##Handle&& other) noexcept \
31
{ \
32
std::swap(this->Handle, other.Handle); \
33
return *this; \
34
} \
35
ScopedH5##name##Handle(const ScopedH5##name##Handle& other) = delete; \
36
ScopedH5##name##Handle& operator=(const ScopedH5##name##Handle&) = delete; \
37
ScopedH5##name##Handle(hid_t handle) \
38
: Handle(handle) \
39
{ \
40
} \
41
virtual ~ScopedH5##name##Handle() \
42
{ \
43
if (this->Handle >= 0) \
44
{ \
45
H5##name##close(this->Handle); \
46
} \
47
} \
48
\
49
operator hid_t() const \
50
{ \
51
return this->Handle; \
52
} \
53
\
54
private: \
55
hid_t Handle; \
56
};
57
58
// Defines ScopedH5AHandle closed with H5Aclose
59
DefineScopedHandle
(A);
60
61
// Defines ScopedH5DHandle closed with H5Dclose
62
DefineScopedHandle
(D);
63
64
// Defines ScopedH5FHandle closed with H5Fclose
65
DefineScopedHandle
(F);
66
67
// Defines ScopedH5GHandle closed with H5Gclose
68
DefineScopedHandle
(G);
69
70
// Defines ScopedH5PHandle closed with H5Pclose
71
DefineScopedHandle
(P);
72
73
// Defines ScopedH5SHandle closed with H5Sclose
74
DefineScopedHandle
(S);
75
76
// Defines ScopedH5THandle closed with H5Tclose
77
DefineScopedHandle
(T);
78
79
VTK_ABI_NAMESPACE_END
80
}
81
82
#endif
83
// VTK-HeaderTest-Exclude: vtkHDF5ScopedHandle.h
vtkHDF
Definition
vtkHDF5ScopedHandle.h:11
DefineScopedHandle
#define DefineScopedHandle(name)
RAII class for automatically closing H5 handles.
Definition
vtkHDF5ScopedHandle.h:17
Generated on Sat Nov 9 2024 10:58:53 for VTK by
1.9.7