← API Reference Class

template<typename... Args> asge::signals::Connection

This class represents a single Connection to a Signal.

#include <Signal.hpp>

Every connection must have a unique identifier and a weak pointer to the connection map of the Signal class to which it is connected. Unique connection identifiers are generated incrementally when a new connection is created. The weak pointer to the Signal connection map is used to avoid dangling pointer and to ensure that operations are performed only if the object is still valid. For a single connection there are two ways of disconnecting it from the signal.

The first one is "manual disconnection", and involved calling the Connection::Disconnect method manually. The other one, relies on a so-called lifetime token which is a weak pointer to a generic object and it is used to automatic manage connection lifetime. That is, if the weak pointer becomes invalid the connection is automatically disconnected and so also destructuted.

Private Types

#using signal_type = Signal< Args... >private
#using signal_slots_type = std::weak_ptr< typename signal_type::conn_container >private
#using lifetime_token = typename signal_type::lifetime_tokenprivate

Friends

#friend Signal< Args... >private

Private Attributes

#size_t m_ConnIdprivate
#signal_slots_type m_WeakSlotsprivate
#bool m_HasTokenprivate

Static Private Member Functions

#static size_t NextConnectionId()private

Generate a monotonic increasing connection unique identifiers for connections handling.

Private Member Functions

#Connection(size_t inId, signal_slots_type inSlotWptr, bool inHasToken)private

Public Member Functions

#Connection()
#void Disconnect()
#bool IsConnected() const

Returns true if the current connection is still alive.

In this context a connection is alive if the identifier != 0, the weak pointer to the connection map is still valid and the lifetime token has not expired.

#size_t GetConnectionId() const