Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of ~archive/BaseObject


Ignore:
Timestamp:
Nov 27, 2007, 9:08:47 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ~archive/BaseObject

    v1 v1  
     1= BaseObject =
     2The BaseObject is the top-most !SuperClass of (most but not) all Classes in orxonox.
     3
     4source:/trunk/src/lib/lang/base_object.h#HEAD [[br]]
     5__Derived From__:
     6  * nothing
     7
     8== Description ==
     9BaseObject is a container for
     10  * The Name of the Object (how the object is called)
     11  * The Class' Name of the Object (in what class this object is)
     12  * The ClassID of the Object (what is the Identity of the class (see [source:/trunk/src/lib/lang/class_id.h#HEAD ClassID]
     13
     14== Usage ==
     15  * __Registration__:[[br]]
     16   Each class, that extends BaseObject must implement the following function:
     17   1. In the Class-Declaration use the following syntax (taken your class is named OrxClass)
     18{{{
     19#!cpp
     20  class OrxClass : public BaseObject // here you could also specify any class derived from BaseObject
     21  {
     22    ObjectListDeclaration(OrxClass);
     23    /// ... rest of the Declaration;
     24  };
     25}}}
     26   1. At the top of the cc-file of the Class (in the definiton) write:
     27{{{
     28#!cpp
     29  ObjectListDefinition(OrxClass);
     30}}}
     31   1. In the constructor of each class implementing BaseObject write the following:
     32{{{
     33#!cpp
     34this->registerObject(this, OrxClass::_objectList);
     35}}}
     36   1. you can then set a Name to the Object using
     37{{{
     38#!cpp
     39this->setName("the name");
     40}}}
     41  * __isA__:[[br]]
     42    isA is a function, that queries, if the Object is of a Specified type. e.g. given a class Player that is derived from BaseObject and [wiki:ParentNode PNode] one can do the following check :
     43{{{
     44#!cpp
     45 Player* player = new Player();
     46 if (player->isA(PNode::staticClassID()) {
     47   /* do something terrible with it */ }
     48}}}
     49
     50== Advanced Topics ==
     51An interessting Function, that BaseObject provides is the ObjectList.
     52With it, one can retrieve lists of any one kind of derived classes from BaseObject.