Connection management for signal and slot objectsThis class implements connection management for signal and slot objects. More...

#include <cxxtools/connectable.h>

Inheritance diagram for cxxtools::Connectable:
cxxtools::Application cxxtools::DelegateBase cxxtools::net::TcpStream cxxtools::SelectorBase cxxtools::Signal< const cxxtools::Event & > cxxtools::SignalBase cxxtools::StreamBuffer cxxtools::unit::Test

Public Member Functions

 Connectable ()
 Default constructor.
virtual ~Connectable ()
 Closes all connections.
virtual void onConnectionOpen (const Connection &c)
 Registers a Connection with the Connectable.
virtual void onConnectionClose (const Connection &c)
 Unregisters a Connection from the Connectable.
size_t connectionCount () const

Protected Member Functions

 Connectable (const Connectable &c)
 Copy constructor.
Connectableoperator= (const Connectable &rhs)
 Assignment operator.
const std::list< Connection > & connections () const
 Returns a list of all current connections.
std::list< Connection > & connections ()
 Returns a list of all current connections.
void clear ()

Protected Attributes

std::list< Connection_connections
 A list of all current connections.

Detailed Description

Connection management for signal and slot objects

This class implements connection management for signal and slot objects.

It makes sure that all connections where this object is involved are closed on destruction. Deriving classes can overload Connectable::opened and Connectable::closed to tune connection managenment.

Constructor & Destructor Documentation

cxxtools::Connectable::Connectable ( )

Default constructor.

Creates an empty Connectable.

virtual cxxtools::Connectable::~Connectable ( )
virtual

Closes all connections.

When a Connectable object is destroyed, it closes all its connections automatically.

cxxtools::Connectable::Connectable ( const Connectable c)
protected

Copy constructor.

See Also
Connectable::operator=()

Member Function Documentation

void cxxtools::Connectable::clear ( )
protected
size_t cxxtools::Connectable::connectionCount ( ) const
inline
const std::list<Connection>& cxxtools::Connectable::connections ( ) const
inlineprotected

Returns a list of all current connections.

std::list<Connection>& cxxtools::Connectable::connections ( )
inlineprotected

Returns a list of all current connections.

virtual void cxxtools::Connectable::onConnectionClose ( const Connection c)
virtual

Unregisters a Connection from the Connectable.

This function is called when a new Connection involving this object is closed. The default implementation removes the connection from its list of connections.

Parameters
cConnection being opened

Reimplemented in cxxtools::Signal< const cxxtools::Event & >, cxxtools::DelegateBase, and cxxtools::SignalBase.

virtual void cxxtools::Connectable::onConnectionOpen ( const Connection c)
virtual

Registers a Connection with the Connectable.

This function is called when a new Connection involving this object is opened. The default implementation adds the connection to a list, so the destructor can close it.

Parameters
cConnection being opened
Returns
True if the Connection was accepted

Reimplemented in cxxtools::Signal< const cxxtools::Event & >, cxxtools::SignalBase, and cxxtools::DelegateBase.

Connectable& cxxtools::Connectable::operator= ( const Connectable rhs)
protected

Assignment operator.

Connectables can be copy constructed if the derived class provides a public copy constructor. Copying a Connectable will not change its connections.

Member Data Documentation

std::list<Connection> cxxtools::Connectable::_connections
mutableprotected

A list of all current connections.


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