Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Sep 18, 2005, 3:24:06 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Shell is now able to execute Aliases (without any Parameters thought, but it works)

File:
1 edited

Legend:

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

    r5197 r5198  
    233233
    234234//  this->classID = classID;
    235   ShellCommandClass::getCommandClass(className)->commandList->add(this); //ClassList::IDToString(classID);
    236 
     235  this->shellClass = ShellCommandClass::getCommandClass(className); //ClassList::IDToString(classID);
     236  if (this->shellClass != NULL)
     237    this->shellClass->commandList->add(this);
    237238  // handling parameters, and storing them:
    238239  if (paramCount > FUNCTOR_MAX_ARGUMENTS)
     
    379380bool ShellCommandBase::execute(const char* executionString)
    380381{
    381 //   if (ShellCommandBase::commandList == NULL)
    382 //     return false;
    383 //
     382  if (ShellCommandClass::commandClassList == NULL)
     383    return false;
     384
     385
     386  long classID;                    //< the classID retrieved from the Class.
     387  tList<BaseObject>* objectList;   //< the list of Objects stored in classID
     388  BaseObject* objectPointer;       //< a pointer to th Object to Execute the command on
     389  bool emptyComplete = false;      //< if the completion input is empty string. e.g ""
     390//  long completeType = SHELLC_NONE; //< the Type we'd like to complete.
     391  SubString inputSplits(executionString, true);
     392
     393  printf("!!!!%s!!!\n", executionString);
     394
     395  if (inputSplits.getCount() == 0)
     396    return false;
     397  // CHECK FOR ALIAS
     398  if (inputSplits.getCount() >= 1)
     399  {
     400    if (ShellCommandClass::aliasList != NULL)
     401    {
     402      tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator();
     403      ShellCommandAlias* elemAL = itAL->firstElement();
     404      while(elemAL != NULL)
     405      {
     406        if (elemAL->getName() != NULL && elemAL->getCommand() != NULL && !strcmp(elemAL->getName(), inputSplits.getString(0)))
     407        {
     408          printf("%s\n", elemAL->getCommand()->shellClass->getName());
     409          elemAL->getCommand()->executeCommand(ClassList::getList(elemAL->getCommand()->shellClass->getName())->firstElement(), "");
     410          return true;
     411        }
     412        elemAL = itAL->nextElement();
     413      }
     414      delete itAL;
     415    }
     416  }
     417
     418
     419   //
    384420//   tIterator<ShellCommandBase>* iterator = ShellCommandBase::commandList->getIterator();
    385421//   ShellCommandBase* elem = iterator->firstElement();
Note: See TracChangeset for help on using the changeset viewer.