RAII style connection with automatic disconnect. More...
Inherits NonCopyable.
Public Member Functions | |
| ScopedConnection () | |
| Default constructor.  More... | |
| ScopedConnection (const Connection &connection) | |
| Constructor: Initializes the instance with a given Connection.  More... | |
| ScopedConnection (ScopedConnection &&source) | |
| Move constructor.  More... | |
| ScopedConnection & | operator= (ScopedConnection &&source) | 
| Move assignment operator.  More... | |
| ~ScopedConnection () | |
| Destructor: Disconnects the event-listener connection.  More... | |
| bool | isConnected () const | 
| Checks whether the instance currently references a listener.  More... | |
RAII style connection with automatic disconnect.
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. Alternatively, you can link a connection to the lifetime of another object by making it a member variable. 
 ScopedConnection is noncopyable, but it is movable. 
| thor::ScopedConnection::ScopedConnection | ( | ) | 
Default constructor.
Initializes an invalid 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. | 
| thor::ScopedConnection::ScopedConnection | ( | ScopedConnection && | source | ) | 
Move constructor.
Invalidates source such that it no longer disconnects the connection upon destruction.
| thor::ScopedConnection::~ScopedConnection | ( | ) | 
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.
| ScopedConnection& thor::ScopedConnection::operator= | ( | ScopedConnection && | source | ) | 
Move assignment operator.
Invalidates source such that it no longer disconnects the connection upon destruction.