| 1 | = ObjectList = |
| 2 | |
| 3 | The ObjectList is a generic container for Classes that are derived from BaseObject. |
| 4 | |
| 5 | Every object, that spcifies the registerObject-function is automatically registered to the ObjectList, and stored within it. (also see BaseObject about this) |
| 6 | |
| 7 | The fancy thing about the ObjectList is: |
| 8 | 1. One can get a list of all Objects of any type (as long as it is derived from BaseObject) |
| 9 | 1. One can check if an Object exists within a List. |
| 10 | 1. One can check if all allocated data is deleted again, or if it is just floting around somewhere. |
| 11 | |
| 12 | == Usage == |
| 13 | * Iterating through a List: (note that the iterator is a std::list<PNode*>::const_iterator and can be used like any other stl-iterator.) |
| 14 | {{{ |
| 15 | #!cpp |
| 16 | ObjectList<PNode>::const_iterator it; |
| 17 | for (it = PNode::objectList().begin(); it != PNode::objectList().end(); ++it) |
| 18 | (*it)->debug(); |
| 19 | }}} |
| 20 | * get an Object with some name |
| 21 | {{{ |
| 22 | #!cpp |
| 23 | /// some class |
| 24 | ObjectListBase::getBaseObject("PNode", "Player"); // returns a BaseObject* to the first object of a class named PNode and an Object named Player. |
| 25 | /// defined class: much faster, and way more powerfull! |
| 26 | PNode::objectList().getObject("Player"); // returns a PNode* to an Object named Player |
| 27 | }}} |