Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7743 in orxonox.OLD for trunk/src/lib/shell


Ignore:
Timestamp:
May 20, 2006, 4:03:16 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: All the ShellCommands get Registered correctly again

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

Legend:

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

    r7742 r7743  
    2828namespace OrxShell
    2929{
    30   CmdClassList ShellCommandClass::commandClassList;
     30  CmdClassList* ShellCommandClass::commandClassList = NULL;
    3131
    3232  /**
     
    4242    this->classID = CL_NULL;
    4343
    44     printf("::: %d\n", commandClassList.size());
    45     ShellCommandClass::commandClassList.push_back(this);
    46     printf("::: %d\n", commandClassList.size());
     44    if (ShellCommandClass::commandClassList == NULL)
     45      ShellCommandClass::commandClassList = new CmdClassList;
     46    ShellCommandClass::commandClassList->push_back(this);
    4747  }
    4848
     
    5454    while(!this->commandList.empty())
    5555      delete this->commandList.back();
    56     CmdClassList::iterator delClass = std::find(ShellCommandClass::commandClassList.begin(), ShellCommandClass::commandClassList.end(), this);
    57     if (delClass != ShellCommandClass::commandClassList.end())
    58       ShellCommandClass::commandClassList.erase(delClass);
     56
     57    if (ShellCommandClass::commandClassList != NULL)
     58    {
     59      CmdClassList::iterator delClass = std::find(ShellCommandClass::commandClassList->begin(), ShellCommandClass::commandClassList->end(), this);
     60      if (delClass != ShellCommandClass::commandClassList->end())
     61        ShellCommandClass::commandClassList->erase(delClass);
     62    }
    5963  }
    6064
     
    6468  void ShellCommandClass::registerCommand(ShellCommand* command)
    6569  {
    66     printf("::::::::::: ADDED COMMAND:: '%s'\n", command->getName());
    6770    this->commandList.push_back(command);
    68     this->help();
    6971  }
    7072
     
    8789    // unregister all commands and Classes
    8890    CmdClassList::iterator classIT;
    89 
    90     while (!ShellCommandClass::commandClassList.empty())
    91       delete ShellCommandClass::commandClassList.back();
     91    if (ShellCommandClass::commandClassList == NULL)
     92      return;
     93
     94    while (!ShellCommandClass::commandClassList->empty())
     95      delete ShellCommandClass::commandClassList->back();
     96    delete ShellCommandClass::commandClassList;
     97    ShellCommandClass::commandClassList = NULL;
    9298  }
    9399
     
    101107  bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList)
    102108  {
     109    if (ShellCommandClass::commandClassList == NULL)
     110      return false;
     111
     112
    103113    CmdClassList::const_iterator elem;
    104     for(elem = ShellCommandClass::commandClassList.begin(); elem != ShellCommandClass::commandClassList.end(); elem++)
     114    for(elem = ShellCommandClass::commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++)
    105115    {
    106116      if (className == (*elem)->getName())
     
    123133  ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)
    124134  {
     135    if (ShellCommandClass::commandClassList == NULL)
     136      return false;
     137
     138
    125139    CmdClassList::const_iterator classIT;
    126     for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
     140    for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
    127141      if (className == (*classIT)->className)
    128142        return (*classIT);
     
    167181  void ShellCommandClass::help(const std::string& className)
    168182  {
     183    if (ShellCommandClass::commandClassList == NULL)
     184    {
     185      PRINT(0)("No Commands Registered\n");
     186      return;
     187    }
    169188    if (className.empty())
    170       PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList.size());
     189      PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList->size());
    171190
    172191
    173192    CmdClassList::iterator classIT;
    174     for (classIT = ShellCommandClass::commandClassList.begin(); classIT != ShellCommandClass::commandClassList.end(); classIT++)
     193    for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
    175194    {
    176195      if (className.empty() || className == (*classIT)->className)
  • trunk/src/lib/shell/shell_command_class.h

    r7742 r7743  
    2727  public:
    2828    /** @returns the CommandClassList */
    29     static const CmdClassList& getCommandClassList() { return ShellCommandClass::commandClassList; };
     29    static const CmdClassList& getCommandClassList() { return *ShellCommandClass::commandClassList; };
    3030
    3131    static bool getCommandListOfClass(const std::string& className, std::list<std::string>& stringList);
     
    5454    CmdList                                commandList;               //!< A list of Commands from this Class
    5555
    56     static CmdClassList                    commandClassList;          //!< A list of Classes
     56    static CmdClassList*                   commandClassList;          //!< A list of Classes
    5757  };
    58 
    5958}
    6059
Note: See TracChangeset for help on using the changeset viewer.