Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7408 in orxonox.OLD for trunk/src/lib


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

orxonox/trunk: exist get functions

Location:
trunk/src/lib/shell
Files:
5 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
  • trunk/src/lib/shell/shell_command.h

    r7407 r7408  
    7272    static ShellCommand* registerCommand(const std::string& commandName, const std::string& className, const Executor& executor);
    7373    static void unregisterCommand(const std::string& commandName, const std::string& className);
     74    static const ShellCommand* const getCommand(const std::string& commandName, const std::string& className);
    7475    static bool exists(const std::string& commandName, const std::string& className);
    7576
  • trunk/src/lib/shell/shell_command_class.cc

    r7407 r7408  
    110110   * @returns the CommandClass if found, NULL otherwise
    111111   */
    112   const ShellCommandClass* ShellCommandClass::exists(const std::string& className)
     112  const ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)
    113113  {
    114114    std::vector<ShellCommandClass*>::const_iterator classIT;
     
    127127
    128128  /**
     129   * @brief checks if a Class is already registered to the Commands' class-stack
     130   * @param className the Name of the Class to check for
     131   * @returns the CommandClass if found, NULL otherwise
     132   */
     133/*  bool ShellCommandClass::exists(const std::string& className)
     134  {
     135
     136  }*/
     137
     138  /**
    129139   * @brief searches for a CommandClass
    130140   * @param className the name of the CommandClass
    131141   * @returns the CommandClass if found, or a new CommandClass if not
    132142   */
    133   ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)
     143  ShellCommandClass* ShellCommandClass::acquireCommandClass(const std::string& className)
    134144  {
    135145    std::vector<ShellCommandClass*>::iterator classIT;
  • trunk/src/lib/shell/shell_command_class.h

    r7403 r7408  
    2828    static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList);
    2929
    30     static ShellCommandClass* getCommandClass(const std::string& className);
    3130    static void unregisterAllCommands();
    32     static const ShellCommandClass* exists(const std::string& className);
     31    static const ShellCommandClass* getCommandClass(const std::string& className);
     32    static bool exists(const std::string& className);
    3333
    3434    static void help (const std::string& className);
     
    3636  private:
    3737    ShellCommandClass(const std::string& className);
     38    static ShellCommandClass* acquireCommandClass(const std::string& className);
    3839    virtual ~ShellCommandClass();
    3940
  • trunk/src/lib/shell/shell_completion.cc

    r7406 r7408  
    5656    long completeType = NullCompletion;              //< the Type we'd like to complete.
    5757    std::string completeString = "";                 //< the string to complete.
     58    unsigned int parameterBegin = 0;                 //< The SubString-entry, the Parameters begin.
    5859
    5960
     
    9697        completeType |= FunctionCompletion;
    9798    }
     99
     100    // Looking for ParameterCompletions.
    98101
    99102    if (completeType & ClassCompletion)
     
    105108    if (completeType & AliasCompletion)
    106109      this->aliasComplete(completeString);
     110
     111    if (completeType == NullCompletion)
     112    {
     113      printf("Completing a Parameter\n");
     114//      ShellCommand::
     115    }
    107116
    108117
Note: See TracChangeset for help on using the changeset viewer.