OpenVPN 3 Core Library
Loading...
Searching...
No Matches
autoreset.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
// Automatically reset a target object when
13
// AutoReset goes out of scope.
14
15
#ifndef OPENVPN_COMMON_AUTORESET_H
16
#define OPENVPN_COMMON_AUTORESET_H
17
18
namespace
openvpn
{
19
20
template
<
typename
T>
21
class
AutoReset
22
{
23
public
:
24
AutoReset
(T &obj)
25
:
obj_
(&obj)
26
{
27
}
28
29
~AutoReset
()
30
{
31
if
(
obj_
)
32
obj_
->reset();
33
}
34
35
void
disarm
()
36
{
37
obj_
=
nullptr
;
38
}
39
40
private
:
41
T *
obj_
;
42
};
43
44
}
// namespace openvpn
45
46
#endif
openvpn::AutoReset
Definition
autoreset.hpp:22
openvpn::AutoReset::disarm
void disarm()
Definition
autoreset.hpp:35
openvpn::AutoReset::obj_
T * obj_
Definition
autoreset.hpp:41
openvpn::AutoReset::AutoReset
AutoReset(T &obj)
Definition
autoreset.hpp:24
openvpn::AutoReset::~AutoReset
~AutoReset()
Definition
autoreset.hpp:29
openvpn
Definition
ovpncli.cpp:97
openvpn
common
autoreset.hpp
Generated by
1.9.8