Changeset 5130 in orxonox.OLD for trunk/src/util/shell_command.h
- Timestamp:
- Aug 26, 2005, 12:04:43 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/shell_command.h
r5129 r5130 11 11 #include <stdarg.h> 12 12 13 #define MAX_SHELL_COMMAND_SIZE 14 13 15 typedef enum ShellParameterType 14 16 { … … 22 24 }; 23 25 26 24 27 // FORWARD DECLARATION 25 28 template<class T> class tList; 26 29 template<class T> class tIterator; 27 #define MAX_SHELL_COMMAND_SIZE28 30 29 class ShellCommandBase 31 class ShellCommandBase : public BaseObject 30 32 { 31 33 public: 32 34 static bool execute (const char* executionString); 33 35 36 // virtual void execute (...); 37 34 38 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(); 36 41 37 static bool isRegistered(const char* commandName, ClassID classID );42 static bool isRegistered(const char* commandName, ClassID classID, unsigned int paramCount, va_list parameters); 38 43 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 39 49 40 50 private: … … 42 52 long classID; //!< The ID of the Class asociated to this Command 43 53 44 54 // STATIC MEMBERS 45 55 static tList<ShellCommandBase>* commandList; //!< A list of availiable commands. 46 56 }; … … 50 60 { 51 61 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, ...); 53 63 54 64 static void unregisterCommand(const char* commandNaame, ClassID classID); 55 65 56 66 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); 58 68 59 69 60 70 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 ) 63 72 }; 64 73 65 74 template<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) 68 77 { 69 78 … … 71 80 72 81 template<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, ...) 74 83 { 75 if (isRegistered() == true) 84 va_list parameters; 85 va_start(parameters, paramCount); 86 87 if (isRegistered(commandName, classID, paramCount, parameters) == true) 76 88 return; 77 89 else 78 90 { 79 ShellCommand<T>* newCommand = new ShellCommand<T>(command);80 elem->functionPointer = pointerToFunction;81 elem->parameter1 = param1Type;82 elem->Object = Object;83 91 84 92 // ShellCommand<T>* newCommand = new ShellCommand<T>(commandName, classID, object, functionPointer, paramCount, parameters); 85 93 } 86 94 }
Note: See TracChangeset
for help on using the changeset viewer.