Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5115 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Aug 24, 2005, 1:30:13 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: reimplemented the list functions, as i did before in revision 5110.
This time, i looked out for the bugs, and i think i found one

@patrick: i know, that you do not want to code at the moment… :/ → see mail

Location:
trunk/src/lib
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_detection/cd_engine.cc

    r5111 r5115  
    7171}
    7272
    73 
     73#include "class_list.h"
     74#include "state.h"
    7475/**
    7576 *  this checks the collisions with the objects
     
    8081  tIterator<WorldEntity>* iterator1 = entityList->getIterator();
    8182  tIterator<WorldEntity>* iterator2 = entityList->getIterator();
    82   WorldEntity* entity1 = iterator1->nextElement();
    83   WorldEntity* entity2 = iterator2->seekElement(entity1);
     83  WorldEntity* entity1 = iterator1->firstElement();
     84  WorldEntity* entity2 = iterator2->iteratorElement(iterator1);
     85  //entity2 = iterator2->nextElement();
    8486  PRINTF(3)("checking for collisions\n");
    8587  while( entity1 != NULL)
     
    8789    if( likely(entity1 != this->terrain))
    8890    {
     91      entity2 = iterator2->nextElement();
     92
    8993      while( entity2 != NULL)
    9094      {
    91         if( likely(entity2 != this->terrain))
     95//        if (entity2 != NULL)
     96//          printf("entity2::%s::%s", entity2->getClassName(), getName());
     97
     98        ///////////////// FIXME
     99        ///////////////// COMMENTED OUT, because some part of it generated a segfault
     100        ////////////////
     101
     102/*                if( likely(entity2 != this->terrain))
    92103        {
    93           PRINTF(3)("checking object %s against %s\n", entity1->getName(), entity2->getName());
     104          PRINTF(4)("checking object %s against %s\n", entity1->getName(), entity2->getName());
    94105          tree = entity1->getOBBTree();
    95           if( likely(tree != NULL)) tree->collideWith(entity1, entity2);
    96         }
     106          if( likely(tree != NULL) && entity2->getOBBTree() != NULL) tree->collideWith(entity1, entity2);
     107        }*/
    97108        entity2 = iterator2->nextElement();
    98109      }
     110//      printf("\n");
    99111    }
    100112    entity1 = iterator1->nextElement();
    101     entity2 = iterator2->seekElement(entity1);
    102 
     113    entity2 = iterator2->iteratorElement(iterator1);
    103114  }
    104115  delete iterator1;
     
    133144
    134145  tIterator<WorldEntity>* iterator = entityList->getIterator();
    135   WorldEntity* entity = iterator->nextElement();
     146  WorldEntity* entity = iterator->firstElement();
    136147  while( entity != NULL)
    137148  {
  • trunk/src/lib/collision_detection/obb_tree.cc

    r5028 r5115  
    4747{
    4848  this->setClassID(CL_OBB_TREE, "OBBTree");
     49
     50  this->rootNode = NULL;
    4951
    5052  material = new Material*[5];
  • trunk/src/lib/collision_detection/obb_tree_node.cc

    r5111 r5115  
    574574
    575575  iterator = partition1.getIterator();
    576   element = iterator->nextElement();
     576  element = iterator->firstElement();
    577577  index = 0;
    578578  while( element != NULL)
     
    592592
    593593  iterator = partition2.getIterator();
    594   element = iterator->nextElement();
     594  element = iterator->firstElement();
    595595  index = 0;
    596596  while( element != NULL)
  • trunk/src/lib/coord/p_node.cc

    r5113 r5115  
    7878PNode::~PNode ()
    7979{
     80  printf("deleting %s::%s\n", this->getClassName(), this->getName());
    8081  tIterator<PNode>* iterator = this->children->getIterator();
    81   PNode* pn = iterator->nextElement();
     82  PNode* pn = iterator->firstElement();
    8283  while( pn != NULL)
    8384    {
     
    435436
    436437  tIterator<PNode>* iterator = this->children->getIterator();
    437   PNode* pn = iterator->nextElement();
     438  PNode* pn = iterator->firstElement();
    438439
    439440  while( pn != NULL)
     
    605606    {
    606607      tIterator<PNode>* iterator = this->children->getIterator();
    607       PNode* pn = iterator->nextElement();
     608      PNode* pn = iterator->firstElement();
    608609      while( pn != NULL)
    609610      {
     
    615616
    616617        pn->update(dt);
    617           //pn = this->children->nextElement();
    618618        pn = iterator->nextElement();
    619619      }
     
    656656    tIterator<PNode>* iterator = this->children->getIterator();
    657657      //PNode* pn = this->children->enumerate ();
    658     PNode* pn = iterator->nextElement();
     658    PNode* pn = iterator->firstElement();
    659659    while( pn != NULL)
    660660    {
     
    722722  if (depth >= 2 || depth == 0)
    723723  {
     724    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
     725
    724726    tIterator<PNode>* iterator = this->children->getIterator();
    725       //PNode* pn = this->children->enumerate ();
    726     Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
    727     PNode* pn = iterator->nextElement();
     727    PNode* pn = iterator->firstElement();
    728728    while( pn != NULL)
    729729    {
  • trunk/src/lib/graphics/importer/model.cc

    r5111 r5115  
    192192
    193193    tIterator<Material>* tmpIt = this->materialList->getIterator();
    194     Material* material = tmpIt->nextElement();
     194    Material* material = tmpIt->firstElement();
    195195  //! @todo do we really have to delete this material??
    196196    while(material)
     
    413413{
    414414  tIterator<Material>* tmpIt = this->materialList->getIterator();
    415   Material* material = tmpIt->nextElement();
     415  Material* material = tmpIt->firstElement();
    416416  while(material)
    417417    {
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5113 r5115  
    5555
    5656  tIterator<Element2D>* iterator = this->children->getIterator();
    57   Element2D* pn = iterator->nextElement();
     57  Element2D* pn = iterator->firstElement();
    5858  while( pn != NULL)
    5959  {
     
    479479{
    480480  tIterator<Element2D>* iterator = this->children->getIterator();
    481   Element2D* pn = iterator->nextElement();
     481  Element2D* pn = iterator->firstElement();
    482482
    483483  while( pn != NULL)
     
    687687  {
    688688    tIterator<Element2D>* iterator = this->children->getIterator();
    689     Element2D* pn = iterator->nextElement();
     689    Element2D* pn = iterator->firstElement();
    690690    while( pn != NULL)
    691691    {
     
    697697
    698698      pn->update2D(dt);
    699           //pn = this->children->nextElement();
    700699      pn = iterator->nextElement();
    701700    }
     
    735734  {
    736735    tIterator<Element2D>* iterator = this->children->getIterator();
    737     Element2D* pn = iterator->nextElement();
     736    Element2D* pn = iterator->firstElement();
    738737    while( pn != NULL)
    739738    {
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r5111 r5115  
    105105  {
    106106    tIterator<Element2D>* iterator = this->element2DList[i]->getIterator();
    107     Element2D* elem = iterator->nextElement();
     107    Element2D* elem = iterator->firstElement();
    108108    while (elem != NULL)
    109109    {
     
    131131    {
    132132      tIterator<Element2D>* iterator = this->element2DList[i]->getIterator();
    133       Element2D* elem = iterator->nextElement();
     133      Element2D* elem = iterator->firstElement();
    134134      while (elem != NULL)
    135135      {
  • trunk/src/lib/graphics/spatial_separation/quadtree_node.cc

    r5111 r5115  
    253253  counter = 0;
    254254  iterator = listA->getIterator();
    255   tempTri = iterator->nextElement();
     255  tempTri = iterator->firstElement();
    256256  while( tempTri)
    257257  {
     
    262262  counter = 0;
    263263  iterator = listB->getIterator();
    264   tempTri = iterator->nextElement();
     264  tempTri = iterator->firstElement();
    265265  while( tempTri)
    266266  {
     
    271271  counter = 0;
    272272  iterator = listC->getIterator();
    273   tempTri = iterator->nextElement();
     273  tempTri = iterator->firstElement();
    274274  while( tempTri)
    275275  {
     
    280280  counter = 0;
    281281  iterator = listD->getIterator();
    282   tempTri = iterator->nextElement();
     282  tempTri = iterator->firstElement();
    283283  while( tempTri)
    284284  {
  • trunk/src/lib/graphics/text_engine.cc

    r5113 r5115  
    845845
    846846  tIterator<BaseObject>* textIterator = ClassList::getList(CL_TEXT)->getIterator();
    847   Text* text = dynamic_cast<Text*>(textIterator->nextElement());
     847  Text* text = dynamic_cast<Text*>(textIterator->firstElement());
    848848  while( text != NULL)
    849849    {
  • trunk/src/lib/lang/class_list.cc

    r5113 r5115  
    208208      {
    209209        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    210         BaseObject* enumBO = iterator->nextElement();
     210        BaseObject* enumBO = iterator->firstElement();
    211211        const char* tmpName;
    212212        while (enumBO != NULL)
     
    249249      {
    250250        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    251         BaseObject* enumBO = iterator->nextElement();
     251        BaseObject* enumBO = iterator->firstElement();
    252252        while (enumBO != NULL)
    253253        {
     
    362362        PRINT(0)("|  Listing Instances:\n");
    363363        tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    364         BaseObject* enumBO = iterator->nextElement();
     364        BaseObject* enumBO = iterator->firstElement();
    365365        while (enumBO)
    366366        {
  • trunk/src/lib/particles/particle_engine.cc

    r5111 r5115  
    5151ParticleEngine::~ParticleEngine ()
    5252{
     53  // we must not do this, because PNoe does it for us
     54  // or we do this with help from ClassList, which essentially makes much more sense
    5355  // delete all remaining systems
    54   tIterator<ParticleSystem>* sysIt = this->systemList->getIterator();
    55   ParticleSystem* tmpSys = sysIt->nextElement();
    56   while(tmpSys)
    57     {
    58       delete tmpSys;
    59       tmpSys = sysIt->nextElement();
    60     }
    61   delete sysIt;
    62   delete this->systemList;
    63 
    64   // delete all remaining emitters
    65   tIterator<ParticleEmitter>* emitIt = this->emitterList->getIterator();
    66   ParticleEmitter* tmpEmit = emitIt->nextElement();
    67   while(tmpEmit)
    68     {
    69       delete tmpEmit;
    70       tmpEmit = emitIt->nextElement();
    71     }
    72   delete emitIt;
    73   delete this->emitterList;
     56//   tIterator<ParticleSystem>* sysIt = this->systemList->getIterator();
     57//   ParticleSystem* tmpSys = sysIt->firstElement();
     58//   while(tmpSys)
     59//     {
     60//       delete tmpSys;
     61//       tmpSys = sysIt->nextElement();
     62//     }
     63//   delete sysIt;
     64   delete this->systemList;
     65//
     66//   // delete all remaining emitters
     67//   tIterator<ParticleEmitter>* emitIt = this->emitterList->getIterator();
     68//   ParticleEmitter* tmpEmit = emitIt->firstElement();
     69//   while(tmpEmit)
     70//     {
     71//       delete tmpEmit;
     72//       tmpEmit = emitIt->nextElement();
     73//     }
     74//   delete emitIt;
     75   delete this->emitterList;
    7476
    7577  // there should be no more Connections
     
    147149  // look, if we have already added this connection
    148150  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    149   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     151  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    150152  while(tmpConnection)
    151153    {
     
    178180  // remove any connections, that have this system within
    179181  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    180   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     182  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    181183  while(tmpConnection)
    182184    {
     
    199201  // remove any connections, that have this emitter within
    200202  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    201   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     203  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    202204  while(tmpConnection)
    203205    {
     
    224226  // look, if we have already added this connection
    225227  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    226   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     228  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    227229  while(tmpConnection)
    228230    {
     
    260262  // ticks all the ParticleSystems
    261263  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    262   ParticleSystem* tmpSys = tmpIt->nextElement();
     264  ParticleSystem* tmpSys = tmpIt->firstElement();
    263265  while(tmpSys)
    264266    {
     
    270272  // add new Particles to each System connected to an Emitter.
    271273  tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    272   ParticleConnection* tmpConnection = tmpConIt->nextElement();
     274  ParticleConnection* tmpConnection = tmpConIt->firstElement();
    273275  while(tmpConnection)
    274276    {
     
    285287{
    286288  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    287   ParticleSystem* tmpSys = tmpIt->nextElement();
     289  ParticleSystem* tmpSys = tmpIt->firstElement();
    288290  while(tmpSys)
    289291    {
     
    302304{
    303305  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    304   ParticleSystem* tmpSys = tmpIt->nextElement();
     306  ParticleSystem* tmpSys = tmpIt->firstElement();
    305307  while(tmpSys)
    306308    {
     
    324326  int count = 0;
    325327  tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    326   ParticleSystem* tmpSys = tmpIt->nextElement();
     328  ParticleSystem* tmpSys = tmpIt->firstElement();
    327329  while(tmpSys)
    328330    {
     
    346348{
    347349  tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    348   ParticleEmitter* tmpEmit = tmpIt->nextElement();
     350  ParticleEmitter* tmpEmit = tmpIt->firstElement();
    349351  while(tmpEmit)
    350352    {
     
    369371  int count = 0;
    370372  tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    371   ParticleEmitter* tmpEmit = tmpIt->nextElement();
     373  ParticleEmitter* tmpEmit = tmpIt->firstElement();
    372374  while(tmpEmit)
    373375    {
     
    402404
    403405    tIterator<ParticleConnection>* tmpConIt = connectionList->getIterator();
    404     ParticleConnection* tmpConnection = tmpConIt->nextElement();
     406    ParticleConnection* tmpConnection = tmpConIt->firstElement();
    405407    while(tmpConnection)
    406408    {
     
    414416  {
    415417    tIterator<ParticleSystem>* tmpIt = systemList->getIterator();
    416     ParticleSystem* tmpSys = tmpIt->nextElement();
     418    ParticleSystem* tmpSys = tmpIt->firstElement();
    417419    while(tmpSys)
    418420    {
     
    429431  {
    430432    tIterator<ParticleEmitter>* tmpIt = emitterList->getIterator();
    431     ParticleEmitter* tmpEmit = tmpIt->nextElement();
     433    ParticleEmitter* tmpEmit = tmpIt->firstElement();
    432434    while(tmpEmit)
    433435    {
  • trunk/src/lib/physics/physics_engine.cc

    r5111 r5115  
    5353  // delete all PhysicsConnections that are still in existence
    5454  tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    55   PhysicsConnection* enumPC = itPC->nextElement();
     55  PhysicsConnection* enumPC = itPC->firstElement();
    5656  while (enumPC)
    5757  {
     
    6060  }
    6161  delete itPC;
    62   delete this->connections;
    63 
    64   // delete all PhysicsInterfaces, still in existence (this could be dangerous)
    65   tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
    66   PhysicsInterface* enumPI = itPI->nextElement();
    67   while (enumPI)
    68   {
    69     delete enumPI;
    70 
    71     enumPI = itPI->nextElement();
    72   }
    73   delete itPI;
    74   delete this->interfaces;
    75 
    76   // delete all PhysicsFields, still in existence (this could be dangerous)
    77   tIterator<Field>* itF = this->fields->getIterator();
    78   Field* enumF = itF->nextElement();
    79   while (enumF)
    80   {
    81     delete enumF;
    82 
    83     enumF = itF->nextElement();
    84   }
    85   delete itF;
    86   delete this->fields;
     62   delete this->connections;
     63//
     64//   // delete all PhysicsInterfaces, still in existence (this could be dangerous)
     65//   tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
     66//   PhysicsInterface* enumPI = itPI->firstElement();
     67//   while (enumPI)
     68//   {
     69//     delete enumPI;
     70//
     71//     enumPI = itPI->nextElement();
     72//   }
     73//   delete itPI;
     74//   delete this->interfaces;
     75//
     76//   // delete all PhysicsFields, still in existence (this could be dangerous)
     77//   tIterator<Field>* itF = this->fields->getIterator();
     78//   Field* enumF = itF->firstElement();
     79//   while (enumF)
     80//   {
     81//     delete enumF;
     82//
     83//     enumF = itF->nextElement();
     84//   }
     85//   delete itF;
     86   delete this->fields;
    8787
    8888
     
    163163{
    164164  tIterator<PhysicsInterface>* tmpIt = interfaces->getIterator();
    165   PhysicsInterface* tmpInt = tmpIt->nextElement();
     165  PhysicsInterface* tmpInt = tmpIt->firstElement();
    166166  while(tmpInt)
    167167  {
     
    206206{
    207207  tIterator<Field>* tmpIt = fields->getIterator();
    208   Field* tmpField = tmpIt->nextElement();
     208  Field* tmpField = tmpIt->firstElement();
    209209  while(tmpField)
    210210  {
     
    251251{
    252252  tIterator<PhysicsConnection>* tmpIt = connections->getIterator();
    253   PhysicsConnection* tmpConn = tmpIt->nextElement();
     253  PhysicsConnection* tmpConn = tmpIt->firstElement();
    254254  while(tmpConn)
    255255  {
     
    278278  meaning let the fields work */
    279279  tIterator<PhysicsConnection>* itPC = this->connections->getIterator();
    280   PhysicsConnection* enumPC = itPC->nextElement();
     280  PhysicsConnection* enumPC = itPC->firstElement();
    281281  while (enumPC)
    282282    {
     
    289289  /* actually tick all the PhysicsInterfaces. Move the objects around */
    290290  tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator();
    291   PhysicsInterface* enumPI = itPI->nextElement();
     291  PhysicsInterface* enumPI = itPI->firstElement();
    292292  while (enumPI)
    293293    {
  • trunk/src/lib/physics/physics_interface.cc

    r5111 r5115  
    6868
    6969    tIterator<PNode>* iterator = massCalcPNode->children->getIterator();
    70     PNode* pn = iterator->nextElement();
     70    PNode* pn = iterator->firstElement();
    7171    while( pn != NULL)
    7272    {
  • trunk/src/lib/sound/sound_engine.cc

    r5111 r5115  
    215215  {
    216216    tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    217     SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
     217    SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    218218    while (enumSource)
    219219    {
     
    228228  {
    229229    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    230     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
     230    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    231231    while (enumBuffer)
    232232    {
     
    298298  // look if there are any sources that have the buffer still loaded
    299299  tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    300   SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
     300  SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    301301  while (enumSource)
    302302    {
     
    345345  {
    346346    tIterator<BaseObject>* iterator = this->sourceList->getIterator();
    347     SoundSource* enumSource = (SoundSource*)iterator->nextElement();
     347    SoundSource* enumSource = (SoundSource*)iterator->firstElement();
    348348    while (enumSource)
    349349    {
     
    373373  {
    374374    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    375     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
     375    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    376376    while (enumBuffer)
    377377    {
    378378      tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    379       SoundSource* enumSource = (SoundSource*)sourceIterator->nextElement();
     379      SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    380380      while (enumSource)
    381381      {
     
    401401  {
    402402    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    403     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
     403    SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    404404    while (enumBuffer)
    405405    {
     
    419419  {
    420420    tIterator<BaseObject>* Iterator = this->sourceList->getIterator();
    421     SoundSource* enumSource = (SoundSource*)Iterator->nextElement();
     421    SoundSource* enumSource = (SoundSource*)Iterator->firstElement();
    422422    while (enumSource)
    423423    {
  • trunk/src/lib/util/ini_parser.cc

    r5111 r5115  
    5858  {
    5959    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    60     IniSection* sectionEnum = sectionIt->nextElement();
     60    IniSection* sectionEnum = sectionIt->firstElement();
    6161    while (sectionEnum)
    6262    {
    6363      tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    64       IniEntry* entryEnum = entryIt->nextElement();
     64      IniEntry* entryEnum = entryIt->firstElement();
    6565      while (entryEnum)
    6666      {
     
    192192    {
    193193      tIterator<IniSection>* sectionIt = this->sections->getIterator();
    194       IniSection* sectionEnum = sectionIt->nextElement();
     194      IniSection* sectionEnum = sectionIt->firstElement();
    195195      while (sectionEnum)
    196196      {
     
    198198
    199199        tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    200         IniEntry* entryEnum = entryIt->nextElement();
     200        IniEntry* entryEnum = entryIt->firstElement();
    201201        while (entryEnum)
    202202        {
     
    246246{
    247247  tIterator<IniSection>* sectionIt = this->sections->getIterator();
    248   IniSection* sectionEnum = sectionIt->nextElement();
     248  IniSection* sectionEnum = sectionIt->firstElement();
    249249  while (sectionEnum)
    250250  {
     
    347347  {
    348348    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    349     IniSection* sectionEnum = sectionIt->nextElement();
     349    IniSection* sectionEnum = sectionIt->firstElement();
    350350    while (sectionEnum)
    351351    {
     
    395395  {
    396396    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    397     IniSection* sectionEnum = sectionIt->nextElement();
     397    IniSection* sectionEnum = sectionIt->firstElement();
    398398    while (sectionEnum)
    399399    {
     
    401401      {
    402402        tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    403         IniEntry* entryEnum = entryIt->nextElement();
     403        IniEntry* entryEnum = entryIt->firstElement();
    404404        while (entryEnum)
    405405        {
     
    452452  {
    453453    tIterator<IniSection>* sectionIt = this->sections->getIterator();
    454     IniSection* sectionEnum = sectionIt->nextElement();
     454    IniSection* sectionEnum = sectionIt->firstElement();
    455455    while (sectionEnum)
    456456    {
     
    458458
    459459      tIterator<IniEntry>* entryIt = sectionEnum->entries->getIterator();
    460       IniEntry* entryEnum = entryIt->nextElement();
     460      IniEntry* entryEnum = entryIt->firstElement();
    461461      while (entryEnum)
    462462      {
  • trunk/src/lib/util/list.h

    r5113 r5115  
    1212#endif
    1313
    14 
     14template<class T> class tIterator;
    1515
    1616//! a list element of the tList,
     
    2323
    2424/**
    25  *  an iterator class
    26 
    27    this enables the user to iterate through a list very easely
    28 */
    29 template<class T> class tIterator
    30 {
    31  public:
    32   tIterator(listElement<T>* startElement);
    33   ~tIterator();
    34 
    35   T* nextElement();
    36   T* seekElement(T* element);
    37 
    38  private:
    39   listElement<T>*    currentEl;                      //!< pointer to the current list element in the iterator
    40   listElement<T>*    tmpEl;                          //!< temp listElemnt pointer
    41   listElement<T>*    startElement;                   //!< pointer to the start of the list
    42 };
    43 
    44 
    45 /**
    46  *  iterator constructor
    47  * @param startElement:  the first list element from the tList
    48 
    49    normaly you will use it like this:
    50 
    51    tIterator<char>* nameIterator = nameList->getIterator();
    52    char name* = nameIterator->nextElement();
    53    while( name != NULL)
    54    {
    55      PRINTF(3)("found name: %s in list\n", name);
    56      name = nameIterator->nextElement();
    57    }
    58    delete nameIterator;
    59 */
    60 template<class T>
    61 inline tIterator<T>::tIterator (listElement<T>* startElement)
    62 {
    63   this->currentEl = startElement;
    64   this->tmpEl = NULL;
    65   this->startElement = startElement;
    66 }
    67 
    68 
    69 /**
    70  *  the destructor
    71 */
    72 template<class T>
    73 inline tIterator<T>::~tIterator ()
    74 {
    75   this->currentEl = NULL;
    76 }
    77 
    78 
    79 /**
    80  *  use it to iterate through the list
    81  * @returns next list element
    82 */
    83 template<class T>
    84 inline T* tIterator<T>::nextElement ()
    85 {
    86   if( this->currentEl == NULL)
    87     return NULL;
    88 
    89   this->tmpEl = this->currentEl;
    90   this->currentEl = this->currentEl->next;
    91   return this->tmpEl->curr;
    92 }
    93 
    94 /**
    95  *  gets the element after the selected one, sets the iterator to this point in the list
    96  * @param element the element to seek
    97  * @returns next list element
    98 
    99   Attention: if you seek an element, the iterator pointer will point to the NEXT listelement after the argument!
    100  */
    101 template<class T>
    102 inline T* tIterator<T>::seekElement (T* element)
    103 {
    104   for(this->tmpEl = this->startElement; this->tmpEl != NULL; this->tmpEl = this->tmpEl->next)
    105   {
    106     if( unlikely(this->tmpEl->curr == element))
    107     {
    108       if( this->tmpEl->next != NULL)
    109       {
    110         this->currentEl = this->tmpEl->next->next;
    111         return this->tmpEl->next->curr;
    112       }
    113       return NULL;
    114     }
    115   }
    116   return NULL;
    117 }
    118 
    119 
    120 
    121 /**
    12225 *  the list template class
    12326
     
    12629template<class T> class tList
    12730{
     31  friend class tIterator<T>;
     32
    12833 public:
    12934  tList ();
     
    374279inline tIterator<T>* tList<T>::getIterator() const
    375280{
    376   tIterator<T>* iterator = new tIterator<T>(this->first);
    377   return iterator;
     281  return new tIterator<T>(this);
    378282}
    379283
     
    414318}
    415319
     320
     321
     322
     323/**
     324 *  an iterator class
     325
     326   this enables the user to iterate through a list very easely
     327 */
     328template<class T> class tIterator
     329{
     330  public:
     331    tIterator(const tList<T>* list);
     332    ~tIterator();
     333
     334    T* firstElement();
     335    T* nextElement();
     336    T* seekElement(T* element);
     337    T* iteratorElement(const tIterator<T>* iterator);
     338
     339  private:
     340    listElement<T>*    currentEl;                      //!< pointer to the current list element in the iterator
     341    listElement<T>*    tmpEl;                          //!< temp listElemnt pointer
     342    const tList<T>*    list;                           //!< The List, that we want to iterate through
     343};
     344
     345
     346/**
     347 *  iterator constructor
     348 * @param startElement:  the first list element from the tList
     349 *
     350 * normaly you will use it like this:
     351 **********************************************************
     352 * tIterator<char>* nameIterator = nameList->getIterator();
     353 * char name* = nameIterator->firstElement();
     354 * while( name != NULL)
     355 *  {
     356 *   PRINTF(3)("found name: %s in list\n", name);
     357 *   name = nameIterator->nextElement();
     358 *  }
     359 * delete nameIterator;
     360 * ********************************************************
     361 */
     362template<class T>
     363  inline tIterator<T>::tIterator (const tList<T>* list)
     364{
     365  this->currentEl = list->first;
     366  this->tmpEl = NULL;
     367  this->list = list;
     368}
     369
     370
     371/**
     372 *  the destructor
     373 */
     374template<class T>
     375    inline tIterator<T>::~tIterator ()
     376{
     377  this->currentEl = NULL;
     378}
     379
     380template<class T>
     381    inline T* tIterator<T>::firstElement ()
     382{
     383  this->currentEl = this->list->first;
     384  if (this->currentEl == NULL)
     385    return NULL;
     386  else
     387    return this->currentEl->curr;
     388}
     389
     390
     391/**
     392 *  use it to iterate through the list
     393 * @returns next list element
     394 */
     395template<class T>
     396    inline T* tIterator<T>::nextElement ()
     397{
     398  if( this->currentEl == NULL)
     399    return NULL;
     400
     401  this->currentEl = this->currentEl->next;
     402  if (this->currentEl != NULL)
     403    return this->currentEl->curr;
     404  else
     405    return NULL;
     406}
     407
     408/**
     409 *  gets the element after the selected one, sets the iterator to this point in the list
     410 * @param element the element to seek
     411 * @returns current list element
     412 */
     413template<class T>
     414    inline T* tIterator<T>::seekElement (T* element)
     415{
     416  if (element == NULL)
     417  {
     418    this->currentEl = NULL;
     419    return NULL;
     420  }
     421  this->tmpEl = this->list->first;
     422  while( this->tmpEl != NULL)
     423  {
     424    if( unlikely(this->tmpEl->curr == element))
     425    {
     426      this->currentEl = this->tmpEl;
     427      return this->currentEl->curr;
     428    }
     429    this->tmpEl = this->tmpEl->next;
     430  }
     431  this->currentEl = NULL;
     432  return NULL;
     433}
     434
     435/**
     436 * grabs the iterator entity from another iterator
     437 * @param iterator the iterator to grab the local currentEl from
     438 * @returns the grabbed element (current).
     439 */
     440template<class T>
     441    T* tIterator<T>::iteratorElement(const tIterator<T>* iterator)
     442{
     443  if (iterator != NULL)
     444  {
     445    this->currentEl = iterator->currentEl;
     446    if (this->currentEl != NULL)
     447      return this->currentEl->curr;
     448    else
     449      return NULL;
     450  }
     451  else
     452  {
     453    this->currentEl = NULL;
     454    return NULL;
     455  }
     456}
     457
     458
    416459#endif /* _LIST_H */
Note: See TracChangeset for help on using the changeset viewer.