|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
RAII handle for signal connections. More...
#include <Connection.hpp>
Public Types | |
| using | DisconnectFunc = std::function<void(CallbackId)> |
Public Member Functions | |
| Connection ()=default | |
| Default constructor creates an empty connection. | |
| Connection (CallbackId id, DisconnectFunc disconnectFunc) | |
| Constructs a connection with disconnect callback. | |
| ~Connection () | |
| Destructor automatically disconnects. | |
| Connection (Connection &&other) noexcept | |
| Move constructor transfers ownership. | |
| Connection & | operator= (Connection &&other) noexcept |
| Move assignment transfers ownership. | |
| Connection (const Connection &)=delete | |
| Connection & | operator= (const Connection &)=delete |
| void | disconnect () |
| Manually disconnect from the signal. | |
| bool | isConnected () const |
| Check if still connected. | |
| CallbackId | getId () const |
| Get the callback ID. | |
| CallbackId | release () |
| Release ownership without disconnecting. | |
RAII handle for signal connections.
Connection manages the lifetime of a callback registration. When the Connection object is destroyed, it automatically disconnects from the signal, preventing memory leaks and dangling callback issues.
Definition at line 57 of file Connection.hpp.
| using esengine::Connection::DisconnectFunc = std::function<void(CallbackId)> |
Definition at line 59 of file Connection.hpp.
|
default |
Default constructor creates an empty connection.
Referenced by Connection(), Connection(), operator=(), and operator=().
|
inline |
Constructs a connection with disconnect callback.
| id | The callback identifier |
| disconnectFunc | Function to call when disconnecting |
Definition at line 71 of file Connection.hpp.
|
inline |
Destructor automatically disconnects.
Definition at line 77 of file Connection.hpp.
References disconnect().
|
inlinenoexcept |
Move constructor transfers ownership.
| other | Connection to move from |
Definition at line 85 of file Connection.hpp.
References Connection(), and esengine::INVALID_CALLBACK_ID.
|
delete |
References Connection().
|
inline |
Manually disconnect from the signal.
Definition at line 113 of file Connection.hpp.
References esengine::INVALID_CALLBACK_ID, and isConnected().
Referenced by ~Connection(), and operator=().
|
inlinenodiscard |
|
inlinenodiscard |
Check if still connected.
Definition at line 125 of file Connection.hpp.
References esengine::INVALID_CALLBACK_ID.
Referenced by disconnect().
|
inlinenoexcept |
Move assignment transfers ownership.
| other | Connection to move from |
Definition at line 96 of file Connection.hpp.
References Connection(), disconnect(), and esengine::INVALID_CALLBACK_ID.
|
delete |
References Connection().
|
inline |
Release ownership without disconnecting.
Definition at line 141 of file Connection.hpp.
References esengine::INVALID_CALLBACK_ID.