Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7399 in orxonox.OLD


Ignore:
Timestamp:
Apr 27, 2006, 4:33:17 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: register unregister much better

Location:
trunk/src/lib/shell
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_command.cc

    r7398 r7399  
    5151    this->shellClass = ShellCommandClass::getCommandClass(className);
    5252    assert (this->shellClass != NULL);
    53     this->shellClass->commandList.push_back(this);
     53    this->shellClass->registerCommand(this);
    5454  }
    5555
     
    5959  ShellCommand::~ShellCommand()
    6060  {
     61    this->shellClass->unregisterCommand(this);
    6162    if (this->alias != NULL)
    6263      delete this->alias;
     
    8384  void ShellCommand::unregisterCommand(const std::string& commandName, const std::string& className)
    8485  {
    85     /// FIXME
    86     /*  if (ShellCommandClass::commandClassList == NULL)
    87         ShellCommandClass::initCommandClassList();
    88 
    89      const ShellCommandClass* checkClass = ShellCommandClass::isRegistered(className);
    90 
    91      if (checkClass != NULL)
    92       {
    93         std::list<ShellCommand*>::iterator elem;
    94         for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
    95         {
    96           if (!strcmp(commandName, (*elem)->getName()))
    97           {
    98             delete (*elem);
    99             checkClass->commandList.remove(*elem);
    100             break;
    101           }
    102         }
    103 
    104         if (checkClass->commandList->size() == 0)
    105         {
    106           ShellCommandClass::commandClassList->remove(checkClass);
    107           delete checkClass;
    108         }
    109       }*/
     86
     87    ShellCommandClass* cmdClass = ShellCommandClass::getCommandClass(className);
     88    if (cmdClass != NULL)
     89    {
     90      std::vector<ShellCommand*>::iterator cmd;
     91      for (cmd = cmdClass->commandList.begin(); cmd < cmdClass->commandList.end(); cmd++)
     92      {
     93        if (commandName == (*cmd)->getName())
     94        {
     95          delete (*cmd);
     96        }
     97      }
     98    }
    11099  }
    111100
  • trunk/src/lib/shell/shell_command_class.cc

    r7394 r7399  
    4949  {
    5050    while(!this->commandList.empty())
    51     {
    5251      delete this->commandList.back();
    53       this->commandList.pop_back();
    54     }
    5552  }
    5653
Note: See TracChangeset for help on using the changeset viewer.