Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 19, 2006, 2:39:05 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: fixed a ShellCommand-bug

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

Legend:

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

    r7330 r7340  
    148148
    149149/**
    150  * deactiveates the Shell.
     150 * @brief deactiveates the Shell.
    151151 */
    152152void Shell::deactivate()
     
    175175
    176176/**
    177  * sets the File to load the fonts from
     177 * @brief sets the File to load the fonts from
    178178 * @param fontFile the file to load the font from
    179179 *
     
    192192
    193193/**
    194  * sets the size of the text and spacing
     194 * @brief sets the size of the text and spacing
    195195 * @param textSize the size of the Text in Pixels
    196196 * @param lineSpacing the size of the Spacing between two lines in pixels
  • trunk/src/lib/shell/shell_command.cc

    r7331 r7340  
    4444  this->executor->setName(commandName);
    4545
    46 //  this->classID = classID;
     46  //  this->classID = classID;
    4747  this->shellClass = ShellCommandClass::getCommandClass(className); //ClassList::IDToString(classID);
    4848  if (this->shellClass != NULL)
     
    8383{
    8484  /// FIXME
    85 /*  if (ShellCommandClass::commandClassList == NULL)
    86     ShellCommandClass::initCommandClassList();
    87 
    88  const ShellCommandClass* checkClass = ShellCommandClass::isRegistered(className);
    89 
    90  if (checkClass != NULL)
    91   {
    92     std::list<ShellCommand*>::iterator elem;
    93     for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
    94     {
    95       if (!strcmp(commandName, (*elem)->getName()))
    96       {
    97         delete (*elem);
    98         checkClass->commandList.remove(*elem);
    99         break;
    100       }
    101     }
    102 
    103     if (checkClass->commandList->size() == 0)
    104     {
    105       ShellCommandClass::commandClassList->remove(checkClass);
    106       delete checkClass;
    107     }
    108   }*/
     85  /*  if (ShellCommandClass::commandClassList == NULL)
     86      ShellCommandClass::initCommandClassList();
     87
     88   const ShellCommandClass* checkClass = ShellCommandClass::isRegistered(className);
     89
     90   if (checkClass != NULL)
     91    {
     92      std::list<ShellCommand*>::iterator elem;
     93      for (elem = checkClass->commandList.begin(); elem != checkClass->commandList.end(); elem++)
     94      {
     95        if (!strcmp(commandName, (*elem)->getName()))
     96        {
     97          delete (*elem);
     98          checkClass->commandList.remove(*elem);
     99          break;
     100        }
     101      }
     102
     103      if (checkClass->commandList->size() == 0)
     104      {
     105        ShellCommandClass::commandClassList->remove(checkClass);
     106        delete checkClass;
     107      }
     108    }*/
    109109}
    110110
     
    138138      }
    139139    }
    140    return false;
     140    return false;
    141141  }
    142142  else
     
    161161  BaseObject* objectPointer = NULL;            //< a pointer to th Object to Execute the command on
    162162  bool emptyComplete = false;                  //< if the completion input is empty string. e.g ""
    163   unsigned int fktPos = 1;                     //< the position of the function (needed for finding it)
    164 //  long completeType = SHELLC_NONE;           //< the Type we'd like to complete.
    165   SubString inputSplits(executionString, " \t\n,");
    166 
    167   if (inputSplits.size() == 0)
    168     return false;
     163  //  long completeType = SHELLC_NONE;           //< the Type we'd like to complete.
     164  SubString inputSplits(executionString, SubString::WhiteSpacesWithComma);
     165
     166
     167  // if we do not have any input return
     168  if (inputSplits.empty())
     169    return false;
     170
     171  // if we only have one input (!MUST BE AN ALIAS)
    169172  if (inputSplits.size() >= 1)
    170173  {
     
    181184          if (objectList != NULL)
    182185          {
    183             if (inputSplits.size() > 1)
    184             {
    185 
    186               (*(*alias)->getCommand()->executor)(objectList->front(), inputSplits.getSubSet(1).join()); /// TODO CHECK IF OK
    187             }
    188             else
    189               (*(*alias)->getCommand()->executor)(objectList->front(), "");
    190            return true;
     186            (*(*alias)->getCommand()->executor)(objectList->front(), inputSplits.getSubSet(1).join()); /// TODO CHECK IF OK
     187            return true;
    191188          }
    192         }
    193       }
    194     }
     189          /// TODO CHECK FOR STATIC functions.
     190        }
     191      }
     192    }
     193
    195194    // looking for a Matching Class
    196195    if (likely(ShellCommandClass::commandClassList != NULL))
     
    199198      for (commandClassIT = ShellCommandClass::commandClassList->begin(); commandClassIT != ShellCommandClass::commandClassList->end(); commandClassIT++)
    200199      {
    201         if ((*commandClassIT)->getName() && inputSplits.getString(0) == (*commandClassIT)->getName())
     200        if ((*commandClassIT)->getName() && inputSplits[0] == (*commandClassIT)->getName())
    202201        {
    203202          //elemCL->getName();
     
    210209    }
    211210
     211    // Second Agument. (either Object, or Function)
    212212    if (commandClass != NULL && inputSplits.size() >= 2)
    213213    {
     214      int fktPos = 1; // The position of the Function (either at pos 1, or 2)
     215      // If we have an ObjectList.
    214216      if (objectList != NULL)
    215217      {
     
    218220        for (object = objectList->begin(); object != objectList->end(); object++)
    219221        {
    220           if ((*object)->getName() != NULL && inputSplits.getString(1) == (*object)->getName() )
     222          if ((*object)->getName() != NULL && inputSplits[1] == (*object)->getName())
    221223          {
    222224            objectPointer = (*object);
     
    224226            break;
    225227          }
    226          }
    227 
    228       //
     228        }
     229
     230        // if we did not find an Object with matching name, take the first.
    229231        if (objectPointer == NULL)
    230232          objectPointer = objectList->front();
    231233      }
     234
    232235      // match a function.
    233236      if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.size() >= 3)))
     
    236239        for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++)
    237240        {
    238           if (inputSplits.getString(fktPos) == (*cmdIT)->getName())
     241          if (inputSplits[fktPos] == (*cmdIT)->getName())
    239242          {
    240243            if (objectPointer == NULL && (*cmdIT)->executor->getType() & Executor_Objective)
    241244              return false;
    242             if (inputSplits.size() > fktPos+1)
    243               (*(*cmdIT)->executor)(objectPointer, inputSplits.getSubSet(2).join()); /// TODO CHECK IF OK
    244245            else
    245               (*(*cmdIT)->executor)(objectPointer, "");
    246             return true;
     246            {
     247              (*(*cmdIT)->executor)(objectPointer, inputSplits.getSubSet(fktPos+1).join()); /// TODO CHECK IF OK
     248              return true;
     249            }
    247250          }
    248251        }
     
    250253    }
    251254  }
     255  return false;
    252256}
    253257
     
    260264  if (this == NULL)
    261265    return NULL;
    262  else
    263  {
    264    this->description = description;
    265    return this;
    266  }
     266  else
     267  {
     268    this->description = description;
     269    return this;
     270  }
    267271}
    268272
     
    302306 */
    303307ShellCommand* ShellCommand::defaultValues(const MultiType& value0, const MultiType& value1,
    304                                           const MultiType& value2, const MultiType& value3,
    305                                           const MultiType& value4)
     308    const MultiType& value2, const MultiType& value3,
     309    const MultiType& value4)
    306310{
    307311  if (this == NULL || this->executor == NULL)
Note: See TracChangeset for help on using the changeset viewer.