Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/ModulesDescription


Ignore:
Timestamp:
Mar 25, 2005, 4:06:35 PM (20 years ago)
Author:
patrick
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/ModulesDescription

    v1 v1  
     1= Module Description =
     2How to use certain modules in the Orxonox Framework
     3
     4== list ==
     5There is a list template called "tList" use it as follows:
     6
     7=== Use in Functions without Global Reference ===
     8It you just want to create a new list and just quickly use it make it as follows:
     9{{{
     10#include "list.h"                           /* include the header */
     11#include "debug.h"                          /* for use of PRINTF */
     12.
     13.
     14.
     15tList<char>* nameList = new tList<char*>(); /* create the new list*/
     16
     17nameList->add("Pumba");                     /* add some elements*/
     18nameList->add("Mogli");
     19nameList->add("Timon");
     20
     21tIterator<char>* nameIterator = nameList->getIterator(); /* get the iterator - JAVA style */
     22char name* = nameIterator->nextElement();   /* this returns the FIRST element */
     23while( name != NULL)                        /* nextElement() will return NULL at the end */
     24{
     25  PRINTF(3)("found name: %s in list\n", name);
     26  name = nameIterator->nextElement();       /* give back the next element or NULL if last */
     27}
     28.
     29.
     30}}}
     31This code will have an output like this:
     32{{{
     33found name: Pumpa in list
     34found name: Mogli in list
     35found name: Timon in list
     36}}}
     37You can make lists of whatever you want eg also from WorldEntities:
     38{{{
     39#include "list.h"
     40.
     41.
     42tList<WorldEntity>* entityList = new tList<WorldEntity>();  /* crete new list*/
     43entityList->add(new WorldEntity());                         /* just adds an new entity */
     44.
     45.
     46}}}
     47And you can make Lists of Lists :))
     48{{{
     49#include "list.h"
     50.
     51.
     52tList<char>* nameList = new tList<char>();
     53tList<tList<char> >* nameListList = new tList<tList<char> >(); /* don't forget the space (_): >_>
     54                                                                  otherwhise it will be interpreted
     55                                                                  as an operator
     56                                                               */
     57.
     58.
     59}}}
     60Now I hear you screem: "ENOUGH"! And you are right...:)
     61
     62=== Use in Header Files ===
     63If you want a list as a class attribute you have to make a forward declaration of the list:
     64{{{
     65
     66#inlcude "list.h"                 /* include the header of the list */
     67
     68template<class T> class tList;    /* forward declaration of the list */
     69
     70class ExampleClass
     71{
     72 private:
     73  tList<>
     74};
     75
     76}}}