Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 8, 2005, 11:07:21 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: executing static commands work

Location:
trunk/src/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/class_list.cc

    r5194 r5329  
    2424#include <string.h>
    2525#include <math.h>
     26#include "shell_command.h"
    2627
    2728using namespace std;
    2829
     30SHELL_COMMAND_STATIC(debug, ClassList, ClassList::debug);
    2931
    3032/**
  • trunk/src/lib/shell/shell.cc

    r5256 r5329  
    6565  // Element2D and generals
    6666  this->setAbsCoor2D(3, -400);
    67   this->textSize = 15;
     67  this->textSize = 20;
    6868  this->lineSpacing = 0;
    6969  this->bActive = false;
  • trunk/src/lib/shell/shell_command.cc

    r5328 r5329  
    422422  if (ShellCommandClass::commandClassList == NULL)
    423423    return false;
    424 
    425424
    426425  long classID = CL_NULL;                 //< the classID retrieved from the Class.
     
    482481    }
    483482
    484     if (classID != CL_NULL && inputSplits.getCount() >= 2 && objectList != NULL)
    485     {
    486       // Checking for a Match in the Objects of classID (else take the first)
    487       tIterator<BaseObject>* itBO = objectList->getIterator();
    488       BaseObject* enumBO = itBO->firstElement();
    489       while(enumBO)
     483    if (commandClass != NULL && inputSplits.getCount() >= 2)
     484    {
     485      if (objectList != NULL)
    490486      {
    491         if (enumBO->getName() != NULL && !strcasecmp(enumBO->getName(), inputSplits.getString(1)))
     487        // Checking for a Match in the Objects of classID (else take the first)
     488        tIterator<BaseObject>* itBO = objectList->getIterator();
     489        BaseObject* enumBO = itBO->firstElement();
     490        while(enumBO)
    492491        {
    493           objectPointer = enumBO;
    494           fktPos++;
    495           break;
    496         }
    497         enumBO = itBO->nextElement();
     492          if (enumBO->getName() != NULL && !strcasecmp(enumBO->getName(), inputSplits.getString(1)))
     493          {
     494            objectPointer = enumBO;
     495            fktPos = 2;
     496            break;
     497          }
     498          enumBO = itBO->nextElement();
     499         }
     500         delete itBO;
     501
     502      //
     503        if (objectPointer == NULL)
     504          objectPointer = objectList->firstElement();
    498505      }
    499       delete itBO;
    500 
    501       //
    502       if (objectPointer == NULL)
    503         objectPointer = objectList->firstElement();
    504 
     506      printf("test\n");
    505507      // match a function.
    506       if (commandClass != NULL && objectPointer != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3)))
     508      if (commandClass != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3)))
    507509      {
    508510        tIterator<ShellCommandBase>* itCMD = commandClass->commandList->getIterator();
     
    512514          if (!strcmp(enumCMD->getName(), inputSplits.getString(fktPos)))
    513515          {
     516            if (objectPointer == NULL && enumCMD->functorType == ShellCommand_Objective)
     517            {
     518              delete itCMD;
     519              return false;
     520            }
    514521            if (inputSplits.getCount() > fktPos+1)
    515522              enumCMD->executeCommand(objectPointer, executionString+inputSplits.getOffset(fktPos +1));
     
    622629
    623630  return this;
    624 }
    625 
    626 
    627 /**
    628  * see ShellCommandBase::debug()
    629  */
    630 void ShellCommandBase::debugDyn()
    631 {
    632   this->debug();
    633631}
    634632
  • trunk/src/lib/shell/shell_command.h

    r5328 r5329  
    3939#define SHELL_COMMAND(command, class, function) \
    4040        ShellCommandBase* shell_command_##class##_##command = ShellCommand<class>::registerCommand(#command, #class, &class::function)
     41/**
     42 * an easy to use Macro to create a Command
     43 * @param command the name of the command (without "" around the string)
     44 * @param class the name of the class to apply this command to (without the "" around the string)
     45 * @param function the function to call
     46 *
     47 * MEANING:
     48 *  ShellCommandBase* someUniqueVarName =
     49 *       ShellCommand<ClassName>::registerCommand("commandNameInShell", "ClassName", &ClassName::FunctionToCall);
     50 *
     51 * In the Shell you would call this Command using:
     52 * $ ClassName [ObjectName] commandNameInShell [parameters]
     53 */
     54#define SHELL_COMMAND_STATIC(command, class, function) \
     55                         ShellCommandBase* shell_command_##class##_##command = ShellCommandStatic<class>::registerCommand(#command, #class, function)
    4156
    4257
     
    110125    static bool isRegistered(const char* commandName, const char* className, unsigned int paramCount, ...);
    111126    static const char* paramToString(long parameter);
    112 
    113     void debugDyn();
    114127
    115128  private:
  • trunk/src/lib/shell/shell_completion.cc

    r5254 r5329  
    107107    completeType |= SHELLC_CLASS;
    108108    completeType |= SHELLC_ALIAS;
    109 
    110109  }
    111110  else if (inputSplits.getCount() == 1 && emptyComplete == false)
  • trunk/src/lib/util/helper_functions.cc

    r5270 r5329  
    2929bool isBool(const char* BOOL, bool defaultValue)
    3030{
     31  if (BOOL == NULL)
     32    return defaultValue;
    3133  if(!strcmp(BOOL, "1") || !strcmp( BOOL,"true") || !strcmp(BOOL,"TRUE"))
    3234    return true;
     
    4042int isInt(const char* INT, int defaultValue)
    4143{
     44  if (INT == NULL)
     45    return defaultValue;
    4246  char* endPtr = NULL;
     47
    4348  int result = strtol(INT, &endPtr, 10);
    4449
     
    5156float isFloat(const char* FLOAT, float defaultValue)
    5257{
     58  if (FLOAT == NULL)
     59    return defaultValue;
    5360  char* endPtr = NULL;
    5461  double result = strtod(FLOAT, &endPtr);
Note: See TracChangeset for help on using the changeset viewer.