| Home | Libraries | People | FAQ | More

## Class connection

boost::signals::connection — Query/disconnect a signal-slot connection.

## Synopsis

    // In header: <boost/signals/connection.hpp>

    class connection {
    public:
      // construct/copy/destruct
      connection();
      connection(const connection&);
      connection& operator=(const connection&);

      // connection management
      void disconnect() const;
      bool connected() const;

      // blocking
      void block(bool = true);
      void unblock();
      bool blocked() const;

      // modifiers
      void swap(const connection&);

      // comparisons
      bool operator==(const connection&) const;
      bool operator<(const connection&) const;
    };

    // specialized algorithms
    void swap(connection&, connection&);

## Description

The connection class represents a connection between a Signal and a Slot. It is a lightweight object that has the ability to query whether the signal and slot are currently connected, and to disconnect the signal and slot. It is always safe to query or disconnect a connection.

### `connection` public construct/copy/destruct

1.     connection();

   Effects: | Sets the currently represented connection to the NULL connection.
   Postconditions: | `!this->connected()`.
   Throws: | Will not throw.

2.     connection(const connection& other);

   Effects: | `this` references the connection referenced by `other`.
   Throws: | Will not throw.

3.     connection& operator=(const connection& other);

   Effects: | `this` references the connection referenced by `other`.
   Throws: | Will not throw.

### `connection` connection management

1.     void disconnect() const;

   Effects: | If `this->connected()`, disconnects the signal and slot referenced by this; otherwise, this operation is a no-op.
   Postconditions: | `!this->connected()`.

2.     bool connected() const;

   Returns: | `true` if this references a non-NULL connection that is still active (connected), and `false` otherwise.
   Throws: | Will not throw.

### `connection` blocking

1.     void block(bool should_block = true);

   Requires: | `connected()`
   Postconditions: | `blocked() == should_block`
   Throws: | Will not throw.

2.     void unblock();

   Requires: | `connected()`
   Postconditions: | `!blocked()`
   Throws: | Will not throw.

3.     bool blocked() const;

   Returns: | `true` if the associated slot is either disconnected or blocked, `false` otherwise.
   Throws: | Will not throw.

### `connection` modifiers

1.     void swap(const connection& other);

   Effects: | Swaps the connections referenced in `this` and `other`.
   Throws: | Will not throw.

### `connection` comparisons

1.     bool operator==(const connection& other) const;

   Returns: | `true` if `this` and `other` reference the same connection or both reference the NULL connection, and `false` otherwise.
   Throws: | Will not throw.

2.     bool operator<(const connection& other) const;

   Returns: | `true` if the connection referenced by `this` precedes the connection referenced by `other` based on some unspecified ordering, and `false` otherwise.
   Throws: | Will not throw.

### `connection` specialized algorithms

1.     void swap(connection& x, connection& y);

   Effects: | `x.swap(y)`
   Throws: | Will not throw.