Class that manages the connection between an event and a listener and disconnects it at destruction. More...
Public Member Functions | |
ScopedConnection (const Connection &connection) | |
Constructor: Initializes the instance with a given Connection. | |
~ScopedConnection () | |
Destructor: Disconnects the event-listener connection. | |
bool | IsConnected () const |
Checks whether the instance currently references a listener. |
Class that manages the connection between an event and a listener and disconnects it at destruction.
In contrast to thor::Connection, the thor::ScopedConnection class disconnects its referenced listener in the destructor. You can use ScopedConnection for temporary listeners that aren't needed after the end of scope.
ScopedConnection is noncopyable.
thor::ScopedConnection::ScopedConnection | ( | const Connection & | connection | ) | [explicit] |
Constructor: Initializes the instance with a given Connection.
Scoped connections must be initialized in the constructor. You cannot assign a new value later.
connection | Connection which is copied. It may be invalid. |
Destructor: Disconnects the event-listener connection.
In case the instance isn't connected, nothing happens.
bool thor::ScopedConnection::IsConnected | ( | ) | const |
Checks whether the instance currently references a listener.