An non-const iterator which iterates throught the subjects of an Observer. More...
#include <SubjectIterator.h>
Public Types | |
enum | ObserverIterationLevel { IterateChildren, IterateSiblings } |
The level to use when passing only an observer in your constructor. More... |
Public Member Functions | |
T * | current () const |
Gets the current item in the context iterated through. | |
T * | first () |
The first item in the context iterated through. | |
T * | last () |
The last item in the context iterated through. | |
T * | next () |
The next item in the context iterated through. | |
T * | previous () |
The previous item in the context iterated through. | |
void | setCurrent (const T *current) |
Sets the current item in the context iterated through. | |
SubjectIterator (const T *subject, const Observer *observer=0, int iterator_id=-1) | |
Default constructor. | |
SubjectIterator (const Observer *observer, ObserverIterationLevel iteration_level, const Observer *sibling_iteration_parent_observer=0, int iterator_id=-1) | |
Observer based constructor. | |
Public Member Functions inherited from Qtilities::Core::Interfaces::IIterator< T > | |
virtual bool | hasNext () |
Indicates if a next item exists. | |
virtual bool | hasPrevious () |
Indicates if a previous item exists. | |
virtual T * | operator++ () |
Prefix increment. | |
virtual T * | operator++ (int x) |
Postfix increment. | |
virtual T * | operator-- () |
Prefix decrement. | |
virtual T * | operator-- (int x) |
Postfix decrement. |
An non-const iterator which iterates throught the subjects of an Observer.
The SubjectIterator allows you to easily iterate over the subjects in an observer in the order shown below:
Lets build this example tree:
It is also possible to specify the current location of your iterator:
In the simple examples above we didn't need to worry about cases where tree items can have multiple parents. If they do have multiple parents, we must specify the Observer that we are interested in:
This class was added in Qtilities v1.0.
enum Qtilities::Core::SubjectIterator::ObserverIterationLevel |
The level to use when passing only an observer in your constructor.
IterateChildren |
Iterate on the observer's children. |
IterateSiblings |
Iterate on the observer's siblings. In this case T must be a subclass of Observer. |
|
inline |
Default constructor.
subject | The current subject where your iterator must start. |
observer | This is an optional parameter which is needed when your subject is observed in multiple contexts. In that case, the observer must be specified in order to know which observer parent to use. |
iterator_id | Internal iterator ID. You should never use this directly. |
|
inline |
Observer based constructor.
observer | The observer that must be used in cases where multiple subjects have multiple parents. |
iteration_level | Indicates on which level the observer must be interated. |
sibling_iteration_parent_observer | When interating over siblings of an obsever (iteration_level = IterateSiblings), *it is necessary to specify the parent of the siblings you are iterating when any of the siblings has multiple parents. |
iterator_id | Internal iterator ID. You should never use this directly. |
Qtilities : Reference Documentation | Back to top |
Copyright © 2009-2013, Jaco Naudé
|