Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 11 and Version 12 of code/doc/Identifier


Ignore:
Timestamp:
Sep 28, 2008, 7:29:55 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/Identifier

    v11 v12  
    7171// Cast the pointer from BaseObject to MyClass:
    7272MyClass* object2 = dynamic_cast<MyClass*>(object);
     73}}}
     74
     75=== Iterating through existing objects ===
     76'''getObjects()''' returns a pointer to an [wiki:ObjectListBase], containing all objects of the class. You can iterate through them with an [wiki:Iterator]:
     77{{{
     78Identifier* identifier = Class(SomeClass);
     79
     80Iterator it = identifier->getObjects()->begin();
     81for (; it != identifier->getObjects()->end(); ++it)
     82{
     83    it->callAFunction();
     84}
     85}}}
     86
     87'''Important''': If you know at compiletime which class you want to iterate through, use [wiki:ObjectListIterator], because it's much faster:
     88{{{
     89ObjectList<SomeClass>::iterator it = ObjectList<SomeClass>::begin();
     90for (; it != ObjectList<SomeClass>::end(); ++it)
     91{
     92    it->callAFunction();
     93}
    7394}}}
    7495