Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/shell/shell_completion.cc


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

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

    r9406 r9869  
    2222#include "shell_command.h"
    2323
    24 #include "substring.h"
    25 #include "class_list.h"
     24#include "helper_functions.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    ClassID classID;
     53    const ObjectListBase* 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 = ObjectListBase::getObjectList(inputSplits[0]);
     87      if (objectList != NULL)
     88        classID = objectList->identity();
     89      if (classID != NullClass::staticClassID())
    9090        completeType |= ObjectCompletion;
    9191      completeType |= FunctionCompletion;
     
    9595             (!emptyComplete && inputSplits.size() == 3))
    9696    {
    97       if (ClassList::exists(inputSplits[0], inputSplits[1]))
     97      if (ObjectListBase::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 ObjectListBase* objectList)
     136  {
     137    assert (objectList != NULL);
     138
     139    CompletionType type = ObjectCompletion;
     140    if (objectList == &ShellCommandClass::objectList())
     141      type = ClassCompletion;
     142
     143    ObjectListBase::base_list list;
     144    objectList->getBaseObjectList(&list);
     145
     146    if (!this->addToCompleteList(list, objectBegin, type))
     147     return false;
     148
    148149    return true;
    149150  }
     
    321322    switch (type)
    322323    {
    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];
     324      default:// SHELLC_NONE
     325      return typeNames[0];
     326      case  ClassCompletion:
     327      return typeNames[1];
     328      case ObjectCompletion:
     329      return typeNames[2];
     330      case FunctionCompletion:
     331      return typeNames[3];
     332      case AliasCompletion:
     333      return typeNames[4];
     334      case ParamCompletion:
     335      return typeNames[5];
    335336    }
    336337  }
Note: See TracChangeset for help on using the changeset viewer.