Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 26, 2006, 11:19:29 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: fixed a notNULL definition

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

Legend:

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

    r7374 r7388  
    2424
    2525#include "key_names.h"
    26 #include <stdarg.h>
    27 #include <stdio.h>
    28 #include <string.h>
    2926
    3027namespace OrxShell
     
    4441    this->executor = executor.clone();
    4542    this->executor->setName(commandName);
     43    this->alias = NULL;
    4644
    4745    //  this->classID = classID;
    48     this->shellClass = ShellCommandClass::getCommandClass(className); //ClassList::IDToString(classID);
     46    this->shellClass = ShellCommandClass::getCommandClass(className);
    4947    if (this->shellClass != NULL)
    5048      this->shellClass->commandList.push_back(this);
     
    130128    if (checkClass != NULL)
    131129    {
    132       std::list<ShellCommand*>::const_iterator elem;
     130      std::vector<ShellCommand*>::const_iterator elem;
    133131      for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
    134132      {
     
    237235        if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.size() >= 3)))
    238236        {
    239           std::list<ShellCommand*>::iterator cmdIT;
     237          std::vector<ShellCommand*>::iterator cmdIT;
    240238          for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++)
    241239          {
     
    334332      PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size());
    335333
    336       std::list<ShellCommand*>::iterator cmdIT;
     334      std::vector<ShellCommand*>::iterator cmdIT;
    337335      for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
    338336      {
  • trunk/src/lib/shell/shell_command.h

    r7386 r7388  
    8888    ShellCommandAlias*               alias;                                //!< An Alias for the Class.
    8989
    90     std::string                      description;                          //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");
     90    std::string                      description;                          //!< A description for this commnand. (initially ""). Assigned with (create)->describe("blablabla");
    9191    Executor*                        executor;                             //!< The Executor, that really executes the Function.
    92 
    9392  };
    9493
  • trunk/src/lib/shell/shell_command_class.cc

    r7386 r7388  
    2424#include "compiler.h"
    2525
    26 #include <stdio.h>
    27 #include <string.h>
    28 
    2926namespace OrxShell
    3027{
     
    5350  ShellCommandClass::~ShellCommandClass()
    5451  {
    55     while(this->commandList.size() > 0)
    56     {
    57       delete this->commandList.front();
    58       this->commandList.pop_front();
     52    while(!this->commandList.empty())
     53    {
     54      delete this->commandList.back();
     55      this->commandList.pop_back();
    5956    }
    6057  }
     
    7370      if (className == (*elem)->getName())
    7471      {
    75         std::list<ShellCommand*>::iterator command;
     72        std::vector<ShellCommand*>::iterator command;
    7673        for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++)
    7774          stringList.push_back((*command)->getName());
     
    194191        {
    195192          PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size());
    196           std::list<ShellCommand*>::const_iterator cmdIT;
     193          std::vector<ShellCommand*>::const_iterator cmdIT;
    197194          for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
    198195          {
     
    216213  }
    217214
     215  void ShellCommandClass::registerCommand(ShellCommand* command)
     216  {
     217    this->commandList.push_back(command);
     218  }
     219
     220
     221  void ShellCommandClass::unregisterCommand(ShellCommand* command)
     222  {
     223    std::vector<ShellCommand*>::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command);
     224    this->commandList.erase(delC);
     225  }
     226
     227
     228
    218229}
     230
     231
     232
     233
  • trunk/src/lib/shell/shell_command_class.h

    r7386 r7388  
    88
    99#include "base_object.h"
    10 #include <list>
     10#include <vector>
    1111
    1212
     
    4141    static void initCommandClassList();
    4242
     43    void registerCommand(ShellCommand* command);
     44    void unregisterCommand(ShellCommand* command);
     45
    4346  private:
    4447    const std::string                      className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
    4548    long                                   classID;                   //!< The classID of this Class
    46     std::list<ShellCommand*>               commandList;               //!< A list of Commands from this Class
     49    std::vector<ShellCommand*>             commandList;               //!< A list of Commands from this Class
    4750    static std::list<ShellCommandClass*>*  commandClassList;          //!< A list of Classes
    48     static std::list<ShellCommandAlias*>*  aliasList;                 //!< An Alias to A Command. (only for classes with one Instance)
     51    static std::list<ShellCommandAlias*>*  aliasList;                 //!< A list of Aliases to A Commands.
    4952  };
    5053
  • trunk/src/lib/shell/shell_completion.cc

    r7386 r7388  
    1818#include "shell_completion.h"
    1919#include "shell_command_class.h"
     20#include "shell_completion_plugin.h"
    2021
    2122#include "shell_command.h"
     
    5051  bool ShellCompletion::autoComplete(std::string& input)
    5152  {
    52     const char* completionLine;           //< the inputLine we complete.
    53 
    54     long classID;                         //< the classID retrieved from the Class.
     53    long classID;                               //< the classID retrieved from the Class.
    5554    const std::list<BaseObject*>* objectList;   //< the list of Objects stored in classID
    56     bool emptyComplete = false;           //< if the completion input is empty string. e.g ""
    57     long completeType = NullCompletion;   //< the Type we'd like to complete.
    58     std::string completeString;           //< the string to complete.
     55    bool emptyComplete = false;                 //< if the completion input is empty string. e.g ""
     56    long completeType = NullCompletion;         //< the Type we'd like to complete.
     57    std::string completeString;                 //< the string to complete.
    5958
    6059
     
    119118
    120119    this->generalComplete(input, completeString);
    121     return true;
    122   }
    123 
    124   /**
    125    * @brief autocompletes a className
    126    * @param classBegin the Beginning of a String to autoComplete
    127    * @return true on success, false otherwise
    128    */
    129   bool ShellCompletion::classComplete(const std::string& classBegin)
    130   {
    131     const std::list<std::string>* clList = ClassList::getClassNames();
    132     if (clList != NULL)
    133     {
    134       if (!this->addToCompleteList(*clList, classBegin, ClassCompletion))
    135         return false;
    136     }
    137     else
    138       return false;
    139120    return true;
    140121  }
  • trunk/src/lib/shell/shell_completion.h

    r7374 r7388  
    4545    // Functions to produce the Complete Lists.
    4646    bool autoComplete(std::string& input);
    47     bool classComplete(const std::string& classBegin);
    4847    //  long classMatch(const char* input, unsigned int* length);
    4948    bool objectComplete(const std::string& objectBegin, long classID);
     
    6059    bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
    6160    bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
     61
    6262    void clearCompletionList();
    63 
    6463
    6564    // Helpers.
  • trunk/src/lib/shell/shell_completion_plugin.cc

    r7387 r7388  
    2727namespace OrxShell
    2828{
    29 
    30 
    3129  void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin)
    3230  {
Note: See TracChangeset for help on using the changeset viewer.