List of all members | Public Member Functions
thor::Connection Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

thor::Connection::Connection ( )

Default constructor: Creates an instance which is initially invalid.

Assign another object to make this instance a valid Connection.

Member Function Documentation

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.

Returns
true if this instance is currently connected.

The documentation for this class was generated from the following file: