Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5635 in orxonox.OLD for trunk/src/lib/util/executor


Ignore:
Timestamp:
Nov 18, 2005, 6:20:23 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more about the executor.

Location:
trunk/src/lib/util/executor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor.cc

    r5633 r5635  
    6868
    6969/**
    70  * lets a command be described
    71  * @param description the description of the Given command
    72  */
    73 Executor* Executor::describe(const char* description)
    74 {
    75   if (this == NULL)
    76     return NULL;
    77  else
    78  {
    79    this->description = description;
    80    return this;
    81  }
    82 }
    83 
    84 /**
    8570 * sets default Values of the Commands
    8671 * @param count how many default Values to set.
     
    9378Executor* Executor::defaultValues(unsigned int count, ...)
    9479{
     80  va_list values;
     81  va_start(values, count);
     82
     83  this->defaultValues(count, values);
     84}
     85
     86Executor* Executor::defaultValues(unsigned int count, va_list values)
     87{
    9588  if (this == NULL)
    9689    return NULL;
     
    10093    count = this->paramCount;
    10194
    102   va_list defaultList;
    103   va_start(defaultList, count);
    10495
    10596  for (unsigned int i = 0; i < count; i++)
     
    10899    {
    109100      case MT_BOOL:
    110         this->defaultValue[i].setInt(va_arg(defaultList, int));
     101        this->defaultValue[i].setInt(va_arg(values, int));
    111102        break;
    112103      case MT_CHAR:
    113         this->defaultValue[i].setChar((char)va_arg(defaultList, int));
     104        this->defaultValue[i].setChar((char)va_arg(values, int));
    114105        break;
    115106      case MT_STRING:
    116         this->defaultValue[i].setString(va_arg(defaultList, char*));
     107        this->defaultValue[i].setString(va_arg(values, char*));
    117108        break;
    118109      case MT_INT:
    119         this->defaultValue[i].setInt(va_arg(defaultList, int));
     110        this->defaultValue[i].setInt(va_arg(values, int));
    120111        break;
    121112/*      case MT_UINT:
    122         this->defaultValue[i].setInt((int)va_arg(defaultList, unsigned int));
     113        this->defaultValue[i].setInt((int)va_arg(values, unsigned int));
    123114        break;*/
    124115      case MT_FLOAT:
    125         this->defaultValue[i].setFloat(va_arg(defaultList, double));
     116        this->defaultValue[i].setFloat(va_arg(values, double));
    126117        break;
    127118/*      case MT_LONG:
    128         this->defaultValue[i].setInt((int) va_arg(defaultList, long));
     119        this->defaultValue[i].setInt((int) va_arg(values, long));
    129120        break;*/
    130121      default:
  • trunk/src/lib/util/executor/executor.h

    r5633 r5635  
    1212#include "multi_type.h"
    1313#include "substring.h"
    14 #include "functor_list.h"
     14#include "functor_list.h" //< MUST BE INCLUDED HERE AT LEAST ONCE.
    1515
    1616#include <stdarg.h>
     
    3232{
    3333  public:
    34     static bool execute (const char* executionString);
    35 
    36     Executor* describe(const char* description);
    3734    Executor* defaultValues(unsigned int count, ...);
     35    Executor* defaultValues(unsigned int count, va_list values);
    3836
    3937    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    4038    virtual void execute (BaseObject* object, const char* parameters) = 0;
    41 
    4239
    4340    static void debug();
     
    5653
    5754  private:
    58     const char*                      description;                          //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");
    5955};
    6056
Note: See TracChangeset for help on using the changeset viewer.