Iterator
TracNav
Development
- Overview
- SVN
Download...
- Contribute
Programming:
- Modules
Documentation
- Overview
Core
- Overview
- ArgumentCompleter
- ArgumentCompletionFunctions
- ArgumentCompletionList
- BaseObject
- ClassFactory
- ClassIdentifier
- ClassTreeMask
- Clock
- CommandEvaluation
- CommandExecutor
- CommandLine
- ConfigFileManager
- ConfigValueContainer
- ConfigValueIncludes
- ConsoleCommand
- CoreIncludes
- Executor
- Factory
- Functor
- GameStates
- Identifier
Input...
- IRC
- Iterator
- Language
- Level
- Loader?
- MetaObjectList
- Namespace?
- ObjectList
- ObjectListBase
- ObjectListIterator
- OrxonoxClass
- RootGameState?
- Script?
- Shell?
- SubclassIdentifier
- Super
- TclBind
- TclThreadManager?
- XMLPort
Network...
Orxonox...
Util...
- API Reference
HowTo...
- FAQ
- Styleguide
More...
Content Creation:
The Iterator allows you to iteratate through any ObjectList you like. It's possible to iterate through all objects of class B with an Iterator of class A, under condition that B is a child of A. Iterator does a dynamic_cast to the requested class. Because this is not really performant, you should always use ObjectListIterator instead in case that A == B.
Important: Always use ObjectListIterator if you know at compiletime through which class you want to iterate.
Iterator is made to iterate through a list of objects which gets determined at runtime. For this reason you can create an Iterator not only by calling ObjectList<T>::begin() but also through anyidentifier->getObjects()->begin(). Of course end(), rbegin() and rend() work too.
Illustration
Example
Identifier* identifier = someFunctionReturningAnIdentifier();
for (Iterator<BaseObject> it = identifier->getObjects()->begin();
it != identifier->getObjects()->end(); ++it)
{
it->callSomeFunction(...);
BaseObject* storeTheObject = (*it);
}
for (Iterator<BaseClass> it = ObjectList<ChildClass>::begin();
it != ObjectList<ChildClass>::end(); ++it)
{
it->callSomeFunction(...);
BaseObject* storeTheObject = (*it);
}
// Note:
// In this case you should better use ObjectListIterator<ChildClass>
// to avoid a dynamic_cast
Attachments
-
Iterator.png
(8.8 KB) - added by landauf
4 years ago.








