Changeset 5136 in orxonox.OLD for trunk/src/util
- Timestamp:
- Aug 26, 2005, 1:24:02 PM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/shell.cc
r5135 r5136 78 78 //void ShellCommand<T>::registerCommand(const char* commandName, ClassID classID, T* object, void* functionPointer, unsigned int paramCount, ...) 79 79 80 ShellCommand<Shell>::registerCommand("clear", CL_NULL, this, &Shell::clear);80 ShellCommand<Shell>::registerCommand("clear", CL_NULL, &Shell::clear, true); 81 81 } 82 82 -
trunk/src/util/shell_command.h
r5135 r5136 76 76 }; 77 77 78 template<class T> class ShellCommand; 78 79 80 template<class T> class ShellCommandSingleton : public ShellCommandBase 81 { 82 friend class ShellCommand<T>; 83 private: 84 ShellCommandSingleton(const char* commandName, ClassID classID, void (T::*functionPointer)()) 85 : ShellCommandBase (commandName, classID, 0) 86 { 87 this->functionPointer_NULL = functionPointer; 88 89 } 90 void (T::*functionPointer_NULL)(); 91 virtual void executeCommand (const char* parameters) 92 { 93 if (this->paramCount == 0) 94 (T::getInstance()->*functionPointer_NULL)(); 95 } 96 }; 79 97 80 98 … … 85 103 static void unregisterCommand(const char* commandNaame, ClassID classID); 86 104 87 static void registerCommand(const char* commandName, ClassID classID, T* object, void (T::*functionPointer)())105 static void registerCommand(const char* commandName, ClassID classID, void (T::*functionPointer)(), bool isSingleton = false) 88 106 { 89 107 if (isRegistered(commandName, classID, 0)== true) 90 108 return; 91 109 else 92 ShellCommand<T>* newCommand = new ShellCommand<T>(commandName, classID, object, functionPointer); 110 { 111 if (isSingleton == false) 112 new ShellCommand<T>(commandName, classID, functionPointer); 113 else 114 new ShellCommandSingleton<T>(commandName, classID, functionPointer); 115 } 93 116 } 117 94 118 private: 95 119 void (T::*functionPointer_NULL)(); 96 ShellCommand(const char* commandName, ClassID classID, T* object,void (T::*functionPointer)())120 ShellCommand(const char* commandName, ClassID classID, void (T::*functionPointer)()) 97 121 : ShellCommandBase (commandName, classID, 0) 98 122 { 99 123 this->functionPointer_NULL = functionPointer; 100 this->objectPointer = object;101 124 } 102 125 virtual void executeCommand (const char* parameters) 103 126 { 104 if (this->paramCount == 0)105 (objectPointer->*functionPointer_NULL)(); 127 /* if (this->paramCount == 0) 128 (objectPointer->*functionPointer_NULL)();*/ 106 129 } 107 130 … … 114 137 115 138 private: 116 117 118 public: 119 T* objectPointer; //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL ) 139 // T* objectPointer; //!< The pointer to the object to apply this function to (NULL if classID == CL_NULL ) 120 140 }; 121 141
Note: See TracChangeset
for help on using the changeset viewer.