KTutorial  0.5.1
Public Member Functions | Protected Member Functions
ktutorial::WaitForNot Class Reference

Special WaitFor class to negate other WaitFor objects. More...

#include <WaitForNot.h>

Inheritance diagram for ktutorial::WaitForNot:
Inheritance graph
[legend]
Collaboration diagram for ktutorial::WaitForNot:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Q_INVOKABLE WaitForNot ()
 Creates a new WaitForNot.
 WaitForNot (WaitFor *waitFor)
 Creates a new WaitForNot.
virtual ~WaitForNot ()
 Destroys this WaitForNot.
Q_INVOKABLE void setNegatedWaitFor (WaitFor *waitFor)
 Sets the WaitFor to be negated.
virtual bool conditionMet () const
 Returns true if the child WaitFor condition isn't met, false otherwise.
virtual void setActive (bool active)
 Sets this WaitForNot and its child as active or inactive.

Protected Member Functions

WaitForwaitFor () const
 Returns the WaitFor to check if its condition isn't met.

Detailed Description

Special WaitFor class to negate other WaitFor objects.

This WaitFor is intended to be used only as a child of WaitForComposed objects. It negates the condition of the WaitFor object added to the WaitForNot.

WaitForNot can't be added directly in Steps, as they don't emit waitEnded(WaitFor*) signal. The signal isn't emitted because it is intended to notify when the wait ends. However, in this class, the wait doesn't really ends, because it is ended since the beginning.

If you need to use WaitForNot, it will be likely be in a WaitForAnd. For example, to wait for a signal only if another signal wasn't emitted. Note that, in this case, you will need to add a fallback WaitFor or an Option to avoid a Step to hang.

   WaitForSignal* someSignal = new WaitForSignal(someObject, SIGNAL(someSignal()));
   WaitForSignal* offendingSignal = new WaitForSignal(someObject, SIGNAL(offendingSignal()));
   WaitForNot* notOffendingSignal = new WaitForNot(offendingSignal);

   WaitForAnd* someSignalButNotOffendingSignal = new WaitForAnd();
   someSignalButNotOffendingSignal->add(someSignal);
   someSignalButNotOffendingSignal->add(notOffendingSignal);

   step->addWaitFor(someSignalButNotOffendingSignal, someObject, SLOT(someSlot));
   ...
   step->addWaitFor(fallbackWaitFor, someObject, SLOT(anotherSlot));

Definition at line 60 of file WaitForNot.h.


Constructor & Destructor Documentation

Creates a new WaitForNot.

This constructor is needed to dynamically create WaitForNot objects in scripts using ScriptingModule::newWaitFor(const QString&). Method setNegatedWaitFor(WaitFor*) must be called to finish setting up the object. For C++ tutorials, use WaitForNot(WaitFor*) constructor instead of this one.

Definition at line 28 of file WaitForNot.cpp.

References ktutorial::WaitForNotPrivate::mWaitFor.

ktutorial::WaitForNot::WaitForNot ( WaitFor waitFor) [explicit]

Creates a new WaitForNot.

The WaitFor is reparented to this WaitForNot, and thus deleted when this WaitForNot is deleted.

Parameters:
waitForThe child WaitFor.

Definition at line 33 of file WaitForNot.cpp.

References setNegatedWaitFor().


Member Function Documentation

bool ktutorial::WaitForNot::conditionMet ( ) const [virtual]

Returns true if the child WaitFor condition isn't met, false otherwise.

Returns:
True if the child WaitFor condition isn't met, false otherwise.

Implements ktutorial::WaitFor.

Definition at line 47 of file WaitForNot.cpp.

References ktutorial::WaitFor::conditionMet(), and ktutorial::WaitForNotPrivate::mWaitFor.

void ktutorial::WaitForNot::setActive ( bool  active) [virtual]

Sets this WaitForNot and its child as active or inactive.

Parameters:
activeTrue to set it active, false otherwise.

Reimplemented from ktutorial::WaitFor.

Definition at line 51 of file WaitForNot.cpp.

References ktutorial::WaitForNotPrivate::mWaitFor, and ktutorial::WaitFor::setActive().

Sets the WaitFor to be negated.

The WaitFor is reparented to this WaitForNot, and thus deleted when this WaitForNot is deleted. This method can be invoked from a script.

In fact, you should only invoke this method from a script, and only once, to set up the object. For C++ tutorials, use WaitForNot(WaitFor*) constructor when creating this WaitForNot.

Parameters:
waitForThe child WaitFor.

Definition at line 42 of file WaitForNot.cpp.

References ktutorial::WaitForNotPrivate::mWaitFor, and waitFor().

Referenced by WaitForNot().

WaitFor * ktutorial::WaitForNot::waitFor ( ) const [protected]

Returns the WaitFor to check if its condition isn't met.

Returns:
The WaitFor to check if its condition isn't met.

Definition at line 58 of file WaitForNot.cpp.

References ktutorial::WaitForNotPrivate::mWaitFor.

Referenced by setNegatedWaitFor().


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