Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 27, 2006, 9:09:55 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: exist get functions

File:
1 edited

Legend:

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

    r7407 r7408  
    5151
    5252    //  this->classID = classID;
    53     this->shellClass = ShellCommandClass::getCommandClass(className);
     53    this->shellClass = ShellCommandClass::acquireCommandClass(className);
    5454    assert (this->shellClass != NULL);
    5555    this->shellClass->registerCommand(this);
     
    9292  {
    9393
    94     ShellCommandClass* cmdClass = ShellCommandClass::getCommandClass(className);
     94    ShellCommandClass* cmdClass = ShellCommandClass::acquireCommandClass(className);
    9595    if (cmdClass != NULL)
    9696    {
     
    100100          delete (*cmd);
    101101    }
     102  }
     103
     104
     105  /**
     106   * @brief gets a command if it has already been registered.
     107   * @param commandName the name of the Command
     108   * @param className the name of the Class the command should apply to.
     109   * @returns The Registered Command, or NULL if it does not exist.
     110   */
     111  const ShellCommand* const ShellCommand::getCommand(const std::string& commandName, const std::string& className)
     112  {
     113    const ShellCommandClass* checkClass = ShellCommandClass::getCommandClass(className);
     114    if (likely(checkClass != NULL))
     115    {
     116      std::vector<ShellCommand*>::const_iterator elem;
     117      for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
     118      {
     119        if (commandName == (*elem)->getName())
     120        {
     121          PRINTF(2)("Command '%s::%s' already registered\n", className.c_str(), commandName.c_str());
     122          return (*elem);
     123        }
     124      }
     125      return NULL;
     126    }
     127    else
     128      return NULL;
    102129  }
    103130
     
    113140  bool ShellCommand::exists(const std::string& commandName, const std::string& className)
    114141  {
    115     const ShellCommandClass* checkClass = ShellCommandClass::exists(className);
    116     if (likely(checkClass != NULL))
    117     {
    118       std::vector<ShellCommand*>::const_iterator elem;
    119       for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
    120       {
    121         if (commandName == (*elem)->getName())
    122         {
    123           PRINTF(2)("Command '%s::%s' already registered\n", className.c_str(), commandName.c_str());
    124           return true;
    125         }
    126       }
    127       return false;
    128     }
    129     else
    130       return false;
     142    return (ShellCommand::getCommand(commandName, className) != NULL);
    131143  }
    132144
Note: See TracChangeset for help on using the changeset viewer.