Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9697 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Aug 25, 2006, 12:03:08 AM (18 years ago)
Author:
bensch
Message:

adapted shell

Location:
branches/new_class_id/src/lib/shell
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/shell/shell_command.cc

    r9692 r9697  
    241241      return false;
    242242
    243     const std::list<BaseObject*>* objectList = ClassList::getList(cmd->shellClass->getName());
     243    const NewObjectListBase* const objectList = NewObjectListBase::getObjectList(cmd->shellClass->getName());
    244244    if (objectList != NULL)
    245245    {
    246       std::list<BaseObject*>::const_iterator bo;
     246      NewObjectListBase::base_iterator bo(objectList->base_begin());
    247247
    248248      // No Description given (only for speedup)
    249249      if (objectDescriptor.empty())
    250250      {
    251         for (bo = objectList->begin(); bo != objectList->end(); bo++)
     251        for (; bo != objectList->base_end(); bo++)
    252252          boList->push_back(*bo);
    253253      }
     
    255255      else
    256256      {
    257         for (bo = objectList->begin(); bo != objectList->end(); bo++)
     257        for (bo = objectList->base_begin(); bo != objectList->base_end(); bo++)
    258258          if (!nocaseCmp(objectDescriptor, (*bo)->getName(), objectDescriptor.size()))
    259259            boList->push_back(*bo);
  • branches/new_class_id/src/lib/shell/shell_command_class.cc

    r9692 r9697  
    2929  NewObjectListDefinition(ShellCommandClass);
    3030
    31   CmdClassList* ShellCommandClass::commandClassList = NULL;
     31  CmdClassList* ShellCommandClass::_commandClassList = NULL;
    3232
    3333  /**
     
    4141    this->setName(className);
    4242
    43     this->classID = CL_NULL;
    44 
    45     if (ShellCommandClass::commandClassList == NULL)
    46       ShellCommandClass::commandClassList = new CmdClassList;
    47     ShellCommandClass::commandClassList->push_back(this);
     43    if (ShellCommandClass::_commandClassList == NULL)
     44      ShellCommandClass::_commandClassList = new CmdClassList;
     45    ShellCommandClass::_commandClassList->push_back(this);
    4846  }
    4947
     
    5351  ShellCommandClass::~ShellCommandClass()
    5452  {
    55     while(!this->commandList.empty())
    56       delete this->commandList.back();
    57 
    58     if (ShellCommandClass::commandClassList != NULL)
    59     {
    60       CmdClassList::iterator delClass = std::find(ShellCommandClass::commandClassList->begin(), ShellCommandClass::commandClassList->end(), this);
    61       if (delClass != ShellCommandClass::commandClassList->end())
    62         ShellCommandClass::commandClassList->erase(delClass);
     53    while(!this->_commandList.empty())
     54      delete this->_commandList.back();
     55
     56    if (ShellCommandClass::_commandClassList != NULL)
     57    {
     58      CmdClassList::iterator delClass = std::find(ShellCommandClass::_commandClassList->begin(), ShellCommandClass::_commandClassList->end(), this);
     59      if (delClass != ShellCommandClass::_commandClassList->end())
     60        ShellCommandClass::_commandClassList->erase(delClass);
    6361    }
    6462  }
     
    6967  void ShellCommandClass::registerCommand(ShellCommand* command)
    7068  {
    71     this->commandList.push_back(command);
     69    this->_commandList.push_back(command);
    7270  }
    7371
     
    7876  void ShellCommandClass::unregisterCommand(ShellCommand* command)
    7977  {
    80     CmdList::iterator delC = std::find(this->commandList.begin(), this->commandList.end(), command);
    81     if (delC != this->commandList.end())
    82       this->commandList.erase(delC);
     78    CmdList::iterator delC = std::find(this->_commandList.begin(), this->_commandList.end(), command);
     79    if (delC != this->_commandList.end())
     80      this->_commandList.erase(delC);
    8381  }
    8482
     
    9088    // unregister all commands and Classes
    9189    CmdClassList::iterator classIT;
    92     if (ShellCommandClass::commandClassList == NULL)
     90    if (ShellCommandClass::_commandClassList == NULL)
    9391      return;
    9492
    95     while (!ShellCommandClass::commandClassList->empty())
    96       delete ShellCommandClass::commandClassList->back();
    97     delete ShellCommandClass::commandClassList;
    98     ShellCommandClass::commandClassList = NULL;
     93    while (!ShellCommandClass::_commandClassList->empty())
     94      delete ShellCommandClass::_commandClassList->back();
     95    delete ShellCommandClass::_commandClassList;
     96    ShellCommandClass::_commandClassList = NULL;
    9997  }
    10098
     
    108106  bool ShellCommandClass::getCommandListOfClass(const std::string& className, std::list<std::string>& stringList)
    109107  {
    110     if (ShellCommandClass::commandClassList == NULL)
     108    if (ShellCommandClass::_commandClassList == NULL)
    111109      return false;
    112110
    113111
    114112    CmdClassList::const_iterator elem;
    115     for(elem = ShellCommandClass::commandClassList->begin(); elem != ShellCommandClass::commandClassList->end(); elem++)
     113    for(elem = ShellCommandClass::_commandClassList->begin(); elem != ShellCommandClass::_commandClassList->end(); elem++)
    116114    {
    117115      if (className == (*elem)->getName())
    118116      {
    119117        CmdList::iterator command;
    120         for(command = (*elem)->commandList.begin(); command != (*elem)->commandList.end(); command++)
     118        for(command = (*elem)->_commandList.begin(); command != (*elem)->_commandList.end(); command++)
    121119          stringList.push_back((*command)->getName());
    122120        return true;
     
    134132  ShellCommandClass* ShellCommandClass::getCommandClass(const std::string& className)
    135133  {
    136     if (ShellCommandClass::commandClassList == NULL)
     134    if (ShellCommandClass::_commandClassList == NULL)
    137135      return false;
    138136
    139137
    140138    CmdClassList::const_iterator classIT;
    141     for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
    142       if (className == (*classIT)->className)
     139    for (classIT = ShellCommandClass::_commandClassList->begin(); classIT != ShellCommandClass::_commandClassList->end(); classIT++)
     140      if (className == (*classIT)->_className)
    143141        return (*classIT);
    144142    return NULL;
     
    153151  {
    154152    return (ShellCommandClass::getCommandClass(className) != NULL);
    155   }
    156 
    157   ClassID ShellCommandClass::getClassID()
    158   {
    159     if (this->classID == CL_NULL)
    160       this->classID = ClassList::StringToID(this->className);
    161     return this->classID;
    162153  }
    163154
     
    182173  void ShellCommandClass::help(const std::string& className)
    183174  {
    184     if (ShellCommandClass::commandClassList == NULL)
     175    if (ShellCommandClass::_commandClassList == NULL)
    185176    {
    186177      PRINT(0)("No Commands Registered\n");
     
    188179    }
    189180    if (className.empty())
    190       PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::commandClassList->size());
     181      PRINT(0)("===== Displaying %d registered Classes:\n", ShellCommandClass::_commandClassList->size());
    191182
    192183
    193184    CmdClassList::iterator classIT;
    194     for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++)
    195     {
    196       if (className.empty() || className == (*classIT)->className)
     185    for (classIT = ShellCommandClass::_commandClassList->begin(); classIT != ShellCommandClass::_commandClassList->end(); classIT++)
     186    {
     187      if (className.empty() || className == (*classIT)->_className)
    197188      {
    198         PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size());
     189        PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->_className.c_str(), (*classIT)->_commandList.size());
    199190        CmdList::const_iterator cmdIT;
    200         for (cmdIT = (*classIT)->commandList.begin(); cmdIT != (*classIT)->commandList.end(); cmdIT++)
     191        for (cmdIT = (*classIT)->_commandList.begin(); cmdIT != (*classIT)->_commandList.end(); cmdIT++)
    201192        {
    202193          PRINT(0)("  command:'%s' : params:%d: ", (*cmdIT)->getCName(), (*cmdIT)->executor->getParamCount());
  • branches/new_class_id/src/lib/shell/shell_command_class.h

    r9692 r9697  
    5454  private:
    5555    const std::string                      _className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
    56     NewClassID                             _classID;                   //!< The classID of this Class
    5756    CmdList                                _commandList;               //!< A list of Commands from this Class
    5857
  • branches/new_class_id/src/lib/shell/shell_completion.cc

    r9406 r9697  
    2323
    2424#include "substring.h"
    25 #include "class_list.h"
    2625#include "debug.h"
    2726
     
    5150  bool ShellCompletion::autoComplete(std::string& input)
    5251  {
    53     long classID = CL_NULL;                          //< the classID retrieved from the Class.
    54     const std::list<BaseObject*>* objectList = NULL; //< the list of Objects stored in classID's ClassList
     52    NewClassID classID;
     53    const NewObjectListBase* objectList = NULL;      //< the list of Objects stored in classID's ClassList
    5554    bool emptyComplete = false;                      //< if the completion input is empty string. e.g ""
    5655    long completeType = NullCompletion;              //< the Type we'd like to complete.
     
    8584             (!emptyComplete && inputSplits.size() == 2))
    8685    {
    87       classID = ClassList::StringToID(inputSplits.getString(0));
    88       objectList = ClassList::getList((ClassID)classID);
    89       if (classID != CL_NULL)
     86      objectList = NewObjectListBase::getObjectList(inputSplits[0]);
     87      if (objectList != NULL)
     88        classID = objectList->identity();
     89      if (classID != NullClass::classID())
    9090        completeType |= ObjectCompletion;
    9191      completeType |= FunctionCompletion;
     
    9595             (!emptyComplete && inputSplits.size() == 3))
    9696    {
    97       if (ClassList::exists(inputSplits[0], inputSplits[1]))
     97      if (NewObjectListBase::getBaseObject(inputSplits[0], inputSplits[1]))
    9898        completeType |= FunctionCompletion;
    9999    }
     
    113113
    114114    if (completeType & ClassCompletion)
    115       this->objectComplete(completeString, CL_SHELL_COMMAND_CLASS);
     115      this->objectComplete(completeString, &ShellCommandClass::objectList());
    116116    if (completeType & ObjectCompletion)
    117       this->objectComplete(completeString, classID);
     117      this->objectComplete(completeString, objectList);
    118118    if (completeType & FunctionCompletion)
    119119      this->commandComplete(completeString, inputSplits[0]);
     
    133133   * @return true on success, false otherwise
    134134   */
    135   bool ShellCompletion::objectComplete(const std::string& objectBegin, long classID)
    136   {
    137     const std::list<BaseObject*>* boList = ClassList::getList((ClassID)classID);
    138     if (boList != NULL)
    139     {
    140       CompletionType type = ObjectCompletion;
    141       if (classID == CL_SHELL_COMMAND_CLASS)
    142         type = ClassCompletion;
    143       if (!this->addToCompleteList(*boList, objectBegin, type))
    144         return false;
    145     }
    146     else
    147       return false;
     135  bool ShellCompletion::objectComplete(const std::string& objectBegin, const NewObjectListBase* objectList)
     136  {
     137    assert (objectList != NULL);
     138
     139    CompletionType type = ObjectCompletion;
     140    if (objectList == &ShellCommandClass::objectList())
     141      type = ClassCompletion;
     142
     143    /// FIXME
     144//     if (!this->addToCompleteList(*boList, objectBegin, type))
     145//       return false;
     146
    148147    return true;
    149148  }
     
    321320    switch (type)
    322321    {
    323         default:// SHELLC_NONE
    324         return typeNames[0];
    325         case  ClassCompletion:
    326         return typeNames[1];
    327         case ObjectCompletion:
    328         return typeNames[2];
    329         case FunctionCompletion:
    330         return typeNames[3];
    331         case AliasCompletion:
    332         return typeNames[4];
    333         case ParamCompletion:
    334         return typeNames[5];
     322      default:// SHELLC_NONE
     323      return typeNames[0];
     324      case  ClassCompletion:
     325      return typeNames[1];
     326      case ObjectCompletion:
     327      return typeNames[2];
     328      case FunctionCompletion:
     329      return typeNames[3];
     330      case AliasCompletion:
     331      return typeNames[4];
     332      case ParamCompletion:
     333      return typeNames[5];
    335334    }
    336335  }
  • branches/new_class_id/src/lib/shell/shell_completion.h

    r7415 r9697  
    1616// FORWARD DECLARATION
    1717class BaseObject;
     18class NewObjectListBase;
    1819
    1920namespace OrxShell
     
    5354
    5455    private:
    55       bool objectComplete(const std::string& objectBegin, long classID);
     56      bool objectComplete(const std::string& objectBegin, const NewObjectListBase* const objectList);
    5657      bool commandComplete(const std::string& commandBegin, const std::string& className);
    5758      bool aliasComplete(const std::string& aliasBegin);
  • branches/new_class_id/src/lib/shell/shell_completion_plugin.cc

    r8330 r9697  
    2222
    2323#include "substring.h"
    24 #include "class_list.h"
    2524#include "loading/resource_manager.h"
    2625
Note: See TracChangeset for help on using the changeset viewer.