Class that manages the connection between an event and a listener. More...
Public Member Functions | |
Connection () | |
Default constructor: Creates an instance which is initially invalid. | |
bool | IsConnected () const |
Checks whether the instance currently references a listener. | |
void | Invalidate () |
Invalidates this instance. | |
void | Disconnect () |
Disconnects the referenced listener from its triggering event. |
Class that manages the connection between an event and a listener.
You need a connection, if you want to remove listeners bound to events. The class Connection uses shared-ownership semantics, that means copying its instances results in multiple references to the same listener. It automatically invalidates when the referenced listener is disconnected from the event system.
Default constructor: Creates an instance which is initially invalid.
Assign another object to make this instance a valid Connection.
void thor::Connection::Disconnect | ( | ) |
Disconnects the referenced listener from its triggering event.
This action invalidates this and all other Connections to the referenced listener. If no connection exists at the moment, this function has no effect.
void thor::Connection::Invalidate | ( | ) |
Invalidates this instance.
This does not affect the referenced listener (if any) nor other Connection instances. Invalidating an already invalid instance has no effects.
After the invalidation, you can reuse this instance by assigning another one. But normally, it pays out to have as few invalid connections as possible, as this saves you from case differentiations.
bool thor::Connection::IsConnected | ( | ) | const |
Checks whether the instance currently references a listener.