Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 28, 2006, 11:11:57 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: ShellCommand with new Improved and more general Functionality

File:
1 edited

Legend:

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

    r7415 r7417  
    141141   * @returns: The ShellCommand if found.
    142142   */
    143   const ShellCommand* const ShellCommand::getCommandFromInput(const std::string& inputLine, unsigned int& paramBegin)
     143  const ShellCommand* const ShellCommand::getCommandFromInput(const std::string& inputLine, unsigned int& paramBegin, std::vector<BaseObject*>* boList)
    144144  {
    145145    ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin);
     
    152152   * @returns: The ShellCommand if found.
    153153   */
    154   const ShellCommand* const ShellCommand::getCommandFromInput(const SubString& strings, unsigned int& paramBegin)
     154  const ShellCommand* const ShellCommand::getCommandFromInput(const SubString& strings, unsigned int& paramBegin, std::vector<BaseObject*>* boList)
    155155  {
    156156    // no input, no Command.
     
    172172    }
    173173
     174    // CHECK FOR COMMAND_CLASS
    174175    const ShellCommandClass* cmdClass = ShellCommandClass::getCommandClass(strings[0]);
    175176    if (cmdClass != NULL)
    176177    {
    177178      const ShellCommand* retCmd;
     179      // Function/Command right after Class
    178180      if (strings.size() >= 1)
    179181      {
    180182        retCmd = ShellCommand::getCommand(strings[1], cmdClass);
    181         paramBegin = 2;
    182       }
     183        if (retCmd != NULL)
     184        {
     185          paramBegin = 2;
     186          return retCmd;
     187        }
     188      }
     189      // Function/Command after Class and 'Object'
    183190      if (retCmd == NULL && strings.size() >= 2)
    184191      {
    185192        retCmd = ShellCommand::getCommand(strings[2], cmdClass);
     193        if (retCmd != NULL)
     194        {
    186195          paramBegin = 3;
     196          return retCmd;
     197        }
    187198      }
    188199      if (retCmd != NULL) // check for the paramBegin.
    189200        return retCmd;
    190201    }
     202    // Nothing usefull found at all.
    191203    paramBegin = 0;
    192204    return NULL;
    193205  }
    194206
     207  bool ShellCommand::fillObjectList(const std::string& objectDescriptor, ShellCommand* cmd, std::vector<BaseObject*>* boList)
     208  {
     209    assert (cmd != NULL && cmd->shellClass != NULL && boList != NULL);
     210
     211    const std::list<BaseObject*>* objectList = ClassList::getList(cmd->shellClass->getName());
     212    if (objectList != NULL)
     213    {
     214      std::list<BaseObject*>::const_iterator bo;
     215
     216      // No Description given (only for speedup)
     217      if (objectDescriptor.empty())
     218      {
     219        for (bo = objectList->begin(); bo != objectList->end(); bo++)
     220          boList->push_back(*bo);
     221      }
     222      // some description
     223      else
     224      {
     225        for (bo = objectList->begin(); bo != objectList->end(); bo++)
     226          if ((*bo)->getName() != NULL && nocaseCmp(objectDescriptor, (*bo)->getName(), objectDescriptor.size()))
     227            boList->push_back(*bo);
     228      }
     229    }
     230  }
    195231
    196232  /**
Note: See TracChangeset for help on using the changeset viewer.