Home · Modules · Classes · Namespaces · Functions

QxtSignalGroup Class Reference
[QxtCore module]

The QxtSignalGroup class groups signals together in a Boolean fashion More...

    #include <QxtSignalGroup>

Inherits QObject.

Inherited by QxtMultiSignalWaiter.

Public Functions

Public Slots

Signals

Additional Inherited Members


Detailed Description

The QxtSignalGroup class groups signals together in a Boolean fashion

When carrying out multiple tasks in parallel, it can be useful to know when any or all of the tasks have emitted a signal. This class allows a group of signals to be defined and re-signalled in a simple AND or OR fashion. More complex Boolean relationships can be written by connecting together multiple QxtSignalGroup objects.

For a simple example, suppose you have four QHttp requests pending and you want to know when the last request has completed. A QxtSignalGroup defined like this will emit its allSignalsReceived() signal after each request has emitted its done() signal.

    QxtSignalGroup* group = new QxtSignalGroup;
    for(int i = 0; i < 4; i++) {
        group->addSignal(http[i], SIGNAL(done()));
    }

For a more complex example, suppose you have two such batches of requests, and you want a signal to be emitted when the first batch is completed. Create two QxtSignalGroup objects (perhaps group1 and group2) and add their signals to a third group. This third group will emit its firstSignalReceived() signal when the first batch is completed and its allSignalsReceived() signal when all batches are finished.

    QxtSignalGroup* batches = new QxtSignalGroup;
    batches->addSignal(group1, SIGNAL(allSignalsReceived()));
    batches->addSignal(group2, SIGNAL(allSignalsReceived()));

Member Function Documentation

QxtSignalGroup::QxtSignalGroup ( QObject * parent = 0 )

Constructs a QxtSignalWaiter with the specified parent.

void QxtSignalGroup::addSignal ( QObject * sender, const char * sig )

Add a signal from sender with signature sig to the group.

void QxtSignalGroup::allSignalsReceived ()   [signal]

This signal is emitted after every signal in the group has been emitted at least once. After this signal is emitted once, you must call reset() before it can be emitted again.

void QxtSignalGroup::clear ()

Removes all signals from the group and resets the signal tracking.

void QxtSignalGroup::firstSignalReceived ()   [signal]

This signal is emitted the first time a signal in the group is emitted. After this signal is emitted once, you must call reset() before it can be emitted again.

bool QxtSignalGroup::hasReceivedAllSignals () const

Returns true if every attached signal has been emitted at least once since the last reset().

bool QxtSignalGroup::hasReceivedFirstSignal () const

Returns true if at least one attached signal has been emitted since the last reset().

void QxtSignalGroup::removeSignal ( QObject * sender, const char * sig = 0 )

Remove a signal from sender with signature sig from the group.

void QxtSignalGroup::reset ()   [slot]

Reset the signal tracking, that is, after calling reset() no signals are considered to have been caught.


Copyright © 2007-2010 Qxt Foundation
Qxt 0.6.1