Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/shell/shell_command.cc


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

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

    r9406 r9869  
    2020
    2121#include "compiler.h"
     22#include "helper_functions.h"
    2223#include "debug.h"
    23 #include "class_list.h"
    2424
    2525#include "key_names.h"
     
    2727namespace OrxShell
    2828{
     29  ObjectListDefinition(ShellCommand);
    2930  SHELL_COMMAND(debug, ShellCommandClass, help);
    3031
     
    3637   * @param paramCount the count of parameters this command takes
    3738   */
    38   ShellCommand::ShellCommand(const std::string& commandName, const std::string& className, Executor* executor)
    39   {
    40     this->setClassID(CL_SHELL_COMMAND, "ShellCommand");
     39  ShellCommand::ShellCommand(const std::string& commandName, const std::string& className, Executor<const SubString>* executor)
     40  {
     41    this->registerObject(this, ShellCommand::_objectList);
    4142    PRINTF(4)("create shellcommand '%s' for class '%s'\n", commandName.c_str(), className.c_str());
    4243    this->setName(commandName);
     
    4445    // copy the executor:
    4546    this->executor = executor;
    46     this->executor->setName(commandName);
    4747
    4848    for (unsigned int i = 0; i < this->executor->getParamCount(); i++)
     
    7575   * @brief registers a new ShellCommand
    7676   */
    77   ShellCommand* ShellCommand::registerCommand(const std::string& commandName, const std::string& className, Executor* executor)
     77  ShellCommand* ShellCommand::registerCommand(const std::string& commandName, const std::string& className, Executor<const SubString>* executor)
    7878  {
    7979    if (ShellCommand::exists(commandName, className))
     
    9494  void ShellCommand::unregisterCommand(const std::string& commandName, const std::string& className)
    9595  {
    96 
    9796    ShellCommandClass* cmdClass = ShellCommandClass::acquireCommandClass(className);
    9897    if (cmdClass != NULL)
    9998    {
    10099      CmdList::iterator cmd;
    101       for (cmd = cmdClass->commandList.begin(); cmd != cmdClass->commandList.end(); cmd++)
     100      for (cmd = cmdClass->_commandList.begin(); cmd != cmdClass->_commandList.end(); cmd++)
    102101        if (commandName == (*cmd)->getName())
    103102        {
     
    119118
    120119    CmdList::const_iterator elem;
    121     for (unsigned int i = 0; i < cmdClass->commandList.size(); i++)
    122     {
    123       if (commandName == cmdClass->commandList[i]->getName())
    124         return (cmdClass->commandList[i]);
     120    for (unsigned int i = 0; i < cmdClass->_commandList.size(); i++)
     121    {
     122      if (commandName == cmdClass->_commandList[i]->getName())
     123        return (cmdClass->_commandList[i]);
    125124    }
    126125    return NULL;
     
    242241      return false;
    243242
    244     const std::list<BaseObject*>* objectList = ClassList::getList(cmd->shellClass->getName());
     243    const ObjectListBase* const objectList = ObjectListBase::getObjectList(cmd->shellClass->getName());
    245244    if (objectList != NULL)
    246245    {
    247       std::list<BaseObject*>::const_iterator bo;
     246      ObjectListBase::base_list list;
     247      objectList->getBaseObjectList(&list);
     248      ObjectListBase::base_iterator it;
    248249
    249250      // No Description given (only for speedup)
    250251      if (objectDescriptor.empty())
    251252      {
    252         for (bo = objectList->begin(); bo != objectList->end(); bo++)
    253           boList->push_back(*bo);
     253        for (it = list.begin(); it != list.end(); it++)
     254          boList->push_back(*it);
    254255      }
    255256      // some description
    256257      else
    257258      {
    258         for (bo = objectList->begin(); bo != objectList->end(); bo++)
    259           if (!nocaseCmp(objectDescriptor, (*bo)->getName(), objectDescriptor.size()))
    260             boList->push_back(*bo);
     259        for (it = list.begin(); it != list.end(); it++)
     260          if (!nocaseCmp(objectDescriptor, (*it)->getName(), objectDescriptor.size()))
     261            boList->push_back(*it);
    261262      }
    262263    }
     
    299300    if (sc != NULL)
    300301    {
    301       for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo)
    302       {
    303         PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName());
    304         (*sc->executor)((*bo), inputSplits.subSet(paramBegin));
    305       }
     302
     303      if(sc->executor->getType() == Executor<const SubString>::FunctionStatic )
     304      {
     305        PRINT(0)("Static Command '%s' of Class '%s' with parameters\n", sc->getCName(), sc->shellClass->getCName());
     306        (*sc->executor)(NULL, inputSplits.subSet(paramBegin));
     307      }
     308      else
     309        for(std::vector<BaseObject*>::const_iterator bo = boList.begin(); bo != boList.end(); ++bo)
     310        {
     311          PRINT(0)("Command '%s' on '%s::%s'\n", sc->getCName(), (*bo)->getClassCName(), (*bo)->getCName());
     312          (*sc->executor)((*bo), inputSplits.subSet(paramBegin));
     313        }
    306314      return true;
    307315    }
     
    376384    else
    377385    {
    378 //       if(this->completors[parameter] == NULL)
    379 //       delete this->completors[parameter];
    380 //       this->completors[parameter] = completorPlugin.clone();
     386      //       if(this->completors[parameter] == NULL)
     387      //       delete this->completors[parameter];
     388      //       this->completors[parameter] = completorPlugin.clone();
    381389    }
    382390    return this;
Note: See TracChangeset for help on using the changeset viewer.