ndn::signal::ScopedConnection Class Reference

Disconnects a Connection automatically upon destruction. More...

#include <ndn-cxx/util/signal/scoped-connection.hpp>

Public Member Functions

constexpr ScopedConnection () noexcept=default
 
 ScopedConnection (Connection connection) noexcept
 Implicit constructor from Connection. More...
 
 ScopedConnection (const ScopedConnection &)=delete
 
 ScopedConnection (ScopedConnection &&) noexcept
 Move constructor. More...
 
 ~ScopedConnection ()
 Destructor, automatically disconnects the connection. More...
 
void disconnect ()
 Manually disconnect the connection. More...
 
bool isConnected () const noexcept
 Check if the connection is connected to the signal. More...
 
ScopedConnectionoperator= (Connection connection)
 Assign a connection. More...
 
ScopedConnectionoperator= (const ScopedConnection &)=delete
 
ScopedConnectionoperator= (ScopedConnection &&) noexcept
 Move assignment operator. More...
 
void release () noexcept
 Release the connection so that it won't be disconnected when this ScopedConnection is destructed. More...
 

Detailed Description

Disconnects a Connection automatically upon destruction.

Definition at line 32 of file scoped-connection.hpp.

Constructor & Destructor Documentation

◆ ScopedConnection() [1/4]

constexpr ndn::signal::ScopedConnection::ScopedConnection ( )
constexprdefaultnoexcept

◆ ScopedConnection() [2/4]

ndn::signal::ScopedConnection::ScopedConnection ( const ScopedConnection )
delete

◆ ScopedConnection() [3/4]

ndn::signal::ScopedConnection::ScopedConnection ( ScopedConnection &&  )
inlinedefaultnoexcept

Move constructor.

◆ ScopedConnection() [4/4]

ndn::signal::ScopedConnection::ScopedConnection ( Connection  connection)
noexcept

Implicit constructor from Connection.

Parameters
connectionthe Connection to be disconnected upon destruction

Definition at line 26 of file scoped-connection.cpp.

◆ ~ScopedConnection()

ndn::signal::ScopedConnection::~ScopedConnection ( )

Destructor, automatically disconnects the connection.

Definition at line 41 of file scoped-connection.cpp.

Member Function Documentation

◆ disconnect()

void ndn::signal::ScopedConnection::disconnect ( )

Manually disconnect the connection.

Definition at line 47 of file scoped-connection.cpp.

◆ isConnected()

bool ndn::signal::ScopedConnection::isConnected ( ) const
noexcept

Check if the connection is connected to the signal.

Returns
false when a default-constructed connection is used, the connection is released, or the connection is disconnected

Definition at line 53 of file scoped-connection.cpp.

◆ operator=() [1/3]

ScopedConnection & ndn::signal::ScopedConnection::operator= ( Connection  connection)

Assign a connection.

If a different connection has been assigned to this instance previously, that connection will be disconnected immediately.

Definition at line 32 of file scoped-connection.cpp.

◆ operator=() [2/3]

ScopedConnection& ndn::signal::ScopedConnection::operator= ( const ScopedConnection )
delete

◆ operator=() [3/3]

ScopedConnection & ndn::signal::ScopedConnection::operator= ( ScopedConnection &&  )
inlinedefaultnoexcept

Move assignment operator.

◆ release()

void ndn::signal::ScopedConnection::release ( )
noexcept

Release the connection so that it won't be disconnected when this ScopedConnection is destructed.

Definition at line 59 of file scoped-connection.cpp.