KTutorial
0.5.1
|
Abstract base class for composed conditions to wait for. More...
#include <WaitForComposed.h>
Public Slots | |
void | childWaitEnd (WaitFor *waitFor) |
Notifies that the child WaitFor object has ended its wait. | |
Public Member Functions | |
virtual | ~WaitForComposed () |
Destroys this WaitForComposed. | |
virtual void | setActive (bool active) |
Sets this WaitForComposed and all the children as active or inactive. | |
Q_INVOKABLE void | add (WaitFor *waitFor) |
Adds a new WaitFor to this WaitForComposed. | |
Protected Member Functions | |
WaitForComposed () | |
Creates a new WaitForComposed. | |
QList< WaitFor * > & | waitFors () const |
Returns a list containing all the WaitFor objects added. |
Abstract base class for composed conditions to wait for.
Classes derived from this one model a composed condition to be waited for. Child WaitFor objects are added using WaitForComposed::add(WaitFor*).
Once a WaitFor is added, it will be automatically activated or deactivated when the parent (the subclass of WaitForComposed) is activated or deactivated.
When an added WaitFor ends its wait, it notifies the parent WaitForComposed subclass. It then checks if it is active and its own condition was met, and in that case ends its own wait.
When subclassing WaitForComposed, conditionMet() must be implemented.
Definition at line 45 of file WaitForComposed.h.
ktutorial::WaitForComposed::WaitForComposed | ( | ) | [protected] |
Creates a new WaitForComposed.
Protected to avoid classes other than subclasses to create them.
Definition at line 72 of file WaitForComposed.cpp.
void ktutorial::WaitForComposed::add | ( | WaitFor * | waitFor | ) |
Adds a new WaitFor to this WaitForComposed.
If the WaitFor is already added, nothing happens. WaitFor notifies this WaitForComposed when its wait ends through WaitForComposed::childWaitEnd(WaitFor*)
The WaitFor is reparented to this WaitForComposed, and thus deleted when this WaitForComposed is deleted.
This method can be invoked from a script.
waitFor | The WaitFor to add. |
Definition at line 42 of file WaitForComposed.cpp.
References childWaitEnd(), ktutorial::WaitForComposedPrivate::mWaitFors, and ktutorial::WaitFor::waitEnded().
void ktutorial::WaitForComposed::childWaitEnd | ( | WaitFor * | waitFor | ) | [slot] |
Notifies that the child WaitFor object has ended its wait.
If is active and the condition is met for this WaitForComposed, its own wait ends.
This slot is connected automatically to children when they are added.
waitFor | The WaitFor child object that ended its wait. |
Definition at line 56 of file WaitForComposed.cpp.
References ktutorial::WaitFor::conditionMet(), ktutorial::WaitFor::isActive(), ktutorial::WaitForComposedPrivate::mWaitFors, and ktutorial::WaitFor::waitEnded().
Referenced by add().
void ktutorial::WaitForComposed::setActive | ( | bool | active | ) | [virtual] |
Sets this WaitForComposed and all the children as active or inactive.
active | True to set it active, false otherwise. |
Reimplemented from ktutorial::WaitFor.
Definition at line 33 of file WaitForComposed.cpp.
References ktutorial::WaitForComposedPrivate::mWaitFors.
QList< WaitFor * > & ktutorial::WaitForComposed::waitFors | ( | ) | const [protected] |
Returns a list containing all the WaitFor objects added.
Definition at line 76 of file WaitForComposed.cpp.
References ktutorial::WaitForComposedPrivate::mWaitFors.
Referenced by ktutorial::WaitForAnd::conditionMet(), and ktutorial::WaitForOr::conditionMet().