Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5130 in orxonox.OLD for trunk/src/util/shell_command.h


Ignore:
Timestamp:
Aug 26, 2005, 12:04:43 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: flush

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/shell_command.h

    r5129 r5130  
    1111#include <stdarg.h>
    1212
     13#define MAX_SHELL_COMMAND_SIZE
     14
    1315typedef enum ShellParameterType
    1416{
     
    2224};
    2325
     26
    2427// FORWARD DECLARATION
    2528template<class T> class tList;
    2629template<class T> class tIterator;
    27 #define MAX_SHELL_COMMAND_SIZE
    2830
    29 class ShellCommandBase
     31class ShellCommandBase : public BaseObject
    3032{
    3133  public:
    3234    static bool execute (const char* executionString);
    3335
     36//    virtual void execute (...);
     37
    3438  protected:
    35     ShellCommandBase(const char* commandName, ClassID classID);
     39    ShellCommandBase(const char* commandName, ClassID classID, void* functionPointer, unsigned int paramCount, va_list parameters);
     40    ~ShellCommandBase();
    3641
    37     static bool isRegistered(const char* commandName, ClassID classID);
     42    static bool isRegistered(const char* commandName, ClassID classID, unsigned int paramCount, va_list parameters);
    3843
     44
     45  protected:
     46    void*                            functionPointer;     //!< The pointeer to the function of the Class (or static pointer if ClassID == CL_NULL )
     47    unsigned int                     paramCount;          //!< the count of parameters
     48    ShellParameterType*              parameters;          //!< Parameters
    3949
    4050  private:
     
    4252    long                             classID;             //!< The ID of the Class asociated to this Command
    4353
    44 
     54    // STATIC MEMBERS
    4555    static tList<ShellCommandBase>*  commandList;         //!< A list of availiable commands.
    4656};
     
    5060{
    5161  public:
    52     static void registerCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
     62    static void registerCommand(const char* commandName, ClassID classID, T* object, void (T::*functionPointer)(), unsigned int paramCount, ...);
    5363
    5464    static void unregisterCommand(const char* commandNaame, ClassID classID);
    5565
    5666  private:
    57     ShellCommand(const char* command, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object = NULL);
     67    ShellCommand(const char* command, ClassID classID, T* object, void* functionPointer, unsigned int paramCount, va_list parameters);
    5868
    5969
    6070  public:
    61     void*                functionPointer;     //!< The pointer to the function of the Class (or static pointer if ClassID == CL_NULL )
    62     T*                   Object;              //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL )
     71    T*                   objectPointer;       //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL )
    6372};
    6473
    6574template<class T>
    66     ShellCommand<T>::ShellCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
    67   : ShellCommandBase (command, classID)
     75    ShellCommand<T>::ShellCommand(const char* commandName, ClassID classID, T* object, void* functionPointer, unsigned int paramCount, va_list parameters)
     76  : ShellCommandBase (commandName, classID, functionPointer, paramCount, parameters)
    6877{
    6978
     
    7180
    7281template<class T>
    73     void ShellCommand<T>::registerCommand(const char* commandName, void* pointerToFunction, ClassID classID, ShellParameterType param1Type, void* Object)
     82    void ShellCommand<T>::registerCommand(const char* commandName, ClassID classID, T* object, void (T::*functionPointer)(), unsigned int paramCount, ...)
    7483{
    75   if (isRegistered() == true)
     84  va_list parameters;
     85  va_start(parameters, paramCount);
     86
     87  if (isRegistered(commandName, classID, paramCount, parameters) == true)
    7688    return;
    7789  else
    7890  {
    79     ShellCommand<T>* newCommand = new ShellCommand<T>(command);
    80     elem->functionPointer = pointerToFunction;
    81     elem->parameter1 = param1Type;
    82     elem->Object = Object;
    8391
    84 
     92//    ShellCommand<T>* newCommand = new ShellCommand<T>(commandName, classID, object, functionPointer, paramCount, parameters);
    8593  }
    8694}
Note: See TracChangeset for help on using the changeset viewer.