Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell_command.h @ 5551

Last change on this file since 5551 was 5551, checked in by bensch, 19 years ago

orxonox/trunk: ShellCommands use less memory due to the use of unions.

File size: 19.6 KB
RevLine 
[4838]1/*!
[5129]2 * @file shell_command.h
[5068]3 * Definition of a on-screen-shell
[5391]4 */
[1853]5
[5129]6#ifndef _SHELL_COMMAND_H
7#define _SHELL_COMMAND_H
[1853]8
[5129]9#include "base_object.h"
[1853]10
[5141]11#include "helper_functions.h"
[5155]12#include "substring.h"
[5143]13#include "functor_list.h"
[5141]14
[5068]15#include <stdarg.h>
16
[5166]17#define     SHELL_COMMAND_MAX_SIZE      //!< The maximum size of a Shell Command
[5130]18
[5127]19
[5130]20
[4838]21// FORWARD DECLARATION
[5068]22template<class T> class tList;
[3543]23
[5166]24/**
25 * an easy to use Macro to create a Command
26 * @param command the name of the command (without "" around the string)
27 * @param class the name of the class to apply this command to (without the "" around the string)
28 * @param function the function to call
[5179]29 *
30 * MEANING:
31 *  ShellCommandBase* someUniqueVarName =
32 *       ShellCommand<ClassName>::registerCommand("commandNameInShell", "ClassName", &ClassName::FunctionToCall);
33 *
34 * In the Shell you would call this Command using:
35 * $ ClassName [ObjectName] commandNameInShell [parameters]
[5166]36 */
[5162]37#define SHELL_COMMAND(command, class, function) \
[5164]38        ShellCommandBase* shell_command_##class##_##command = ShellCommand<class>::registerCommand(#command, #class, &class::function)
[5329]39/**
40 * an easy to use Macro to create a Command
41 * @param command the name of the command (without "" around the string)
42 * @param class the name of the class to apply this command to (without the "" around the string)
43 * @param function the function to call
44 *
45 * MEANING:
46 *  ShellCommandBase* someUniqueVarName =
47 *       ShellCommand<ClassName>::registerCommand("commandNameInShell", "ClassName", &ClassName::FunctionToCall);
48 *
49 * In the Shell you would call this Command using:
50 * $ ClassName [ObjectName] commandNameInShell [parameters]
51 */
52#define SHELL_COMMAND_STATIC(command, class, function) \
53                         ShellCommandBase* shell_command_##class##_##command = ShellCommandStatic<class>::registerCommand(#command, #class, function)
[5135]54
[5162]55
[5328]56//! an enumerator for the definition of the Type.
57typedef enum {
58  ShellCommand_Objective = 1,
59  ShellCommand_Static    = 2,
60} ShellCommand_Type;
61
[5161]62////////////////
63// BASE CLASS //
64////////////////
[5170]65class ShellCommandBase;
[5190]66class ShellCommandAlias;
[5170]67
68//! A class to hold all Classes that have (once) registered Commands.
69class ShellCommandClass : public BaseObject
70{
71  friend class ShellCommandBase;
72
73  public:
[5197]74    /** @returns the CommandClassList */
[5170]75    static const tList<ShellCommandClass>* getCommandClassList() { return ShellCommandClass::commandClassList; };
[5195]76    static bool getCommandListOfClass(const char* className, tList<const char>* stringList);
77    static bool getCommandListOfAlias(tList<const char>* aliasList);
[5190]78
[5170]79    static ShellCommandClass* getCommandClass(const char* className);
[5171]80    static void unregisterAllCommands();
[5170]81
[5204]82    static void help (const char* className);
83
[5170]84  private:
85    ShellCommandClass(const char* className);
86    ~ShellCommandClass();
87
88    static const ShellCommandClass* isRegistered(const char* className);
89    static void initCommandClassList();
90
91  private:
[5171]92    const char*                      className;                 //!< The Name of the Class. This should match the ClassName of the Commands Class.
93    long                             classID;                   //!< The classID of this Class
94    tList<ShellCommandBase>*         commandList;               //!< A list of Commands from this Class
95    static tList<ShellCommandClass>* commandClassList;          //!< A list of Classes
[5195]96    static tList<ShellCommandAlias>* aliasList;                 //!< An Alias to A Command. (only for classes with one Instance)
[5170]97};
98
99
[5161]100//! a baseClass for all possible ShellCommands
101class ShellCommandBase : public BaseObject
102{
[5170]103  friend class ShellCommandClass;
[5161]104  public:
105    static bool execute (const char* executionString);
106
[5164]107    ShellCommandBase* describe(const char* description);
[5190]108    ShellCommandBase* setAlias(const char* alias);
[5207]109    ShellCommandBase* defaultValues(unsigned int count, ...);
[5164]110
[5166]111    /** @returns the CommandList of the Shell */
112    static void unregisterCommand(const char* commandName, const char* className);
[5161]113
114    static void debug();
115
116  protected:
117    ShellCommandBase(const char* commandName, const char* className, unsigned int paramCount, ...);
118    ~ShellCommandBase();
119
[5328]120    /** @returns the Type of this Function (either static or objective) */
121    inline ShellCommand_Type getType() { return this->functorType; };
122
[5161]123    static bool isRegistered(const char* commandName, const char* className, unsigned int paramCount, ...);
124    static const char* paramToString(long parameter);
125
126  private:
[5166]127    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
[5279]128    virtual void executeCommand (BaseObject* object, const char* parameters) = 0;
[5161]129
130  protected:
[5328]131    ShellCommand_Type                functorType;                          //!< The type of Function we've got (either static or objective).
[5163]132    void*                            functionPointer;                      //!< The pointeer to the function of the Class (or static pointer if ClassID == CL_NULL )
[5166]133    unsigned int                     paramCount;                           //!< the count of parameters.
134    unsigned int*                    parameters;                           //!< Parameters the function of this Command takes.
135    char*                            defaultStrings[FUNCTOR_MAX_ARGUMENTS];//!< A list of default Strings stored.
136    int                              defaultInts[FUNCTOR_MAX_ARGUMENTS];   //!< A list of default Ints stored.
137    float                            defaultFloats[FUNCTOR_MAX_ARGUMENTS]; //!< A list of default Floats stored.
138    bool                             defaultBools[FUNCTOR_MAX_ARGUMENTS];  //!< A list of default Bools stored.
[5161]139
[5328]140
[5161]141  private:
[5170]142    ShellCommandClass*               shellClass;                           //!< A Pointer to the Shell-Class this Command belongs to.
[5196]143    ShellCommandAlias*               alias;                                //!< An Alias for the Class.
[5161]144
[5166]145    const char*                      description;                          //!< A description for this commnand. (initially NULL). Assigned with (create)->describe("blablabla");
[5161]146};
147
148///////////////////////////////////////////////////
149///////////////////////////////////////////////////
150
[5326]151/////////////////////////////////
152// MACRO DEFINITION EXTENSIONS //
153/////////////////////////////////
[5166]154//! where to chek for default BOOL values
[5151]155#define   l_BOOL_DEFGRAB(i)         this->defaultBools[i]
[5166]156//! where to chek for default INT values
[5151]157#define   l_INT_DEFGRAB(i)          this->defaultInts[i]
[5166]158//! where to chek for default UINT values
[5151]159#define   l_UINT_DEFGRAB(i)         (unsigned int)this->defaultInts[i]
[5166]160//! where to chek for default LONG values
[5151]161#define   l_LONG_DEFGRAB(i)         (long)this->defaultInts[i]
[5166]162//! where to chek for default FLOAT values
[5151]163#define   l_FLOAT_DEFGRAB(i)        this->defaultFloats[i]
[5166]164//! where to chek for default STRING values
[5151]165#define   l_STRING_DEFGRAB(i)       this->defaultStrings[i]
[5135]166
[5153]167//////////////////////////
168// COMMAND REGISTRATION //
169//////////////////////////
[5326]170// SHELLCOMMAND can be redefined as ShellCommand or ShellCommandStatic
171// SHELLCOMMANDEXECUTER can be redefined too.
[5327]172// SHELLCOMMANDINCLASS
[5328]173// SHELLCOMMANDTYPE
[5166]174//! registers a command without any parameters
[5153]175#define ShellCommandRegister0() \
[5327]176  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)()) \
[5142]177  { \
[5161]178    if (isRegistered(commandName, className, 0)== true) \
179      return NULL; \
[5327]180    return new SHELLCOMMAND<T>(commandName, className, function); \
[5142]181  }
[5135]182
[5166]183//! registers a command with 1 parameter
[5145]184#define ShellCommandRegister1(t1) \
[5327]185  static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \
[5135]186  { \
[5161]187    if (isRegistered(commandName, className, 1, t1##_PARAM)== true) \
188      return NULL; \
[5327]189    return new SHELLCOMMAND<T>(commandName, className, function, d1); \
[5142]190  }
191
[5166]192//! registers a command with 2 parameters
[5153]193#define ShellCommandRegister2(t1,t2) \
[5327]194  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) \
[5153]195  { \
[5161]196    if (isRegistered(commandName, className, 2, t1##_PARAM, t2##_PARAM)== true) \
197      return NULL; \
[5327]198    return new SHELLCOMMAND<T>(commandName, className, function, d1, d2); \
[5153]199  }
200
[5166]201//! registers a command with 3 parameters
[5153]202#define ShellCommandRegister3(t1,t2,t3) \
[5327]203  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) \
[5153]204  { \
[5161]205    if (isRegistered(commandName, className, 3, t1##_PARAM, t2##_PARAM, t3##_PARAM)== true) \
206      return NULL; \
[5327]207    return new SHELLCOMMAND<T>(commandName, className, function, d1, d2, d3); \
[5153]208  }
209
[5166]210//! registers a command with 4 parameters
[5153]211#define ShellCommandRegister4(t1,t2,t3,t4) \
[5327]212  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) \
[5153]213  { \
[5161]214    if (isRegistered(commandName, className, 4, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM)== true) \
215      return NULL; \
[5327]216    return new SHELLCOMMAND<T>(commandName, className, function, d1, d2, d3, d4); \
[5153]217  }
[5161]218
[5166]219//! registers a command with 5 parameters
[5153]220#define ShellCommandRegister5(t1,t2,t3,t4,t5) \
[5327]221  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) \
[5153]222  { \
[5161]223    if (isRegistered(commandName, className, 5, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM, t5##_PARAM)== true) \
224      return NULL; \
225    return new ShellCommand<T>(commandName, className, function, d1, d2, d3, d4, d5); \
[5153]226  }
227
[5551]228///////////////////////
229// FUNCTION POINTERS //
230///////////////////////
231#define ShellCommandFunctionPoiter0() \
232  void SHELLCOMMANDINCLASS(*functionPointer_0)();
233
234#define ShellCommandFunctionPoiter1(t1) \
235  void SHELLCOMMANDINCLASS(*functionPointer_1_##t1)(t1##_TYPE);
236
237#define ShellCommandFunctionPoiter2(t1, t2) \
238  void SHELLCOMMANDINCLASS(*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE);
239
240
241#define ShellCommandFunctionPoiter3(t1, t2, t3) \
242  void SHELLCOMMANDINCLASS(*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE);
243
244#define ShellCommandFunctionPoiter4(t1, t2, t3, t4) \
245  void SHELLCOMMANDINCLASS(*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE);
246
247
248#define ShellCommandFunctionPoiter5(t1, t2, t3, t4, t5) \
249  void SHELLCOMMANDINCLASS(*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \
250
251
[5153]252//////////////////
253// CONSTRUCTORS //
254/////////////////
[5166]255//! creates a command that takes no parameters
[5153]256#define ShellCommandConstructor0() \
[5327]257  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)()) \
[5161]258  : ShellCommandBase(commandName, className, 0) \
[5142]259  { \
[5328]260    this->functorType = SHELLCOMMANDTYPE; \
[5551]261    this->fp.functionPointer_0 = function; \
[5142]262  }
263
[5166]264//! creates a command that takes one parameter
[5145]265#define ShellCommandConstructor1(t1) \
[5327]266  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE), t1##_TYPE d1) \
[5161]267  : ShellCommandBase(commandName, className, 1, t1##_PARAM, d1) \
[5135]268  { \
[5328]269    this->functorType = SHELLCOMMANDTYPE; \
[5551]270    this->fp.functionPointer_1_##t1 = function; \
[5135]271  }
272
[5166]273//! creates a command that takes two parameters
[5153]274#define ShellCommandConstructor2(t1,t2) \
[5327]275  SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \
[5161]276  : ShellCommandBase(commandName, className, 2, t1##_PARAM, d1, t2##_PARAM, d2) \
[5153]277  { \
[5328]278    this->functorType = SHELLCOMMANDTYPE; \
[5551]279    this->fp.functionPointer_2_##t1##_##t2 = function; \
[5153]280  }
[5135]281
[5166]282//! creates a command that takes three parameter
[5153]283#define ShellCommandConstructor3(t1,t2,t3) \
[5327]284  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) \
[5161]285  : ShellCommandBase(commandName, className, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \
[5153]286  { \
[5328]287    this->functorType = SHELLCOMMANDTYPE; \
[5551]288    this->fp.functionPointer_3_##t1##_##t2##_##t3 = function; \
[5153]289  }
[5141]290
[5166]291//! creates a command that takes four parameter
[5153]292#define ShellCommandConstructor4(t1,t2,t3,t4) \
[5327]293  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) \
[5161]294  : ShellCommandBase(commandName, className, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \
[5153]295  { \
[5328]296    this->functorType = SHELLCOMMANDTYPE; \
[5551]297    this->fp.functionPointer_4_##t1##_##t2##_##t3##_##t4 = function; \
[5153]298  }
299
[5166]300//! creates a command that takes five parameter
[5153]301#define ShellCommandConstructor5(t1,t2,t3,t4,t5) \
[5327]302  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) \
[5161]303  : ShellCommandBase(commandName, className, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \
[5153]304  { \
[5328]305    this->functorType = SHELLCOMMANDTYPE; \
[5551]306    this->fp.functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5 = function; \
[5153]307  }
308
309///////////////
310// EXECUTION //
311///////////////
[5166]312//! execute-macro for functions with no parameters
[5153]313#define ShellCommandExecute0() \
[5145]314  if (this->paramCount == 0) \
[5326]315    SHELLCOMMANDEXECUTER(_0)()
[5145]316
[5166]317//! execute-macro for functions with one parameter
[5145]318#define ShellCommandExecute1(t1) \
[5146]319   else if (this->paramCount == 1 && this->parameters[0] == t1##_PARAM) \
[5326]320    SHELLCOMMANDEXECUTER(_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0)))
[5145]321
[5166]322//! execute-macro for functions with two parameters
[5153]323#define ShellCommandExecute2(t1,t2) \
324   else if (this->paramCount == 2 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM) \
[5326]325    SHELLCOMMANDEXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
[5145]326
[5166]327//! execute-macro for functions with three parameters
[5153]328#define ShellCommandExecute3(t1,t2,t3) \
329   else if (this->paramCount == 3 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM) \
[5326]330    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)))
[5153]331
[5166]332//! execute-macro for functions with four parameters
[5153]333#define ShellCommandExecute4(t1,t2,t3,t4) \
334   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) \
[5326]335    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)))
[5153]336
[5166]337//! execute-macro for functions with five parameters
[5153]338#define ShellCommandExecute5(t1,t2,t3,t4,t5) \
339   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) \
[5326]340    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)))
[5153]341
342
[5129]343//! keeps information about a ShellCommand
344template<class T> class ShellCommand : public ShellCommandBase
345{
346  public:
[5153]347#ifdef FUNCTOR_LIST
348#undef FUNCTOR_LIST
349#endif
[5326]350#ifdef SHELLCOMMAND
351#undef SHELLCOMMAND
352#endif
[5327]353#define SHELLCOMMAND                       ShellCommand
[5326]354#ifdef SHELLCOMMANDEXECUTER
355#undef SHELLCOMMANDEXECUTER
356#endif
[5551]357#define SHELLCOMMANDEXECUTER(nameExt)      (dynamic_cast<T*>(object)->*(fp.functionPointer##nameExt))
[5327]358#ifdef SHELLCOMMANDINCLASS
359#undef SHELLCOMMANDINCLASS
360#endif
361#define SHELLCOMMANDINCLASS(FUNCTION)      (T::FUNCTION)
[5328]362#ifdef SHELLCOMMANDTYPE
363#undef SHELLCOMMANDTYPE
364#endif
365#define SHELLCOMMANDTYPE                   ShellCommand_Objective
[5166]366//! FUNCTOR_LIST is the List of command-registerers
[5142]367#define FUNCTOR_LIST(x) ShellCommandRegister ## x
[5153]368#include "functor_list.h"
[5142]369#undef FUNCTOR_LIST
[5136]370
[5142]371
[5068]372  private:
[5551]373//! FUNCTOR_LIST is the List of FunctionPointers
374    union FunctionPointers {
375#define FUNCTOR_LIST(x) ShellCommandFunctionPoiter ## x
376#include "functor_list.h"
377#undef FUNCTOR_LIST
378    } fp;
379
[5166]380//! FUNCTOR_LIST is the List of CommandConstructors
[5142]381#define FUNCTOR_LIST(x) ShellCommandConstructor ## x
[5153]382#include "functor_list.h"
[5142]383#undef FUNCTOR_LIST
384
385    virtual void executeCommand (BaseObject* object, const char* parameters)
[5135]386    {
[5204]387      SubString sub(parameters, true);
[5166]388//! FUNCTOR_LIST is the List of Executive Functions
[5145]389#define FUNCTOR_LIST(x) ShellCommandExecute ## x
[5153]390#include "functor_list.h"
[5135]391#undef FUNCTOR_LIST
[5145]392    }
[5129]393};
[5113]394
[5327]395//! keeps information about a ShellCommand, that points to a Static Function
[5326]396template<class T> class ShellCommandStatic : public ShellCommandBase
397{
398  public:
399#ifdef FUNCTOR_LIST
400#undef FUNCTOR_LIST
401#endif
402#ifdef SHELLCOMMAND
403#undef SHELLCOMMAND
404#endif
405#define SHELLCOMMAND                      ShellCommandStatic
406#ifdef SHELLCOMMANDEXECUTER
407#undef SHELLCOMMANDEXECUTER
408#endif
[5551]409#define SHELLCOMMANDEXECUTER(nameExt)     fp.functionPointer##nameExt
[5327]410#ifdef SHELLCOMMANDINCLASS
411#undef SHELLCOMMANDINCLASS
412#endif
413#define SHELLCOMMANDINCLASS(FUNCTION)     (FUNCTION)
[5328]414#ifdef SHELLCOMMANDTYPE
415#undef SHELLCOMMANDTYPE
416#endif
417#define SHELLCOMMANDTYPE                   ShellCommand_Static
[5326]418
419//! FUNCTOR_LIST is the List of command-registerers
420#define FUNCTOR_LIST(x) ShellCommandRegister ## x
421#include "functor_list.h"
422#undef FUNCTOR_LIST
423
424  private:
[5551]425//! FUNCTOR_LIST is the List of FunctionPointers
426    union FunctionPointers {
427#define FUNCTOR_LIST(x) ShellCommandFunctionPoiter ## x
428#include "functor_list.h"
429#undef FUNCTOR_LIST
430    } fp;
431
[5326]432//! FUNCTOR_LIST is the List of CommandConstructors
433#define FUNCTOR_LIST(x) ShellCommandConstructor ## x
434#include "functor_list.h"
435#undef FUNCTOR_LIST
436
437    virtual void executeCommand (BaseObject* object, const char* parameters)
438    {
439  SubString sub(parameters, true);
440//! FUNCTOR_LIST is the List of Executive Functions
441#define FUNCTOR_LIST(x) ShellCommandExecute ## x
442#include "functor_list.h"
443#undef FUNCTOR_LIST
444    }
445};
446
[5197]447//! A Class, that handles aliases.
[5190]448class ShellCommandAlias
449{
[5196]450  friend class ShellCommandBase;
[5190]451  public:
[5197]452    /** @returns the Name of the Alias. */
[5195]453    const char* getName() const { return this->aliasName; };
[5197]454    /** @returns the Command, this Alias is asociated with */
[5195]455    ShellCommandBase* getCommand() const { return this->command; };
[5196]456
[5190]457  private:
[5197]458    /** @param aliasName the name of the Alias @param command the Command, to associate this alias with */
[5196]459    ShellCommandAlias(const char* aliasName, ShellCommandBase* command) { this->aliasName = aliasName; this->command = command; };
460
461  private:
[5197]462    const char*         aliasName;       //!< the name of the Alias
463    ShellCommandBase*   command;         //!< a pointer to the command, this alias executes.
[5190]464};
465
[5129]466#endif /* _SHELL_COMMAND_H */
Note: See TracBrowser for help on using the repository browser.