Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5779 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Nov 26, 2005, 2:20:58 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ClassList is now in std::list style
ShellCommand is now in std::list style

Location:
trunk/src
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/text_engine/text_engine.cc

    r5515 r5779  
    6464{
    6565  // first remove all the remaining Texts (if any).
    66   tList<BaseObject>* textList = ClassList::getList(CL_TEXT);
     66  std::list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    6767  if (textList != NULL)
    6868  {
    69     tIterator<BaseObject>* textIterator = textList->getIterator();
    70     Text* text = dynamic_cast<Text*>(textIterator->firstElement());
    71     while( text != NULL)
     69    while(textList->size() > 0)
    7270    {
    73       delete text;
    74       text = dynamic_cast<Text*>(textIterator->nextElement());
     71      delete dynamic_cast<Text*>(textList->front());
    7572    }
    76     delete textIterator;
    7773  }
    7874  // delete all remaining fonts (There should not be Anything to do here)
    79   tList<BaseObject>* fontList = ClassList::getList(CL_FONT);
     75  std::list<BaseObject*>* fontList = ClassList::getList(CL_FONT);
    8076  if (fontList != NULL)
    8177  {
    82     tIterator<BaseObject>* fontIterator = fontList->getIterator();
    83     Font* font = dynamic_cast<Font*>(fontIterator->firstElement());
    84     while( font != NULL)
     78//    while (fontList->size() > 0)
    8579    {
     80      Font* font = dynamic_cast<Font*>(fontList->front());
    8681      if (likely(font != Font::getDefaultFont()))
    8782        ResourceManager::getInstance()->unload(font, RP_GAME);
    88       font = dynamic_cast<Font*>(fontIterator->nextElement());
    8983    }
    90     delete fontIterator;
    9184  }
    92 
    9385  this->disableFonts();
    9486
     
    133125void TextEngine::debug() const
    134126{
    135   tList<BaseObject>* textList = ClassList::getList(CL_TEXT);
     127  list<BaseObject*>* textList = ClassList::getList(CL_TEXT);
    136128  if (textList != NULL)
    137129  {
     
    139131    PRINT(0)("+ TEXT ENGINE DEBUG INFORMATION +\n");
    140132    PRINT(0)("+-------------------------------+\n");
    141     PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->getSize());
     133    PRINT(0)("Reference: %p; Text Counts: %d\n", this, textList->size());
    142134
    143     tIterator<BaseObject>* textIterator = textList->getIterator();
    144     Text* text = dynamic_cast<Text*>(textIterator->firstElement());
    145     while( text != NULL)
    146       {
    147         text->debug();
    148         text = dynamic_cast<Text*>(textIterator->nextElement());
    149       }
    150     delete textIterator;
     135    list<BaseObject*>::iterator text;
     136    for ( text = textList->begin(); text != textList->end(); text++)
     137      dynamic_cast<Text*>(*text)->debug();
    151138    PRINT(0)("+---------------------------TE--+\n");
    152139  }
  • trunk/src/lib/lang/class_list.cc

    r5770 r5779  
    4040  this->className = className;
    4141  this->classID = classID;
    42   this->objectList = new tList<BaseObject>;
    4342
    4443  ++ClassList::classCount;
     
    5049ClassList::~ClassList ()
    5150{
    52   delete this->objectList;
    53   if(ClassList::classList != NULL)
    54   {
    55     delete ClassList::classList;
    56     ClassList::classList = NULL;
    57   }
     51  /// FIXME
     52//   if(ClassList::classList != NULL)
     53//   {
     54//     delete ClassList::classList;
     55//     ClassList::classList = NULL;
     56//   }
    5857  --ClassList::classCount;
    5958}
     
    6665
    6766//! a List of all strings of all classes, that have registered so far.
    68 tList<const char>* ClassList::classList = NULL;
     67std::list<const char*> ClassList::classList;
    6968
    7069/**
     
    10099    }
    101100  }
    102   regClass->objectList->add(objectPointer);
     101  regClass->objectList.push_back(objectPointer);
    103102}
    104103
     
    114113    if (objectPointer->isA(tmp->classID))
    115114    {
    116       tmp->objectList->remove(objectPointer);
     115      tmp->objectList.remove(objectPointer);
    117116    }
    118117    tmp = tmp->next;
     
    127126 * befor it changes anything.
    128127 */
    129 const tList<const char>* ClassList::getClassList()
    130 {
    131   if (unlikely(ClassList::classList != NULL && ClassList::classList->getSize() != ClassList::classCount))
    132   {
    133     delete ClassList::classList;
    134     ClassList::classList = NULL;
    135   }
    136   if (unlikely(ClassList::classList == NULL))
    137     ClassList::classList = new tList<const char>;
     128const std::list<const char*>* ClassList::getClassList()
     129{
     130  if (ClassList::classList.size() != ClassList::classCount)
     131    ClassList::classList.erase(ClassList::classList.begin(), ClassList::classList.end());
    138132
    139133  if(likely(ClassList::first != NULL))
     
    142136    while (likely(tmpCL != NULL))
    143137    {
    144       ClassList::classList->add(tmpCL->className);
    145       tmpCL = tmpCL->next;
    146     }
    147   }
    148   return ClassList::classList;
     138      ClassList::classList.push_back(tmpCL->className);
     139      tmpCL = tmpCL->next;
     140    }
     141  }
     142  return &ClassList::classList;
    149143}
    150144
     
    154148 * @return the List accessed by classID, or NULL if not found
    155149 */
    156 tList<BaseObject>* ClassList::getList(long classID)
     150std::list<BaseObject*>* ClassList::getList(long classID)
    157151{
    158152  if(unlikely(ClassList::first == NULL))
     
    164158    {
    165159      if (unlikely(tmpCL->classID == classID))
    166         return tmpCL->objectList;
     160        return &tmpCL->objectList;
    167161      tmpCL = tmpCL->next;
    168162    }
     
    175169 * @param className the name of the class to get the list from
    176170 * @return the List accessed by classID, or NULL if not found
    177  */tList<BaseObject>* ClassList::getList(const char* className)
     171 */
     172std::list<BaseObject*>* ClassList::getList(const char* className)
    178173{
    179174  if(unlikely(ClassList::first == NULL))
     
    185180    {
    186181      if (unlikely(!strcmp(tmpCL->className, className)))
    187         return tmpCL->objectList;
     182        return &tmpCL->objectList;
    188183      tmpCL = tmpCL->next;
    189184    }
     
    210205      if (tmp->classID == classID || classID == CL_NULL)
    211206      {
    212         tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    213         BaseObject* enumBO = iterator->firstElement();
    214         const char* tmpName;
    215         while (enumBO != NULL)
    216         {
    217           tmpName = enumBO->getName();
    218           if (tmpName && !strcmp(tmpName, name))
    219           {
    220             delete iterator;
    221             return enumBO;
    222           }
    223           enumBO = iterator->nextElement();
    224         }
    225         delete iterator;
     207        list<BaseObject*>::iterator bo;
     208        for (bo = tmp->objectList.begin(); bo != tmp->objectList.end(); bo++)
     209          if ((*bo)->getName() && !strcmp((*bo)->getName(), name))
     210            return (*bo);
    226211        break;
    227212      }
     
    251236      if (tmp->classID == classID || classID == CL_NULL)
    252237      {
    253         tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    254         const BaseObject* enumBO = iterator->firstElement();
    255         while (enumBO != NULL)
    256         {
    257           if (enumBO == object)
    258           {
    259             delete iterator;
     238        list<BaseObject*>::iterator bo;
     239        for (bo = tmp->objectList.begin(); bo != tmp->objectList.end(); bo++)
     240          if ((*bo) == object)
    260241            return true;
    261           }
    262           enumBO = iterator->nextElement();
    263         }
    264242        if (likely(tmp->classID == classID))
    265         {
    266           delete iterator;
    267243          break;
    268         }
    269244      }
    270245      tmp = tmp->next;
     
    354329  while (likely(tmp != NULL))
    355330  {
    356     if ((debugLevel >= 1 || tmp->objectList->getSize() > 0 ) &&
     331    if ((debugLevel >= 1 || tmp->objectList.size() > 0 ) &&
    357332         (classID == CL_NULL || unlikely (classID == tmp->classID)))
    358333    {
    359334      lenCount = 1;
    360       while (pow(10,lenCount) <= tmp->objectList->getSize())
     335      while (pow(10, lenCount) <= tmp->objectList.size())
    361336        ++lenCount;
    362337      for (int i=0; i < 30-strlen(tmp->className) - lenCount; i++)
     
    364339      niceString[30-strlen(tmp->className) - lenCount] = '\0';
    365340
    366       PRINT(0)("| CLASS %s:%s %d\n", tmp->className, niceString, tmp->objectList->getSize());
    367 
    368       if (debugLevel >=2 && tmp->objectList->getSize() > 0)
     341      PRINT(0)("| CLASS %s:%s %d\n", tmp->className, niceString, tmp->objectList.size());
     342
     343      if (debugLevel >=2 && tmp->objectList.size() > 0)
    369344      {
    370345        PRINT(0)("|  Listing Instances:\n");
    371         tIterator<BaseObject>* iterator = tmp->objectList->getIterator();
    372         BaseObject* enumBO = iterator->firstElement();
    373         while (enumBO)
     346        list<BaseObject*>::const_iterator bo;
     347        for (bo = tmp->objectList.begin(); bo != tmp->objectList.end(); bo++)
    374348        {
    375           PRINT(0)("|   (class %s): NAME(%s)->%p ", enumBO->getClassName(), enumBO->getName(), enumBO);
     349          PRINT(0)("|   (class %s): NAME(%s)->%p ", (*bo)->getClassName(), (*bo)->getName(), (*bo));
    376350          if (debugLevel == 3)
    377             ClassList::whatIs(enumBO);
     351            ClassList::whatIs(*bo);
    378352          PRINT(0)("\n");
    379           enumBO = iterator->nextElement();
    380353        }
    381         delete iterator;
    382354      }
    383355    }
  • trunk/src/lib/lang/class_list.h

    r5405 r5779  
    99
    1010#include "class_id.h"
     11#include <list>
    1112
    1213// FORWARD DECLARATION
    1314class BaseObject;
    14 template<class T> class tList;
    15 
    1615
    1716//! A class that handles Pointers to Objects of all type.
     
    3534
    3635    // STATIC FUNCTIONS
    37     static void                     addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
    38     static void                     removeFromClassList(BaseObject* objectPointer);
     36    static void                          addToClassList(BaseObject* objectPointer, const long& classID, const char* className);
     37    static void                          removeFromClassList(BaseObject* objectPointer);
    3938
    40     static tList<BaseObject>*       getList(long classID = CL_NULL);
    41     static tList<BaseObject>*       getList(const char* className);
    42     static const tList<const char>* getClassList();
    43     static BaseObject*              getObject(const char* name, long classID = CL_NULL);
    44     static bool                     exists(const BaseObject* object, long classID = CL_NULL);
     39    static std::list<BaseObject*>*       getList(long classID = CL_NULL);
     40    static std::list<BaseObject*>*       getList(const char* className);
     41    static const std::list<const char*>* getClassList();
     42    static BaseObject*                   getObject(const char* name, long classID = CL_NULL);
     43    static bool                          exists(const BaseObject* object, long classID = CL_NULL);
    4544
    46     static void                     whatIs(const BaseObject* object);
     45    static void                          whatIs(const BaseObject* object);
    4746
    48     static const char*              IDToString(long classID = CL_NULL);
    49     static long                     StringToID(const char* className);
    50     static void                     debug(unsigned int debugLevel = 0, long classID = CL_NULL);
    51     static void                     debugS(const char* className = 0x0, unsigned int debugLevel = 0);
     47    static const char*                   IDToString(long classID = CL_NULL);
     48    static long                          StringToID(const char* className);
     49    static void                          debug(unsigned int debugLevel = 0, long classID = CL_NULL);
     50    static void                          debugS(const char* className = 0x0, unsigned int debugLevel = 0);
     51
    5252
    5353
    5454  private:
    55     tList<BaseObject>*              objectList;             //!< A list of Objects belonging to this Class
     55    std::list<BaseObject*>          objectList;             //!< A list of Objects belonging to this Class
    5656
    5757    long                            classID;                //!< ClassID stored in this ClassList \see ClassID
     
    6262    // STATIC MEMBERS
    6363    static ClassList*               first;                  //!< The first Class in the List
    64     static tList<const char>*       classList;              //!< a List of all Names of all classes, that have registered so far.
     64    static std::list<const char*>   classList;              //!< a List of all Names of all classes, that have registered so far.
    6565    static unsigned int             classCount;             //!< The Count of classes that have been registered (should match the lower description)
    6666};
  • trunk/src/lib/physics/physics_engine.cc

    r5778 r5779  
    131131PhysicsInterface* PhysicsEngine::getPhysicsInterfaceByName(const char* physicsInterfaceName) const
    132132{
    133   tIterator<BaseObject>* tmpIt = ClassList::getList(CL_PHYSICS_INTERFACE)->getIterator();
    134   BaseObject* tmpInt = tmpIt->firstElement();
    135   while(tmpInt)
    136   {
    137     if (!strcmp(physicsInterfaceName, tmpInt->getName()))
    138     {
    139       delete tmpIt;
    140       return dynamic_cast<PhysicsInterface*>(tmpInt);
    141     }
    142     tmpInt = tmpIt->nextElement();
    143   }
    144   delete tmpIt;
    145   return NULL;
     133  BaseObject* interface = ClassList::getObject(physicsInterfaceName, CL_PHYSICS_INTERFACE);
     134  return (interface != NULL)?  dynamic_cast<PhysicsInterface*>(interface) : NULL;
    146135}
    147136
     
    237226  if (this->interfaces != NULL || (this->interfaces = ClassList::getList(CL_PHYSICS_INTERFACE)) != NULL)
    238227  {
    239     tIterator<BaseObject>* itPI = this->interfaces->getIterator();
    240     PhysicsInterface* enumPI = dynamic_cast<PhysicsInterface*>(itPI->firstElement());
    241     while (enumPI)
    242     {
    243        enumPI->tickPhys(dt);
    244 
    245       enumPI = dynamic_cast<PhysicsInterface*>(itPI->nextElement());
    246     }
    247    delete itPI;
     228    list<BaseObject*>::const_iterator tickPhys;
     229    for (tickPhys = this->interfaces->begin(); tickPhys != this->interfaces->end(); tickPhys++)
     230      dynamic_cast<PhysicsInterface*>(*tickPhys)->tickPhys(dt);
    248231  }
    249232}
     
    261244  PRINT(0)(" reference: %p\n", this);
    262245  if (this->interfaces != NULL)
    263     PRINT(0)(" number of Interfaces: %d\n", this->interfaces->getSize());
     246    PRINT(0)(" number of Interfaces: %d\n", this->interfaces->size());
    264247  PRINT(0)(" number of Fields: %d\n", this->fields.size());
    265248  PRINT(0)(" number of Connections: %d\n", this->connections.size());
  • trunk/src/lib/physics/physics_engine.h

    r5777 r5779  
    5454  std::list<Field*>             fields;               //!< a list of physicsl fields.
    5555  std::list<PhysicsConnection*> connections;          //!< a list of physical connections.
    56   const tList<BaseObject>*      interfaces;           //!< The list of physical interfaces.
     56  const std::list<BaseObject*>* interfaces;           //!< The list of physical interfaces.
    5757};
    5858
  • trunk/src/lib/shell/shell_command.cc

    r5656 r5779  
    4747  this->shellClass = ShellCommandClass::getCommandClass(className); //ClassList::IDToString(classID);
    4848  if (this->shellClass != NULL)
    49     this->shellClass->commandList->add(this);
     49    this->shellClass->commandList.push_back(this);
    5050}
    5151
     
    8282void ShellCommand::unregisterCommand(const char* commandName, const char* className)
    8383{
    84   if (ShellCommandClass::commandClassList == NULL)
     84  /// FIXME
     85/*  if (ShellCommandClass::commandClassList == NULL)
    8586    ShellCommandClass::initCommandClassList();
    8687
     
    8990 if (checkClass != NULL)
    9091  {
    91     tIterator<ShellCommand>* iterator = checkClass->commandList->getIterator();
    92     ShellCommand* elem = iterator->firstElement();
    93     while(elem != NULL)
    94     {
    95       if (!strcmp(commandName, elem->getName()))
    96       {
    97         checkClass->commandList->remove(elem);
    98         delete elem;
     92    std::list<ShellCommand*>::iterator elem;
     93    for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
     94    {
     95      if (!strcmp(commandName, (*elem)->getName()))
     96      {
     97        delete (*elem);
     98        checkClass->commandList.remove(*elem);
    9999        break;
    100100      }
    101       elem = iterator->nextElement();
    102     }
    103     delete iterator;
    104 
    105     if (checkClass->commandList->getSize() == 0)
     101    }
     102
     103    if (checkClass->commandList->size() == 0)
    106104    {
    107105      ShellCommandClass::commandClassList->remove(checkClass);
    108106      delete checkClass;
    109107    }
    110   }
     108  }*/
    111109}
    112110
     
    132130  if (checkClass != NULL)
    133131  {
    134     tIterator<ShellCommand>* iterator = checkClass->commandList->getIterator();
    135     ShellCommand* elem = iterator->firstElement();
    136     while(elem != NULL)
    137    {
    138      if (!strcmp(commandName, elem->getName()))
    139      {
    140        PRINTF(2)("Command already registered\n");
    141        delete iterator;
    142        return true;
    143       }
    144      elem = iterator->nextElement();
    145    }
    146    delete iterator;
     132    std::list<ShellCommand*>::const_iterator elem;
     133    for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
     134    {
     135      if (!strcmp(commandName, (*elem)->getName()))
     136      {
     137        PRINTF(2)("Command '%s::%s' already registered\n", className, commandName);
     138        return true;
     139      }
     140    }
    147141   return false;
    148142  }
     
    163157    return false;
    164158
    165   long classID = CL_NULL;                 //< the classID retrieved from the Class.
    166   ShellCommandClass* commandClass = NULL; //< the command class this command applies to.
    167   tList<BaseObject>* objectList = NULL;   //< the list of Objects stored in classID
    168   BaseObject* objectPointer = NULL;       //< a pointer to th Object to Execute the command on
    169   bool emptyComplete = false;             //< if the completion input is empty string. e.g ""
    170   unsigned int fktPos = 1;                //< the position of the function (needed for finding it)
    171 //  long completeType = SHELLC_NONE;      //< the Type we'd like to complete.
     159  long classID = CL_NULL;                      //< the classID retrieved from the Class.
     160  ShellCommandClass* commandClass = NULL;      //< the command class this command applies to.
     161  std::list<BaseObject*>* objectList = NULL;   //< the list of Objects stored in classID
     162  BaseObject* objectPointer = NULL;            //< a pointer to th Object to Execute the command on
     163  bool emptyComplete = false;                  //< if the completion input is empty string. e.g ""
     164  unsigned int fktPos = 1;                     //< the position of the function (needed for finding it)
     165//  long completeType = SHELLC_NONE;           //< the Type we'd like to complete.
    172166  SubString inputSplits(executionString, " \t\n,");
    173167
     
    179173    if (ShellCommandClass::aliasList != NULL)
    180174    {
    181       tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator();
    182       ShellCommandAlias* elemAL = itAL->firstElement();
    183       while(elemAL != NULL)
    184       {
    185         if (elemAL->getName() != NULL && !strcmp(elemAL->getName(), inputSplits.getString(0)) && elemAL->getCommand() != NULL &&
    186             elemAL->getCommand()->shellClass != NULL )
     175      list<ShellCommandAlias*>::iterator alias;
     176      for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++ )
     177      {
     178        if ((*alias)->getName() != NULL && !strcmp((*alias)->getName(), inputSplits.getString(0)) && (*alias)->getCommand() != NULL &&
     179            (*alias)->getCommand()->shellClass != NULL )
    187180        {
    188           objectList = ClassList::getList(elemAL->getCommand()->shellClass->getName());
     181          objectList = ClassList::getList((*alias)->getCommand()->shellClass->getName());
    189182          if (objectList != NULL)
    190183          {
    191184            if (inputSplits.getCount() > 1)
    192               elemAL->getCommand()->executor->execute(objectList->firstElement(), executionString+inputSplits.getOffset(1));
     185              (*alias)->getCommand()->executor->execute(objectList->front(), executionString+inputSplits.getOffset(1));
    193186            else
    194               elemAL->getCommand()->executor->execute(objectList->firstElement(), "");
    195             delete itAL;
     187              (*alias)->getCommand()->executor->execute(objectList->front(), "");
     188           return true;
     189          }
     190        }
     191      }
     192    }
     193    // looking for a Matching Class
     194    if (likely(ShellCommandClass::commandClassList != NULL))
     195    {
     196      list<ShellCommandClass*>::iterator commandClassIT;
     197      for (commandClassIT = ShellCommandClass::commandClassList->begin(); commandClassIT != ShellCommandClass::commandClassList->end(); commandClassIT++)
     198      {
     199        if ((*commandClassIT)->getName() && !strcasecmp(inputSplits.getString(0), (*commandClassIT)->getName()))
     200        {
     201          //elemCL->getName();
     202          classID = ClassList::StringToID((*commandClassIT)->getName());
     203          commandClass = (*commandClassIT);
     204          objectList = ClassList::getList(classID);
     205          break;
     206        }
     207      }
     208    }
     209
     210    if (commandClass != NULL && inputSplits.getCount() >= 2)
     211    {
     212      if (objectList != NULL)
     213      {
     214        // Checking for a Match in the Objects of classID (else take the first)
     215        list<BaseObject*>::const_iterator object;
     216        for (object = objectList->begin(); object != objectList->end(); object++)
     217        {
     218          if ((*object)->getName() != NULL && !strcasecmp((*object)->getName(), inputSplits.getString(1)))
     219          {
     220            objectPointer = (*object);
     221            fktPos = 2;
     222            break;
     223          }
     224         }
     225
     226      //
     227        if (objectPointer == NULL)
     228          objectPointer = objectList->front();
     229      }
     230      // match a function.
     231      if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3)))
     232      {
     233        list<ShellCommand*>::iterator cmdIT;
     234        for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++)
     235        {
     236          if (!strcmp((*cmdIT)->getName(), inputSplits.getString(fktPos)))
     237          {
     238            if (objectPointer == NULL && (*cmdIT)->executor->getType() & Executor_Objective)
     239              return false;
     240            if (inputSplits.getCount() > fktPos+1)
     241              (*cmdIT)->executor->execute(objectPointer, executionString+inputSplits.getOffset(fktPos +1));
     242            else
     243              (*cmdIT)->executor->execute(objectPointer, "");
    196244            return true;
    197245          }
    198246        }
    199         elemAL = itAL->nextElement();
    200       }
    201       delete itAL;
    202     }
    203     // looking for a Matching Class
    204     if (likely(ShellCommandClass::commandClassList != NULL))
    205     {
    206       tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator();
    207       ShellCommandClass* elemCL = itCL->firstElement();
    208       while(elemCL != NULL)
    209       {
    210         if (elemCL->getName() && !strcasecmp(inputSplits.getString(0), elemCL->getName()))
    211         {
    212           //elemCL->getName();
    213           classID = ClassList::StringToID(elemCL->getName());
    214           commandClass = elemCL;
    215           objectList = ClassList::getList(classID);
    216           break;
    217         }
    218         elemCL = itCL->nextElement();
    219       }
    220       delete itCL;
    221     }
    222 
    223     if (commandClass != NULL && inputSplits.getCount() >= 2)
    224     {
    225       if (objectList != NULL)
    226       {
    227         // Checking for a Match in the Objects of classID (else take the first)
    228         tIterator<BaseObject>* itBO = objectList->getIterator();
    229         BaseObject* enumBO = itBO->firstElement();
    230         while(enumBO)
    231         {
    232           if (enumBO->getName() != NULL && !strcasecmp(enumBO->getName(), inputSplits.getString(1)))
    233           {
    234             objectPointer = enumBO;
    235             fktPos = 2;
    236             break;
    237           }
    238           enumBO = itBO->nextElement();
    239          }
    240          delete itBO;
    241 
    242       //
    243         if (objectPointer == NULL)
    244           objectPointer = objectList->firstElement();
    245       }
    246       // match a function.
    247       if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3)))
    248       {
    249         tIterator<ShellCommand>* itCMD = commandClass->commandList->getIterator();
    250         ShellCommand* enumCMD = itCMD->firstElement();
    251         while (enumCMD != NULL)
    252         {
    253           if (!strcmp(enumCMD->getName(), inputSplits.getString(fktPos)))
    254           {
    255             if (objectPointer == NULL && enumCMD->executor->getType() & Executor_Objective)
    256             {
    257               delete itCMD;
    258               return false;
    259             }
    260             if (inputSplits.getCount() > fktPos+1)
    261               enumCMD->executor->execute(objectPointer, executionString+inputSplits.getOffset(fktPos +1));
    262             else
    263               enumCMD->executor->execute(objectPointer, "");
    264             delete itCMD;
    265             return true;
    266           }
    267 
    268           enumCMD = itCMD->nextElement();
    269         }
    270         delete itCMD;
    271247      }
    272248    }
     
    306282  {
    307283    if (ShellCommandClass::aliasList == NULL)
    308       ShellCommandClass::aliasList = new tList<ShellCommandAlias>;
     284      ShellCommandClass::aliasList = new std::list<ShellCommandAlias*>;
    309285
    310286    ShellCommandAlias* aliasCMD = new ShellCommandAlias(alias, this);
    311     ShellCommandClass::aliasList->add(aliasCMD);
     287    ShellCommandClass::aliasList->push_back(aliasCMD);
    312288    this->alias = aliasCMD;
    313289  }
     
    348324  }
    349325
    350   tIterator<ShellCommandClass>* iteratorCL = ShellCommandClass::commandClassList->getIterator();
    351   ShellCommandClass* elemCL = iteratorCL->firstElement();
    352   while(elemCL != NULL)
    353   {
    354     PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize());
    355     tIterator<ShellCommand>* iterator = elemCL->commandList->getIterator();
    356     const ShellCommand* elem = iterator->firstElement();
    357     while(elem != NULL)
    358     {
    359       PRINT(0)("  command:'%s' : params:%d: ", elem->getName(), elem->executor->getParamCount());
     326  list<ShellCommandClass*>::iterator classIT;
     327  for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
     328  {
     329    PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className, (*classIT)->commandList.size());
     330
     331    list<ShellCommand*>::iterator cmdIT;
     332    for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
     333    {
     334      PRINT(0)("  command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount());
    360335      /// FIXME
    361336      /*      for (unsigned int i = 0; i< elem->paramCount; i++)
    362337       printf("%s ", ShellCommand::paramToString(elem->parameters[i]));*/
    363       if (elem->description != NULL)
    364        printf("- %s", elem->description);
     338      if ((*cmdIT)->description != NULL)
     339       printf("- %s", (*cmdIT)->description);
    365340      printf("\n");
    366341
    367       elem = iterator->nextElement();
    368     }
    369     delete iterator;
    370     elemCL = iteratorCL->nextElement();
    371   }
    372   delete iteratorCL;
     342    }
     343  }
    373344}
    374345
  • trunk/src/lib/shell/shell_command.h

    r5690 r5779  
    108108
    109109  private:
    110     const char*         aliasName;       //!< the name of the Alias
     110    const char*     aliasName;       //!< the name of the Alias
    111111    ShellCommand*   command;         //!< a pointer to the command, this alias executes.
    112112};
  • trunk/src/lib/shell/shell_command_class.cc

    r5644 r5779  
    2929using namespace std;
    3030
    31 tList<ShellCommandClass>* ShellCommandClass::commandClassList = NULL;
    32 tList<ShellCommandAlias>* ShellCommandClass::aliasList = NULL;
     31std::list<ShellCommandClass*>* ShellCommandClass::commandClassList = NULL;
     32std::list<ShellCommandAlias*>* ShellCommandClass::aliasList = NULL;
    3333
    3434/**
     
    4343  this->className = className;
    4444  this->classID = CL_NULL;
    45   this->commandList = new tList<ShellCommand>;
    46 
    47   ShellCommandClass::commandClassList->add(this);
     45
     46  ShellCommandClass::commandClassList->push_back(this);
    4847}
    4948
     
    5352ShellCommandClass::~ShellCommandClass()
    5453{
    55   tIterator<ShellCommand>* iterator = this->commandList->getIterator();
    56   ShellCommand* elem = iterator->firstElement();
    57   while(elem != NULL)
    58   {
    59     delete elem;
    60     elem = iterator->nextElement();
    61   }
    62   delete iterator;
    63   delete this->commandList;
     54  while(this->commandList.size() > 0)
     55  {
     56    delete this->commandList.front();
     57    this->commandList.pop_front();
     58  }
    6459}
    6560
     
    7065 * @returns true on success, false otherwise
    7166 */
    72 bool ShellCommandClass::getCommandListOfClass(const char* className, tList<const char>* stringList)
     67bool ShellCommandClass::getCommandListOfClass(const char* className, std::list<const char*>* stringList)
    7368{
    7469  if (stringList == NULL || className == NULL)
    7570    return false;
    7671
    77   tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator();
    78   ShellCommandClass* elem = iterator->firstElement();
    79   while(elem != NULL)
    80   {
    81     if (!strcmp (elem->getName(), className))
    82     {
    83       tIterator<ShellCommand>* itFkt = elem->commandList->getIterator();
    84       ShellCommand* command = itFkt->firstElement();
    85       while (command != NULL)
    86       {
    87         stringList->add(command->getName());
    88         command = itFkt->nextElement();
    89       }
    90       delete itFkt;
    91     }
    92 
    93     elem = iterator->nextElement();
    94   }
    95   delete iterator;
     72  list<ShellCommandClass*>::iterator elem;
     73  for(elem = ShellCommandClass::commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++)
     74  {
     75    if (!strcmp ((*elem)->getName(), className))
     76    {
     77      list<ShellCommand*>::iterator command;
     78      for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++)
     79        stringList->push_back((*command)->getName());
     80    }
     81  }
    9682  return true;
    9783}
     
    10288 * @returns true on success, false otherwise
    10389 */
    104 bool ShellCommandClass::getCommandListOfAlias(tList<const char>* stringList)
     90bool ShellCommandClass::getCommandListOfAlias(std::list<const char*>* stringList)
    10591{
    10692  if (stringList == NULL || ShellCommandClass::aliasList == NULL)
    10793    return false;
    10894
    109   tIterator<ShellCommandAlias>* iterator = ShellCommandClass::aliasList->getIterator();
    110    ShellCommandAlias* elem = iterator->firstElement();
    111    while(elem != NULL)
    112    {
    113      stringList->add(elem->getName());
    114      elem = iterator->nextElement();
    115    }
    116    delete iterator;
    117    return true;
     95  list<ShellCommandAlias*>::iterator alias;
     96  for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++)
     97    stringList->push_back((*alias)->getName());
     98  return true;
    11899}
    119100
     
    123104void ShellCommandClass::unregisterAllCommands()
    124105{
    125   if (ShellCommandClass::commandClassList != NULL)
     106  /// FIXME
     107
     108  /*  if (ShellCommandClass::commandClassList != NULL)
    126109  {
    127110    // unregister all commands
     
    153136    delete ShellCommandClass::aliasList;
    154137    ShellCommandClass::aliasList = NULL;
    155   }
     138  }*/
    156139}
    157140
     
    166149    initCommandClassList();
    167150
    168   tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator();
    169   ShellCommandClass* elem = iterator->firstElement();
    170   while(elem != NULL)
    171   {
    172     if (!strcmp(className, elem->className))
    173     {
    174       if (elem->classID == CL_NULL)
    175         elem->classID = ClassList::StringToID(className);
    176 
    177       delete iterator;
    178       return elem;
    179     }
    180     elem = iterator->nextElement();
    181   }
    182   delete iterator;
     151  list<ShellCommandClass*>::const_iterator classIT;
     152  for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
     153  {
     154    if (!strcmp(className, (*classIT)->className))
     155    {
     156      if ((*classIT)->classID == CL_NULL)
     157        (*classIT)->classID = ClassList::StringToID(className);
     158
     159      return (*classIT);
     160    }
     161  }
    183162  return NULL;
    184163}
     
    194173    initCommandClassList();
    195174
    196   tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator();
    197   ShellCommandClass* elem = iterator->firstElement();
    198   while(elem != NULL)
    199   {
    200     if (!strcmp(className, elem->className))
    201     {
    202       delete iterator;
    203       return elem;
    204     }
    205     elem = iterator->nextElement();
    206   }
    207   delete iterator;
     175  list<ShellCommandClass*>::iterator classIT;
     176  for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
     177  {
     178    if (!strcmp(className, (*classIT)->className))
     179    {
     180      return (*classIT);
     181    }
     182  }
    208183  return new ShellCommandClass(className);
    209184}
     
    216191  if (ShellCommandClass::commandClassList == NULL)
    217192  {
    218     ShellCommandClass::commandClassList = new tList<ShellCommandClass>;
     193    ShellCommandClass::commandClassList = new std::list<ShellCommandClass*>;
    219194    ShellCommand::registerCommand("debug", "ShellCommand", ExecutorStatic<ShellCommand>(ShellCommand::debug));
    220195  }
     
    231206  if (likely(ShellCommandClass::commandClassList != NULL))
    232207  {
    233     tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator();
    234     ShellCommandClass* elemCL = itCL->firstElement();
    235     while(elemCL != NULL)
    236     {
    237       if (elemCL->className && !strcasecmp(className, elemCL->className))
     208    list<ShellCommandClass*>::iterator classIT;
     209    for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
     210    {
     211      if ((*classIT)->className && !strcasecmp(className, (*classIT)->className))
    238212      {
    239         PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize());
    240         tIterator<ShellCommand>* iterator = elemCL->commandList->getIterator();
    241         const ShellCommand* elem = iterator->firstElement();
    242         while(elem != NULL)
     213        PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className, (*classIT)->commandList.size());
     214        list<ShellCommand*>::const_iterator cmdIT;
     215        for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
    243216        {
    244           PRINT(0)("  command:'%s' : params:%d: ", elem->getName(), elem->executor->getParamCount());
     217          PRINT(0)("  command:'%s' : params:%d: ", (*cmdIT)->getName(), (*cmdIT)->executor->getParamCount());
    245218          /// FIXME
    246219          /*          for (unsigned int i = 0; i< elem->paramCount; i++)
    247220            PRINT(0)("%s ", ShellCommand::paramToString(elem->parameters[i]));*/
    248           if (elem->description != NULL)
    249             PRINT(0)("- %s", elem->description);
     221          if ((*cmdIT)->description != NULL)
     222            PRINT(0)("- %s", (*cmdIT)->description);
    250223          PRINT(0)("\n");
    251           elem = iterator->nextElement();
    252224        }
    253         delete iterator;
    254 
    255         delete itCL;
    256225        return;
    257226      }
    258       elemCL = itCL->nextElement();
    259     }
    260     delete itCL;
     227    }
    261228    PRINTF(3)("Class %s not found in Command's classes\n", className);
    262229  }
  • trunk/src/lib/shell/shell_command_class.h

    r5639 r5779  
    88
    99#include "base_object.h"
     10#include <list>
    1011
    1112
     
    2627  public:
    2728    /** @returns the CommandClassList */
    28     static const tList<ShellCommandClass>* getCommandClassList() { return ShellCommandClass::commandClassList; };
    29     static bool getCommandListOfClass(const char* className, tList<const char>* stringList);
    30     static bool getCommandListOfAlias(tList<const char>* aliasList);
     29    static const std::list<ShellCommandClass*>* getCommandClassList() { return ShellCommandClass::commandClassList; };
     30    static bool getCommandListOfClass(const char* className, std::list<const char*>* stringList);
     31    static bool getCommandListOfAlias(std::list<const char*>* aliasList);
    3132
    3233    static ShellCommandClass* getCommandClass(const char* className);
     
    4344
    4445  private:
    45     const char*                      className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
    46     long                             classID;                   //!< The classID of this Class
    47     tList<ShellCommand>*             commandList;               //!< A list of Commands from this Class
    48     static tList<ShellCommandClass>* commandClassList;          //!< A list of Classes
    49     static tList<ShellCommandAlias>* aliasList;                 //!< An Alias to A Command. (only for classes with one Instance)
     46    const char*                            className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
     47    long                                   classID;                   //!< The classID of this Class
     48    std::list<ShellCommand*>               commandList;               //!< A list of Commands from this Class
     49    static std::list<ShellCommandClass*>* commandClassList;          //!< A list of Classes
     50    static std::list<ShellCommandAlias*>* aliasList;                 //!< An Alias to A Command. (only for classes with one Instance)
    5051};
    5152
  • trunk/src/lib/shell/shell_completion.cc

    r5656 r5779  
    6363bool ShellCompletion::autoComplete(ShellInput* input)
    6464{
    65   const char* completionLine;      //< the inputLine we complete.
    66 
    67   long classID;                    //< the classID retrieved from the Class.
    68   tList<BaseObject>* objectList;   //< the list of Objects stored in classID
    69   bool emptyComplete = false;      //< if the completion input is empty string. e.g ""
    70   long completeType = SHELLC_NONE; //< the Type we'd like to complete.
    71   const char* completeString;      //< the string to complete.
     65  const char* completionLine;           //< the inputLine we complete.
     66
     67  long classID;                         //< the classID retrieved from the Class.
     68  std::list<BaseObject*>* objectList;   //< the list of Objects stored in classID
     69  bool emptyComplete = false;           //< if the completion input is empty string. e.g ""
     70  long completeType = SHELLC_NONE;      //< the Type we'd like to complete.
     71  const char* completeString;           //< the string to complete.
    7272
    7373
     
    159159  if (unlikely(classBegin == NULL))
    160160    return false;
    161   const tList<const char>* clList = ClassList::getClassList();
     161  const std::list<const char*>* clList = ClassList::getClassList();
    162162  if (clList != NULL)
    163163  {
     
    180180  if (unlikely(objectBegin == NULL))
    181181    return false;
    182   const tList<BaseObject>* boList = ClassList::getList(classID);
     182  const std::list<BaseObject*>* boList = ClassList::getList(classID);
    183183  if (boList != NULL)
    184184  {
     
    203203  if (unlikely(functionBegin == NULL))
    204204    return false;
    205   tList<const char> fktList;
     205  std::list<const char*> fktList;
    206206  ShellCommandClass::getCommandListOfClass(className, &fktList);
    207207  //printf("%s\n", boList->firstElement()->getName());
     
    220220  if (unlikely(aliasBegin == NULL))
    221221    return false;
    222   tList<const char> aliasList;
     222  std::list<const char*> aliasList;
    223223  ShellCommandClass::getCommandListOfAlias(&aliasList);
    224224  //printf("%s\n", boList->firstElement()->getName());
     
    241241  if (completionList == NULL || this->input == NULL )
    242242    return false;
    243   if (completionList->getSize() == 0)
    244     return false;
    245 
    246   ShellC_Element* addElem = completionList->firstElement();
     243  if (completionList->size() == 0)
     244    return false;
     245
     246  ShellC_Element* addElem = completionList->front();
    247247  const char* addString = addElem->name;
    248248  unsigned int addLength = 0;
     
    252252  if (addString != NULL)
    253253    addLength = strlen(addString);
    254   tIterator<ShellC_Element>* charIterator = completionList->getIterator();
    255   ShellC_Element* charElem = charIterator->firstElement();
     254
    256255  SHELLC_TYPE changeType = SHELLC_NONE;
    257   while (charElem != NULL)
    258   {
    259     if (charElem->type != changeType)
     256  list<ShellC_Element*>::iterator charIT;
     257  for (charIT = completionList->begin(); charIT != completionList->end(); charIT++)
     258  {
     259    if ((*charIT)->type != changeType)
    260260    {
    261261      if (changeType != SHELLC_NONE)
    262262        PRINT(0)("\n");
    263       PRINT(0)("%s: ", ShellCompletion::typeToString(charElem->type));
    264       changeType = charElem->type;
    265     }
    266     PRINTF(0)("%s ", charElem->name);
     263      PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT)->type));
     264      changeType = (*charIT)->type;
     265    }
     266    PRINTF(0)("%s ", (*charIT)->name);
    267267    for (unsigned int i = inputLenght; i < addLength; i++)
    268       if (addString[i] != charElem->name[i])
     268      if (addString[i] != (*charIT)->name[i])
    269269      {
    270270       addLength = i;
    271271//       break;
    272272      }
    273     charElem = charIterator->nextElement();
    274   }
    275   delete charIterator;
     273  }
    276274  PRINT(0)("\n");
    277275
     
    287285     this->input->addCharacters(adder);
    288286
    289       if (completionList->getSize() == 1)
     287      if (completionList->size() == 1)
    290288      {
    291289        if ( addBack != NULL )
     
    305303 * !! The strings MUST NOT be deleted !!
    306304 */
    307 bool ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin, SHELLC_TYPE type)
     305bool ShellCompletion::addToCompleteList(const std::list<const char*>* inputList, const char* completionBegin, SHELLC_TYPE type)
    308306{
    309307  if (inputList == NULL || completionBegin == NULL)
     
    311309  unsigned int searchLength = strlen(completionBegin);
    312310
    313   tIterator<const char>* iterator = inputList->getIterator();
    314   const char* enumString = iterator->firstElement();
    315   while (enumString != NULL)
    316   {
    317     if (strlen(enumString) >= searchLength &&
    318         !strncasecmp(enumString, completionBegin, searchLength))
    319     {
    320       printf("%s\n", enumString);
     311  list<const char*>::const_iterator string;
     312  for (string = inputList->begin(); string != inputList->end(); string++)
     313  {
     314    if (strlen(*string) >= searchLength &&
     315        !strncasecmp(*string, completionBegin, searchLength))
     316    {
     317      printf("%s\n", *string);
    321318      ShellC_Element* newElem = new ShellC_Element;
    322       newElem->name = enumString;
     319      newElem->name = *string;
    323320      newElem->type = type;
    324       this->completionList->add(newElem);
    325     }
    326     enumString = iterator->nextElement();
    327   }
    328   delete iterator;
    329 
     321      this->completionList->push_back(newElem);
     322    }
     323  }
    330324  return true;
    331325}
     
    337331 * !! The strings MUST NOT be deleted !!
    338332 */
    339 bool ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin, SHELLC_TYPE type)
     333bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type)
    340334{
    341335  if (inputList == NULL || completionBegin == NULL)
     
    343337  unsigned int searchLength = strlen(completionBegin);
    344338
    345   tIterator<BaseObject>* iterator = inputList->getIterator();
    346   BaseObject* enumBO = iterator->firstElement();
    347   while (enumBO != NULL)
    348   {
    349     if (enumBO->getName() != NULL &&
    350         strlen(enumBO->getName()) >= searchLength &&
    351         !strncasecmp(enumBO->getName(), completionBegin, searchLength))
     339  list<BaseObject*>::const_iterator bo;
     340  for(bo = inputList->begin(); bo != inputList->end(); bo++)
     341  {
     342    if ((*bo)->getName() != NULL &&
     343        strlen((*bo)->getName()) >= searchLength &&
     344        !strncasecmp((*bo)->getName(), completionBegin, searchLength))
    352345    {
    353346      ShellC_Element* newElem = new ShellC_Element;
    354       newElem->name = enumBO->getName();
     347      newElem->name = (*bo)->getName();
    355348      newElem->type = type;
    356       this->completionList->add(newElem);
    357     }
    358     enumBO = iterator->nextElement();
    359   }
    360   delete iterator;
     349      this->completionList->push_back(newElem);
     350    }
     351  }
    361352
    362353  return true;
     
    372363  if (this->completionList != NULL)
    373364  {
    374     tIterator<ShellC_Element>* elemIT = this->completionList->getIterator();
    375     ShellC_Element* elem = elemIT->firstElement();
    376     while (elem != NULL)
    377     {
    378       delete elem;
    379       elem = elemIT->nextElement();
    380     }
    381     delete this->completionList;
    382   }
    383   this->completionList = new tList<ShellC_Element>;
     365    while (this->completionList->size() > 0)
     366    {
     367      delete this->completionList->front();
     368      this->completionList->pop_front();
     369    }
     370  }
    384371}
    385372
  • trunk/src/lib/shell/shell_completion.h

    r5371 r5779  
    99#ifndef _SHELL_COMPLETION_H
    1010#define _SHELL_COMPLETION_H
     11
     12#include <list>
    1113
    1214// FORWARD DECLARATION
     
    5153  bool generalComplete(const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL);
    5254
    53   bool addToCompleteList(const tList<const char>* inputList, const char* completionBegin, SHELLC_TYPE type);
    54   bool addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin, SHELLC_TYPE type);
     55  bool addToCompleteList(const std::list<const char*>* inputList, const char* completionBegin, SHELLC_TYPE type);
     56  bool addToCompleteList(const std::list<BaseObject*>* inputList, const char* completionBegin, SHELLC_TYPE type);
    5557  void emptyCompletionList();
    5658
     
    5860
    5961 private:
    60    tList<ShellC_Element>*   completionList;          //!< A list of completions, that are io.
    61    ShellInput*              input;                   //!< the input this completion works on.
     62   std::list<ShellC_Element*>*  completionList;          //!< A list of completions, that are io.
     63   ShellInput*                  input;                   //!< the input this completion works on.
    6264};
    6365
  • trunk/src/lib/sound/sound_engine.cc

    r5473 r5779  
    6363  if(this->sourceList != NULL)
    6464  {
    65     tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    66     SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    67     while (enumSource)
    68     {
    69         delete enumSource;
    70         enumSource = (SoundSource*)sourceIterator->nextElement();
    71     }
    72     delete sourceIterator;
     65    while (this->sourceList->size() > 0)
     66      delete dynamic_cast<SoundSource*>(this->sourceList->front());
    7367  }
    7468
     
    7670  if (this->bufferList != NULL)
    7771  {
    78     tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    79     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    80     while (enumBuffer)
    81     {
    82       ResourceManager::getInstance()->unload(enumBuffer);
    83       enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
    84     }
    85     delete bufferIterator;
     72    while(this->bufferList->size() > 0)
     73      ResourceManager::getInstance()->unload(dynamic_cast<SoundBuffer*>(this->bufferList->front()));
    8674  }
    8775
     
    148136{
    149137  // look if there are any sources that have the buffer still loaded
    150   tIterator<BaseObject>* sourceIterator = this->sourceList->getIterator();
    151   SoundSource* enumSource = (SoundSource*)sourceIterator->firstElement();
    152   while (enumSource)
    153     {
    154       if (buffer == enumSource->getBuffer())
    155         delete enumSource;
    156       enumSource = (SoundSource*)sourceIterator->nextElement();
     138  if (this->sourceList != NULL)
     139  {
     140    list<BaseObject*>::iterator source;
     141    for (source = this->sourceList->begin(); source != this->sourceList->end(); source++)
     142    {
     143      if (buffer == static_cast<SoundSource*>(*source)->getBuffer())
     144        delete (*source);
    157145    }
    158   delete sourceIterator;
     146  }
    159147}
    160148
     
    195183  if (likely(this->sourceList != NULL))
    196184  {
    197     tIterator<BaseObject>* iterator = this->sourceList->getIterator();
    198     SoundSource* enumSource = (SoundSource*)iterator->firstElement();
    199     while (enumSource)
    200     {
    201       if (likely(enumSource->getNode() != NULL))
     185    list<BaseObject*>::iterator sourceIT;
     186    SoundSource* source;
     187    for (sourceIT = this->sourceList->begin(); sourceIT != this->sourceList->end(); sourceIT++)
     188    {
     189      source = static_cast<SoundSource*>(*sourceIT);
     190      if (likely(source->getNode() != NULL))
    202191      {
    203         alSource3f(enumSource->getID(), AL_POSITION,
    204                    enumSource->getNode()->getAbsCoor().x,
    205                    enumSource->getNode()->getAbsCoor().y,
    206                    enumSource->getNode()->getAbsCoor().z);
    207         alSource3f(enumSource->getID(), AL_VELOCITY,
    208                    enumSource->getNode()->getVelocity().x,
    209                    enumSource->getNode()->getVelocity().y,
    210                    enumSource->getNode()->getVelocity().z);
     192        alSource3f(source->getID(), AL_POSITION,
     193                   source->getNode()->getAbsCoor().x,
     194                   source->getNode()->getAbsCoor().y,
     195                   source->getNode()->getAbsCoor().z);
     196        alSource3f(source->getID(), AL_VELOCITY,
     197                   source->getNode()->getVelocity().x,
     198                   source->getNode()->getVelocity().y,
     199                   source->getNode()->getVelocity().z);
    211200      }
    212       enumSource = (SoundSource*)iterator->nextElement();
    213201    }
    214     delete iterator;
    215202  }
    216203}
     
    221208void SoundEngine::flushUnusedBuffers()
    222209{
    223   if(this->sourceList && this->bufferList)
     210/*  if(this->sourceList && this->bufferList)
    224211  {
    225212    tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
     
    241228    }
    242229    delete bufferIterator;
    243   }
     230}*/ /// FIXME
    244231}
    245232
     
    252239  if (this->bufferList)
    253240  {
    254     tIterator<BaseObject>* bufferIterator = this->bufferList->getIterator();
    255     SoundBuffer* enumBuffer = (SoundBuffer*)bufferIterator->firstElement();
    256     while (enumBuffer)
    257     {
    258       ResourceManager::getInstance()->unload(enumBuffer, RP_LEVEL);
    259       enumBuffer = (SoundBuffer*)bufferIterator->nextElement();
    260     }
    261     delete bufferIterator;
     241    while (this->bufferList->size() > 0)
     242      ResourceManager::getInstance()->unload(static_cast<SoundBuffer*>(this->bufferList->front()), RP_LEVEL);
    262243  }
    263244}
     
    270251  if (this->sourceList)
    271252  {
    272     tIterator<BaseObject>* Iterator = this->sourceList->getIterator();
    273     SoundSource* enumSource = (SoundSource*)Iterator->firstElement();
    274     while (enumSource)
    275     {
    276       delete enumSource;
    277       enumSource = (SoundSource*)Iterator->nextElement();
    278     }
    279     delete Iterator;
     253    while(this->sourceList->size() > 0)
     254      delete this->sourceList->front();
    280255  }
    281256}
  • trunk/src/lib/sound/sound_engine.h

    r5405 r5779  
    1313#include "sound_source.h"
    1414
     15#include <list>
     16
    1517#define SOUND_DOPPLER_FACTOR       0.001          //!< A factor for the audible doppler effect
    1618#define SOUND_DOPPLER_VELOCITY     5000000        //!< A factor for the TravelSpeed of sound
     
    1820// FORWARD DECLARATION
    1921class PNode;
    20 template<class T> class tList;
    2122class IniParser;
    2223
     
    7071    float                    effectsVolume;            //!< the maximum volume of sound-effects in % (0f,1f]
    7172    PNode*                   listener;                 //!< The listener of the Scene
    72     tList<BaseObject>*       bufferList;               //!< A list of buffers
    73     tList<BaseObject>*       sourceList;               //!< A list for all the sources in the scene.
     73    std::list<BaseObject*>*  bufferList;               //!< A list of buffers
     74    std::list<BaseObject*>*  sourceList;               //!< A list for all the sources in the scene.
    7475
    7576};
  • trunk/src/world_entities/weapons/aim.cc

    r5750 r5779  
    8181
    8282  this->text = new Text();
     83  this->text->setLayer(this->getLayer());
    8384  this->text->setParent2D(this);
    8485  this->text->setRelCoor2D(10, -50);
  • trunk/src/world_entities/weapons/guided_missile.cc

    r5772 r5779  
    6666
    6767  /* this is normaly done by World.cc by deleting the ParticleEngine */
    68   if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     68  if (GuidedMissile::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)
    6969  {
    7070    if (ClassList::exists(GuidedMissile::trailParticles, CL_PARTICLE_SYSTEM))
     
    7272    GuidedMissile::trailParticles = NULL;
    7373  }
    74   if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     74  if (GuidedMissile::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)
    7575  {
    7676    if (ClassList::exists(GuidedMissile::explosionParticles, CL_PARTICLE_SYSTEM))
  • trunk/src/world_entities/weapons/laser.cc

    r5769 r5779  
    6363
    6464  /* this is normaly done by World.cc by deleting the ParticleEngine */
    65   if (Laser::explosionParticles != NULL && ClassList::getList(CL_LASER)->getSize() <= 1)
     65  if (Laser::explosionParticles != NULL && ClassList::getList(CL_LASER)->size() <= 1)
    6666  {
    6767    //if (ClassList::exists(Laser::explosionParticles, CL_PARTICLE_SYSTEM))
  • trunk/src/world_entities/weapons/rocket.cc

    r5769 r5779  
    6262
    6363  /* this is normaly done by World.cc by deleting the ParticleEngine */
    64   if (Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     64  if (Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)
    6565  {
    6666    if (ClassList::exists(Rocket::trailParticles, CL_PARTICLE_SYSTEM))
     
    6868    Rocket::trailParticles = NULL;
    6969  }
    70   if (Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     70  if (Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)
    7171  {
    7272    if (ClassList::exists(Rocket::explosionParticles, CL_PARTICLE_SYSTEM))
  • trunk/src/world_entities/weapons/test_bullet.cc

    r5769 r5779  
    6262
    6363  /* this is normaly done by World.cc by deleting the ParticleEngine */
    64   if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     64  if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)
    6565  {
    6666    if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM))
     
    6868    TestBullet::trailParticles = NULL;
    6969  }
    70   if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     70  if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->size() <= 1)
    7171  {
    7272    if (ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM))
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5750 r5779  
    347347   if (this->targetIterator == NULL)
    348348   {
    349      tList<BaseObject>* npcList = ClassList::getList(CL_NPC);
     349     std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC);
    350350     if (npcList != NULL)
    351351     {
    352        this->targetIterator = npcList->getIterator();
    353        this->targetIterator->firstElement();
     352       this->targetIterator = npcList->begin();
    354353     }
    355354     else
     
    357356   }
    358357
    359    PNode* retNode = dynamic_cast<PNode*>(targetIterator->nextElement());
    360    if (retNode == NULL && this->targetIterator->getList()->getSize() > 0)
    361      retNode =  dynamic_cast<PNode*>(targetIterator->firstElement());
     358   ///FIXME
     359//   this->targetIterator++;
     360   PNode* retNode = dynamic_cast<PNode*>((*targetIterator));
     361//   if (retNode == NULL && this->targetIterator->getList()->getSize() > 0)
     362//     retNode =  dynamic_cast<PNode*>(targetIterator->firstElement());
    362363
    363364   return retNode;
     
    372373PNode* WeaponManager::getDistanceTarget(const PNode* carrier, float distance)
    373374{
    374   tList<BaseObject>* npcList = ClassList::getList(CL_NPC);
     375  std::list<BaseObject*>* npcList = ClassList::getList(CL_NPC);
    375376  if (npcList != NULL)
    376377  {
    377     tIterator<BaseObject>* npcIT = npcList->getIterator();
    378     PNode* tmpNPC = dynamic_cast<PNode*>(npcIT->firstElement());
    379     while (tmpNPC != NULL)
    380     {
    381       if ((carrier->getAbsCoor() - tmpNPC->getAbsCoor()).len() < distance)
    382       {
    383         delete npcIT;
    384         return tmpNPC;
    385       }
    386       tmpNPC = dynamic_cast<PNode*>(npcIT->nextElement());
    387     }
    388     delete npcIT;
     378    list<BaseObject*>::iterator node;
     379    for (node= npcList->begin(); node != npcList->end(); node++)
     380      if ((carrier->getAbsCoor() - dynamic_cast<PNode*>(*node)->getAbsCoor()).len() < distance)
     381        return dynamic_cast<PNode*>(*node);
    389382  }
    390383  return this->getFixedTarget();
    391 
    392384}
    393385
  • trunk/src/world_entities/weapons/weapon_manager.h

    r5750 r5779  
    110110    tAnimation<Crosshair>*  crossHairSizeAnim;                        //!< An animation for the crosshair (scaling)
    111111
    112     tIterator<BaseObject>*  targetIterator;                           //!< An iterator for traversion lists of enemies.
     112    std::list<BaseObject*>::iterator  targetIterator;                           //!< An iterator for traversion lists of enemies.
    113113};
Note: See TracChangeset for help on using the changeset viewer.