Class that maintains control over a registered object. More...
Public Member Functions | |
Connection () | |
Default constructor: Creates an instance which is initially invalid. More... | |
bool | isConnected () const |
Checks whether the instance currently references a listener. More... | |
void | invalidate () |
Invalidates this instance. More... | |
void | disconnect () |
Disconnects the referenced listener from its triggering event. More... | |
Class that maintains control over a registered object.
You need a connection if you want to remove event listeners, particle emitters or affectors from their containers. The class Connection uses shared-ownership semantics, that means copying its instances results in multiple references to the same listener. A connection automatically invalidates when the referenced object is removed. Therefore, you don't have to worry about dangling connections.
thor::Connection::Connection | ( | ) |
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 off 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.