CLASS SCOPED_CONN(3)

NAME
boost::signals2::scoped_connection - Limits a signal-slot connection lifetime to a particular scope.

SYNOPSIS

// In header: <boost/signals2/connection.hpp>
class scoped_connection : public connection {
public:
  // construct/copy/destruct
  scoped_connection();
  scoped_connection(const connection&);
  ~scoped_connection();
  // public methods
  scoped_connection & operator=(const connection &);
  connection release();
private:
  // construct/copy/destruct
  scoped_connection(const scoped_connection&);
  scoped_connection& operator=(const scoped_connection&);
};

DESCRIPTION

A connection which automatically disconnects on destruction. Thread Safety.PP The methods of the scoped_connection class (including those inherited from its base connection class) are thread-safe with the exception of signals2::connection::swap, release, and the assignment operator. A scoped_connection object should not be accessed concurrently when any of these operations is in progress. However, it is always safe to access a different connection object in another thread, even if it references the same underlying signal-slot connection.

  scoped_connection public construct/copy/destruct

    1.

    scoped_connection();

    Default constructs an empty scoped_connection.

    Postconditions:
        connected() == false

    Throws:
        Will not throw.

    2.

    scoped_connection(const connection& other);

    Effects:
        this references the connection referenced by other.

    Postconditions:
        connected() == other.connected()

    Throws:
        Will not throw.

    3.

    ~scoped_connection();

    Effects:
        If this->connected(), disconnects the signal-slot connection.

  scoped_connection public methods

    1.

    scoped_connection & operator=(const connection & rhs);

    Effects:
        this references the connection referenced by rhs. If this already references another connection, the old connection will be disconnected first.

    Postconditions:
        connected() == rhs.connected()

    2.

    connection release();

    Effects:
        Releases the connection so it will not be disconnected by the scoped_connection when it is destroyed or reassigned. The scoped_connection is reset to the NULL connection after this call completes.

    Postconditions:
        connected() == false

    Returns:
        A connection object referencing the connection which was released by the scoped_connection.

  scoped_connection private construct/copy/destruct

    1.

    scoped_connection(const scoped_connection& other);

    The scoped_connection class is not copyable. It may only be constructed from a connection object.

    2.

    scoped_connection& operator=(const scoped_connection& rhs);

    The scoped_connection class is not copyable. It may only be assigned from a connection object.