Class connection
Synopsis
#include <src/entt/signal/sigh.hpp>
class connection
Description
Connection class.
Opaque object the aim of which is to allow users to release an already estabilished connection without having to keep a reference to the signal or the sink that generated it.
Methods
connection | Default constructor. | |
operator bool | Checks whether a connection is properly initialized. | |
release | Breaks the connection. |
Source
Lines 152-184 in src/entt/signal/sigh.hpp.
class connection {
/*! @brief A sink is allowed to create connection objects. */
template<typename>
friend class sink;
connection(delegate<void(void *)> fn, void *ref)
: disconnect{fn}, signal{ref}
{}
public:
/*! @brief Default constructor. */
connection() = default;
/**
* @brief Checks whether a connection is properly initialized.
* @return True if the connection is properly initialized, false otherwise.
*/
[[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
return static_cast<bool>(disconnect);
}
/*! @brief Breaks the connection. */
void release() {
if(disconnect) {
disconnect(signal);
disconnect.reset();
}
}
private:
delegate<void(void *)> disconnect;
void *signal{};
};