Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5153 in orxonox.OLD


Ignore:
Timestamp:
Aug 27, 2005, 1:48:59 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: up to 5 arguments are now able to be parsed

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/functor_list.h

    r5145 r5153  
    104104
    105105#ifdef FUNCTOR_LIST
    106   FUNCTOR_LIST(0)()
     106  FUNCTOR_LIST(0)();
    107107  //! makes functions with one string
    108108  FUNCTOR_LIST(1)(l_STRING);
  • trunk/src/util/shell_command.h

    r5152 r5153  
    3333#define   l_STRING_DEFGRAB(i)       this->defaultStrings[i]
    3434
    35 // COMMAND REGISTRATION
     35//////////////////////////
     36// COMMAND REGISTRATION //
     37//////////////////////////
    3638// NO ARGUMENTS
    37 #define ShellCommandRegister0 \
     39#define ShellCommandRegister0() \
    3840  static void registerCommand(const char* commandName, ClassID classID, void (T::*function)()) \
    3941  { \
     
    5153  }
    5254
    53 // CONSTRUCTORS
    54 #define ShellCommandConstructor0 \
     55#define ShellCommandRegister2(t1,t2) \
     56  static void registerCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT) \
     57  { \
     58    if (isRegistered(commandName, classID, 2, t1##_PARAM, t2##_PARAM)== true) \
     59      return; \
     60    new ShellCommand<T>(commandName, classID, function, d1, d2); \
     61  }
     62
     63#define ShellCommandRegister3(t1,t2,t3) \
     64  static void registerCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT) \
     65  { \
     66    if (isRegistered(commandName, classID, 3, t1##_PARAM, t2##_PARAM, t3##_PARAM)== true) \
     67      return; \
     68    new ShellCommand<T>(commandName, classID, function, d1, d2, d3); \
     69  }
     70
     71#define ShellCommandRegister4(t1,t2,t3,t4) \
     72  static void registerCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT, t4##_TYPE d4 = t4##_DEFAULT) \
     73  { \
     74    if (isRegistered(commandName, classID, 4, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM)== true) \
     75      return; \
     76    new ShellCommand<T>(commandName, classID, function, d1, d2, d3, d4); \
     77  }
     78#define ShellCommandRegister5(t1,t2,t3,t4,t5) \
     79  static void registerCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT, t4##_TYPE d4 = t4##_DEFAULT, t5##_TYPE d5 = t5##_DEFAULT) \
     80  { \
     81    if (isRegistered(commandName, classID, 5, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM, t5##_PARAM)== true) \
     82      return; \
     83    new ShellCommand<T>(commandName, classID, function, d1, d2, d3, d4, d5); \
     84  }
     85
     86//////////////////
     87// CONSTRUCTORS //
     88/////////////////
     89#define ShellCommandConstructor0() \
    5590  void (T::*functionPointer_0)(); \
    5691  ShellCommand(const char* commandName, ClassID classID, void (T::*function)()) \
     
    68103  }
    69104
    70 
    71 
    72 #define ShellCommandExecute0 \
     105#define ShellCommandConstructor2(t1,t2) \
     106  void (T::*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \
     107  ShellCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \
     108  : ShellCommandBase(commandName, classID, 2, t1##_PARAM, d1, t2##_PARAM, d2) \
     109  { \
     110    this->functionPointer_2_##t1##_##t2 = function; \
     111  }
     112
     113#define ShellCommandConstructor3(t1,t2,t3) \
     114  void (T::*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \
     115  ShellCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3) \
     116  : ShellCommandBase(commandName, classID, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \
     117  { \
     118    this->functionPointer_3_##t1##_##t2##_##t3 = function; \
     119  }
     120
     121#define ShellCommandConstructor4(t1,t2,t3,t4) \
     122  void (T::*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \
     123  ShellCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3, t4##_TYPE d4) \
     124  : ShellCommandBase(commandName, classID, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \
     125  { \
     126    this->functionPointer_4_##t1##_##t2##_##t3##_##t4 = function; \
     127  }
     128
     129#define ShellCommandConstructor5(t1,t2,t3,t4,t5) \
     130  void (T::*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \
     131  ShellCommand(const char* commandName, ClassID classID, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3, t4##_TYPE d4, t5##_TYPE d5) \
     132  : ShellCommandBase(commandName, classID, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \
     133  { \
     134    this->functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5 = function; \
     135  }
     136
     137///////////////
     138// EXECUTION //
     139///////////////
     140#define ShellCommandExecute0() \
    73141  if (this->paramCount == 0) \
    74142    (dynamic_cast<T*>(object)->*functionPointer_0)()
     
    77145   else if (this->paramCount == 1 && this->parameters[0] == t1##_PARAM) \
    78146    (dynamic_cast<T*>(object)->*functionPointer_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0)))
     147
     148#define ShellCommandExecute2(t1,t2) \
     149   else if (this->paramCount == 2 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM) \
     150    (dynamic_cast<T*>(object)->*functionPointer_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
     151
     152#define ShellCommandExecute3(t1,t2,t3) \
     153   else if (this->paramCount == 3 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM) \
     154    (dynamic_cast<T*>(object)->*functionPointer_3_##t1##_##t2##_##t3)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)))
     155
     156#define ShellCommandExecute4(t1,t2,t3,t4) \
     157   else if (this->paramCount == 4 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM && this->parameters[3] == t4##_PARAM) \
     158    (dynamic_cast<T*>(object)->*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3)))
     159
     160#define ShellCommandExecute5(t1,t2,t3,t4,t5) \
     161   else if (this->paramCount == 5 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM && this->parameters[3] == t4##_PARAM && this->parameters[4] == t5##_PARAM) \
     162    (dynamic_cast<T*>(object)->*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3)), t5##_FUNC(sub.getString(4), t5##_DEFGRAB(4)))
     163
    79164
    80165
     
    126211    static void unregisterCommand(const char* commandNaame, ClassID classID);
    127212
     213#ifdef FUNCTOR_LIST
     214#undef FUNCTOR_LIST
     215#endif
     216
    128217#define FUNCTOR_LIST(x) ShellCommandRegister ## x
    129 //#include "functor_list.h"
    130   FUNCTOR_LIST(0);
    131   FUNCTOR_LIST(1)(l_INT);
    132   FUNCTOR_LIST(1)(l_STRING);
    133   FUNCTOR_LIST(1)(l_FLOAT);
    134   FUNCTOR_LIST(1)(l_BOOL);
     218#include "functor_list.h"
    135219#undef FUNCTOR_LIST
    136220
     
    138222  private:
    139223#define FUNCTOR_LIST(x) ShellCommandConstructor ## x
    140 //#include "functor_list.h"
    141   FUNCTOR_LIST(0);
    142   FUNCTOR_LIST(1)(l_INT);
    143   FUNCTOR_LIST(1)(l_STRING);
    144   FUNCTOR_LIST(1)(l_FLOAT);
    145   FUNCTOR_LIST(1)(l_BOOL);
     224#include "functor_list.h"
    146225#undef FUNCTOR_LIST
    147226
     
    149228    {
    150229//      if (parameters != NULL)
    151       SubString subLoads(parameters);
    152       subLoads.debug();
     230      SubString sub(parameters);
    153231#define FUNCTOR_LIST(x) ShellCommandExecute ## x
    154 //#include "functor_list.h"
    155   FUNCTOR_LIST(0);
    156   FUNCTOR_LIST(1)(l_INT);
    157   FUNCTOR_LIST(1)(l_STRING);
    158   FUNCTOR_LIST(1)(l_FLOAT);
    159   FUNCTOR_LIST(1)(l_BOOL);
     232#include "functor_list.h"
    160233#undef FUNCTOR_LIST
    161234    }
Note: See TracChangeset for help on using the changeset viewer.