Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 4 (modified by landauf, 8 years ago) (diff)

fixed links

ObjectList

This is an archived page!
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!

The ObjectList is a generic container for Classes that are derived from BaseObject.

Every object, that spcifies the registerObject-function is automatically registered to the ObjectList, and stored within it. (also see BaseObject about this)

The fancy thing about the ObjectList is:

  1. One can get a list of all Objects of any type (as long as it is derived from BaseObject)
  2. One can check if an Object exists within a List.
  3. One can check if all allocated data is deleted again, or if it is just floting around somewhere.

Usage

  • Iterating through a List: (note that the iterator is a std::list<PNode*>::const_iterator and can be used like any other stl-iterator.)
     ObjectList<PNode>::const_iterator it;
     for (it = PNode::objectList().begin(); it != PNode::objectList().end(); ++it)
      (*it)->debug();
    
  • get an Object with some name
    /// some class
    ObjectListBase::getBaseObject("PNode", "Player"); // returns a BaseObject* to the first object of a class named PNode and an Object named Player.
    /// defined class: much faster, and way more powerfull!
    PNode::objectList().getObject("Player"); // returns a PNode* to an Object named Player