Sen API
Sen Libraries
Loading...
Searching...
No Matches
connection_guard.h
Go to the documentation of this file.
1// === connection_guard.h ==============================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_CORE_OBJ_CONNECTION_GUARD_H
9#define SEN_CORE_OBJ_CONNECTION_GUARD_H
10
11// sen
13#include "sen/core/meta/type.h"
14
15// std
16#include <cstdint>
17#include <memory>
18
19namespace sen
20{
21
22namespace impl
23{
24
25template <typename... T>
26class EventBuffer;
27
28}
29
32
33class Object;
34
36class [[nodiscard]] ConnectionGuard
37{
38public:
39 SEN_COPY_CONSTRUCT(ConnectionGuard) = delete;
40 SEN_COPY_ASSIGN(ConnectionGuard) = delete;
41
42public:
43 SEN_MOVE_CONSTRUCT(ConnectionGuard);
44 SEN_MOVE_ASSIGN(ConnectionGuard);
45
46public:
49
53
55 void keep() noexcept;
56
57private:
58 friend class Object;
59
60 template <typename... T>
61 friend class impl::EventBuffer;
62
64 ConnectionGuard(Object* source, uint32_t id, MemberHash memberHash, bool typed);
65
67 void destroy();
68
69private:
70 std::weak_ptr<Object> source_;
71 uint32_t id_;
72 MemberHash memberHash_;
73 bool typed_;
74};
75
77
78} // namespace sen
79
80#endif // SEN_CORE_OBJ_CONNECTION_GUARD_H
friend class Object
Definition connection_guard.h:58
~ConnectionGuard()
Removes the associated callback from the object if the object has not been destructed and keep() has ...
ConnectionGuard()
Constructs an emtpy guard.
void keep() noexcept
Tells this class to keep the callback even when this guard is destroyed.
friend class impl::EventBuffer
Definition connection_guard.h:61
A sen object.
Definition object.h:76
Definition assert.h:17
STL namespace.
The hash of a member.
Definition type.h:39