Sparkplug B C++ Library
1.0.0
Modern C++-23 implementation of Eclipse Sparkplug B 2.2 specification
Loading...
Searching...
No Matches
mqtt_handle.hpp
1
// include/sparkplug/mqtt_handle.hpp
2
#pragma once
3
4
typedef
void
* MQTTAsync;
5
6
namespace
sparkplug {
7
8
// RAII wrapper for MQTTAsync client handle
9
class
MQTTAsyncHandle
{
10
public
:
11
MQTTAsyncHandle
() noexcept : client_(
nullptr
) {
12
}
13
explicit
MQTTAsyncHandle
(MQTTAsync client) noexcept : client_(client) {
14
}
15
16
~MQTTAsyncHandle
()
noexcept
;
17
18
// Non-copyable
19
MQTTAsyncHandle
(
const
MQTTAsyncHandle
&) =
delete
;
20
MQTTAsyncHandle
& operator=(
const
MQTTAsyncHandle
&) =
delete
;
21
22
// Movable
23
MQTTAsyncHandle
(
MQTTAsyncHandle
&& other) noexcept : client_(other.client_) {
24
other.client_ =
nullptr
;
25
}
26
27
MQTTAsyncHandle
& operator=(
MQTTAsyncHandle
&& other)
noexcept
{
28
if
(
this
!= &other) {
29
reset();
30
client_ = other.client_;
31
other.client_ =
nullptr
;
32
}
33
return
*
this
;
34
}
35
36
// Access
37
MQTTAsync get()
const
noexcept
{
38
return
client_;
39
}
40
MQTTAsync operator*()
const
noexcept
{
41
return
client_;
42
}
43
explicit
operator
bool()
const
noexcept
{
44
return
client_ !=
nullptr
;
45
}
46
47
// Modifiers
48
void
reset()
noexcept
;
49
MQTTAsync release()
noexcept
{
50
MQTTAsync tmp = client_;
51
client_ =
nullptr
;
52
return
tmp;
53
}
54
55
private
:
56
MQTTAsync client_;
57
};
58
59
}
// namespace sparkplug
sparkplug::MQTTAsyncHandle
Definition
mqtt_handle.hpp:9
include
sparkplug
mqtt_handle.hpp
Generated on Sun Dec 7 2025 05:33:41 for Sparkplug B C++ Library by
1.9.8