Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/trunk: more overwhelmingly complicated code, that slowly gets out of my grasp

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

Legend:

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

    r5326 r5327  
    211211  {
    212212    ShellCommandClass::commandClassList = new tList<ShellCommandClass>;
    213     ShellCommand<ShellCommandBase>::registerCommand("debug", "ShellCommand", &ShellCommandBase::debugDyn);
     213//    ShellCommandStatic<ShellCommandBase>::registerCommand("debug", "ShellCommand", &ShellCommandBase::debug);
    214214  }
    215215}
  • trunk/src/lib/shell/shell_command.h

    r5326 r5327  
    148148// SHELLCOMMAND can be redefined as ShellCommand or ShellCommandStatic
    149149// SHELLCOMMANDEXECUTER can be redefined too.
     150// SHELLCOMMANDINCLASS
    150151//! registers a command without any parameters
    151152#define ShellCommandRegister0() \
    152   static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)()) \
     153  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)()) \
    153154  { \
    154155    if (isRegistered(commandName, className, 0)== true) \
    155156      return NULL; \
    156     return new ShellCommand<T>(commandName, className, function); \
     157    return new SHELLCOMMAND<T>(commandName, className, function); \
    157158  }
    158159
    159160//! registers a command with 1 parameter
    160161#define ShellCommandRegister1(t1) \
    161   static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \
     162  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \
    162163  { \
    163164    if (isRegistered(commandName, className, 1, t1##_PARAM)== true) \
    164165      return NULL; \
    165     return new ShellCommand<T>(commandName, className, function, d1); \
     166    return new SHELLCOMMAND<T>(commandName, className, function, d1); \
    166167  }
    167168
    168169//! registers a command with 2 parameters
    169170#define ShellCommandRegister2(t1,t2) \
    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) \
     171  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT) \
    171172  { \
    172173    if (isRegistered(commandName, className, 2, t1##_PARAM, t2##_PARAM)== true) \
    173174      return NULL; \
    174     return new ShellCommand<T>(commandName, className, function, d1, d2); \
     175    return new SHELLCOMMAND<T>(commandName, className, function, d1, d2); \
    175176  }
    176177
    177178//! registers a command with 3 parameters
    178179#define ShellCommandRegister3(t1,t2,t3) \
    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) \
     180  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1 = t1##_DEFAULT, t2##_TYPE d2 = t2##_DEFAULT, t3##_TYPE d3 = t3##_DEFAULT) \
    180181  { \
    181182    if (isRegistered(commandName, className, 3, t1##_PARAM, t2##_PARAM, t3##_PARAM)== true) \
    182183      return NULL; \
    183     return new ShellCommand<T>(commandName, className, function, d1, d2, d3); \
     184    return new SHELLCOMMAND<T>(commandName, className, function, d1, d2, d3); \
    184185  }
    185186
    186187//! registers a command with 4 parameters
    187188#define ShellCommandRegister4(t1,t2,t3,t4) \
    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) \
     189  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*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) \
    189190  { \
    190191    if (isRegistered(commandName, className, 4, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM)== true) \
    191192      return NULL; \
    192     return new ShellCommand<T>(commandName, className, function, d1, d2, d3, d4); \
     193    return new SHELLCOMMAND<T>(commandName, className, function, d1, d2, d3, d4); \
    193194  }
    194195
    195196//! registers a command with 5 parameters
    196197#define ShellCommandRegister5(t1,t2,t3,t4,t5) \
    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) \
     198  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*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) \
    198199  { \
    199200    if (isRegistered(commandName, className, 5, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM, t5##_PARAM)== true) \
     
    207208//! creates a command that takes no parameters
    208209#define ShellCommandConstructor0() \
    209   void (T::*functionPointer_0)(); \
    210   SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)()) \
     210  void SHELLCOMMANDINCLASS(*functionPointer_0)(); \
     211  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)()) \
    211212  : ShellCommandBase(commandName, className, 0) \
    212213  { \
     
    216217//! creates a command that takes one parameter
    217218#define ShellCommandConstructor1(t1) \
    218   void (T::*functionPointer_1_##t1)(t1##_TYPE); \
    219   SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1) \
     219  void SHELLCOMMANDINCLASS(*functionPointer_1_##t1)(t1##_TYPE); \
     220  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE), t1##_TYPE d1) \
    220221  : ShellCommandBase(commandName, className, 1, t1##_PARAM, d1) \
    221222  { \
     
    225226//! creates a command that takes two parameters
    226227#define ShellCommandConstructor2(t1,t2) \
    227   void (T::*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \
    228   SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \
     228  void SHELLCOMMANDINCLASS(*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \
     229  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \
    229230  : ShellCommandBase(commandName, className, 2, t1##_PARAM, d1, t2##_PARAM, d2) \
    230231  { \
     
    234235//! creates a command that takes three parameter
    235236#define ShellCommandConstructor3(t1,t2,t3) \
    236   void (T::*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \
    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) \
     237  void SHELLCOMMANDINCLASS(*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \
     238  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3) \
    238239  : ShellCommandBase(commandName, className, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \
    239240  { \
     
    243244//! creates a command that takes four parameter
    244245#define ShellCommandConstructor4(t1,t2,t3,t4) \
    245   void (T::*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \
    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) \
     246  void SHELLCOMMANDINCLASS(*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \
     247  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE), t1##_TYPE d1, t2##_TYPE d2, t3##_TYPE d3, t4##_TYPE d4) \
    247248  : ShellCommandBase(commandName, className, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \
    248249  { \
     
    252253//! creates a command that takes five parameter
    253254#define ShellCommandConstructor5(t1,t2,t3,t4,t5) \
    254   void (T::*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \
    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) \
     255  void SHELLCOMMANDINCLASS(*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \
     256  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*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) \
    256257  : ShellCommandBase(commandName, className, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \
    257258  { \
     
    303304#undef SHELLCOMMAND
    304305#endif
    305 #define SHELLCOMMAND         ShellCommand
     306#define SHELLCOMMAND                       ShellCommand
    306307#ifdef SHELLCOMMANDEXECUTER
    307308#undef SHELLCOMMANDEXECUTER
    308309#endif
    309 #define SHELLCOMMANDEXECUTER(nameExt)     (dynamic_cast<T*>(object)->*functionPointer##nameExt)
     310#define SHELLCOMMANDEXECUTER(nameExt)      (dynamic_cast<T*>(object)->*functionPointer##nameExt)
     311#ifdef SHELLCOMMANDINCLASS
     312#undef SHELLCOMMANDINCLASS
     313#endif
     314#define SHELLCOMMANDINCLASS(FUNCTION)      (T::FUNCTION)
    310315
    311316//! FUNCTOR_LIST is the List of command-registerers
     
    331336};
    332337
     338//! keeps information about a ShellCommand, that points to a Static Function
    333339template<class T> class ShellCommandStatic : public ShellCommandBase
    334340{
     
    345351#endif
    346352#define SHELLCOMMANDEXECUTER(nameExt)     T::functionPointer##nameExt
     353#ifdef SHELLCOMMANDINCLASS
     354#undef SHELLCOMMANDINCLASS
     355#endif
     356#define SHELLCOMMANDINCLASS(FUNCTION)     (FUNCTION)
    347357
    348358//! FUNCTOR_LIST is the List of command-registerers
Note: See TracChangeset for help on using the changeset viewer.