Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 8, 2005, 9:18:12 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ShellCommandStatic defined… now going to test it, (or revert if not working)

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

Legend:

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

    r5249 r5326  
    432432//  long completeType = SHELLC_NONE;      //< the Type we'd like to complete.
    433433  SubString inputSplits(executionString, true);
    434 
    435   printf("!!!!%s!!!\n", executionString);
    436434
    437435  if (inputSplits.getCount() == 0)
  • trunk/src/lib/shell/shell_command.h

    r5279 r5326  
    127127///////////////////////////////////////////////////
    128128
    129 ///////////////////////
    130 // MACRO DEFINITIONS //
    131 ///////////////////////
     129/////////////////////////////////
     130// MACRO DEFINITION EXTENSIONS //
     131/////////////////////////////////
    132132//! where to chek for default BOOL values
    133133#define   l_BOOL_DEFGRAB(i)         this->defaultBools[i]
     
    146146// COMMAND REGISTRATION //
    147147//////////////////////////
     148// SHELLCOMMAND can be redefined as ShellCommand or ShellCommandStatic
     149// SHELLCOMMANDEXECUTER can be redefined too.
    148150//! registers a command without any parameters
    149151#define ShellCommandRegister0() \
    150   static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)()) \
     152  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)()) \
    151153  { \
    152154    if (isRegistered(commandName, className, 0)== true) \
     
    157159//! registers a command with 1 parameter
    158160#define ShellCommandRegister1(t1) \
    159   static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \
     161  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \
    160162  { \
    161163    if (isRegistered(commandName, className, 1, t1##_PARAM)== true) \
     
    166168//! registers a command with 2 parameters
    167169#define ShellCommandRegister2(t1,t2) \
    168   static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT) \
     170  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT) \
    169171  { \
    170172    if (isRegistered(commandName, className, 2, t1##_PARAM, t2##_PARAM)== true) \
     
    175177//! registers a command with 3 parameters
    176178#define ShellCommandRegister3(t1,t2,t3) \
    177   static ShellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT) \
     179  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT) \
    178180  { \
    179181    if (isRegistered(commandName, className, 3, t1##_PARAM, t2##_PARAM, t3##_PARAM)== true) \
     
    184186//! registers a command with 4 parameters
    185187#define ShellCommandRegister4(t1,t2,t3,t4) \
    186   static ShellCommand<T>* registerCommand(const char* commandName, const char* className, 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) \
     188  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, 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) \
    187189  { \
    188190    if (isRegistered(commandName, className, 4, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM)== true) \
     
    193195//! registers a command with 5 parameters
    194196#define ShellCommandRegister5(t1,t2,t3,t4,t5) \
    195   static ShellCommand<T>* registerCommand(const char* commandName, const char* className, 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) \
     197  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, 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) \
    196198  { \
    197199    if (isRegistered(commandName, className, 5, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM, t5##_PARAM)== true) \
     
    206208#define ShellCommandConstructor0() \
    207209  void (T::*functionPointer_0)(); \
    208   ShellCommand(const char* commandName, const char* className, void (T::*function)()) \
     210  SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)()) \
    209211  : ShellCommandBase(commandName, className, 0) \
    210212  { \
     
    215217#define ShellCommandConstructor1(t1) \
    216218  void (T::*functionPointer_1_##t1)(t1##_TYPE); \
    217   ShellCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1) \
     219  SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1) \
    218220  : ShellCommandBase(commandName, className, 1, t1##_PARAM, d1) \
    219221  { \
     
    224226#define ShellCommandConstructor2(t1,t2) \
    225227  void (T::*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \
    226   ShellCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \
     228  SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \
    227229  : ShellCommandBase(commandName, className, 2, t1##_PARAM, d1, t2##_PARAM, d2) \
    228230  { \
     
    233235#define ShellCommandConstructor3(t1,t2,t3) \
    234236  void (T::*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \
    235   ShellCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3) \
     237  SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3) \
    236238  : ShellCommandBase(commandName, className, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \
    237239  { \
     
    242244#define ShellCommandConstructor4(t1,t2,t3,t4) \
    243245  void (T::*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \
    244   ShellCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3, t4##_TYPE d4) \
     246  SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3, t4##_TYPE d4) \
    245247  : ShellCommandBase(commandName, className, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \
    246248  { \
     
    251253#define ShellCommandConstructor5(t1,t2,t3,t4,t5) \
    252254  void (T::*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \
    253   ShellCommand(const char* commandName, const char* className, 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) \
     255  SHELLCOMMAND(const char* commandName, const char* className, 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) \
    254256  : ShellCommandBase(commandName, className, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \
    255257  { \
     
    263265#define ShellCommandExecute0() \
    264266  if (this->paramCount == 0) \
    265     (dynamic_cast<T*>(object)->*functionPointer_0)()
     267    SHELLCOMMANDEXECUTER(_0)()
    266268
    267269//! execute-macro for functions with one parameter
    268270#define ShellCommandExecute1(t1) \
    269271   else if (this->paramCount == 1 && this->parameters[0] == t1##_PARAM) \
    270     (dynamic_cast<T*>(object)->*functionPointer_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0)))
     272    SHELLCOMMANDEXECUTER(_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0)))
    271273
    272274//! execute-macro for functions with two parameters
    273275#define ShellCommandExecute2(t1,t2) \
    274276   else if (this->paramCount == 2 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM) \
    275     (dynamic_cast<T*>(object)->*functionPointer_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
     277    SHELLCOMMANDEXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
    276278
    277279//! execute-macro for functions with three parameters
    278280#define ShellCommandExecute3(t1,t2,t3) \
    279281   else if (this->paramCount == 3 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM) \
    280     (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)))
     282    SHELLCOMMANDEXECUTER(_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)))
    281283
    282284//! execute-macro for functions with four parameters
    283285#define ShellCommandExecute4(t1,t2,t3,t4) \
    284286   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) \
    285     (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)))
     287    SHELLCOMMANDEXECUTER(_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)))
    286288
    287289//! execute-macro for functions with five parameters
    288290#define ShellCommandExecute5(t1,t2,t3,t4,t5) \
    289291   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) \
    290     (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)))
     292    SHELLCOMMANDEXECUTER(_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)))
    291293
    292294
     
    295297{
    296298  public:
    297 
    298299#ifdef FUNCTOR_LIST
    299300#undef FUNCTOR_LIST
    300301#endif
     302#ifdef SHELLCOMMAND
     303#undef SHELLCOMMAND
     304#endif
     305#define SHELLCOMMAND         ShellCommand
     306#ifdef SHELLCOMMANDEXECUTER
     307#undef SHELLCOMMANDEXECUTER
     308#endif
     309#define SHELLCOMMANDEXECUTER(nameExt)     (dynamic_cast<T*>(object)->*functionPointer##nameExt)
    301310
    302311//! FUNCTOR_LIST is the List of command-registerers
     
    314323    virtual void executeCommand (BaseObject* object, const char* parameters)
    315324    {
    316 //      if (parameters != NULL)
    317325      SubString sub(parameters, true);
     326//! FUNCTOR_LIST is the List of Executive Functions
     327#define FUNCTOR_LIST(x) ShellCommandExecute ## x
     328#include "functor_list.h"
     329#undef FUNCTOR_LIST
     330    }
     331};
     332
     333template<class T> class ShellCommandStatic : public ShellCommandBase
     334{
     335  public:
     336#ifdef FUNCTOR_LIST
     337#undef FUNCTOR_LIST
     338#endif
     339#ifdef SHELLCOMMAND
     340#undef SHELLCOMMAND
     341#endif
     342#define SHELLCOMMAND                      ShellCommandStatic
     343#ifdef SHELLCOMMANDEXECUTER
     344#undef SHELLCOMMANDEXECUTER
     345#endif
     346#define SHELLCOMMANDEXECUTER(nameExt)     T::functionPointer##nameExt
     347
     348//! FUNCTOR_LIST is the List of command-registerers
     349#define FUNCTOR_LIST(x) ShellCommandRegister ## x
     350#include "functor_list.h"
     351#undef FUNCTOR_LIST
     352
     353  private:
     354//! FUNCTOR_LIST is the List of CommandConstructors
     355#define FUNCTOR_LIST(x) ShellCommandConstructor ## x
     356#include "functor_list.h"
     357#undef FUNCTOR_LIST
     358
     359    virtual void executeCommand (BaseObject* object, const char* parameters)
     360    {
     361  SubString sub(parameters, true);
    318362//! FUNCTOR_LIST is the List of Executive Functions
    319363#define FUNCTOR_LIST(x) ShellCommandExecute ## x
Note: See TracChangeset for help on using the changeset viewer.