Changeset 5327 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Oct 8, 2005, 9:52:13 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r5326 r5327 211 211 { 212 212 ShellCommandClass::commandClassList = new tList<ShellCommandClass>; 213 ShellCommand<ShellCommandBase>::registerCommand("debug", "ShellCommand", &ShellCommandBase::debugDyn);213 // ShellCommandStatic<ShellCommandBase>::registerCommand("debug", "ShellCommand", &ShellCommandBase::debug); 214 214 } 215 215 } -
trunk/src/lib/shell/shell_command.h
r5326 r5327 148 148 // SHELLCOMMAND can be redefined as ShellCommand or ShellCommandStatic 149 149 // SHELLCOMMANDEXECUTER can be redefined too. 150 // SHELLCOMMANDINCLASS 150 151 //! registers a command without any parameters 151 152 #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)()) \ 153 154 { \ 154 155 if (isRegistered(commandName, className, 0)== true) \ 155 156 return NULL; \ 156 return new S hellCommand<T>(commandName, className, function); \157 return new SHELLCOMMAND<T>(commandName, className, function); \ 157 158 } 158 159 159 160 //! registers a command with 1 parameter 160 161 #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) \ 162 163 { \ 163 164 if (isRegistered(commandName, className, 1, t1##_PARAM)== true) \ 164 165 return NULL; \ 165 return new S hellCommand<T>(commandName, className, function, d1); \166 return new SHELLCOMMAND<T>(commandName, className, function, d1); \ 166 167 } 167 168 168 169 //! registers a command with 2 parameters 169 170 #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) \ 171 172 { \ 172 173 if (isRegistered(commandName, className, 2, t1##_PARAM, t2##_PARAM)== true) \ 173 174 return NULL; \ 174 return new S hellCommand<T>(commandName, className, function, d1, d2); \175 return new SHELLCOMMAND<T>(commandName, className, function, d1, d2); \ 175 176 } 176 177 177 178 //! registers a command with 3 parameters 178 179 #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) \ 180 181 { \ 181 182 if (isRegistered(commandName, className, 3, t1##_PARAM, t2##_PARAM, t3##_PARAM)== true) \ 182 183 return NULL; \ 183 return new S hellCommand<T>(commandName, className, function, d1, d2, d3); \184 return new SHELLCOMMAND<T>(commandName, className, function, d1, d2, d3); \ 184 185 } 185 186 186 187 //! registers a command with 4 parameters 187 188 #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) \ 189 190 { \ 190 191 if (isRegistered(commandName, className, 4, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM)== true) \ 191 192 return NULL; \ 192 return new S hellCommand<T>(commandName, className, function, d1, d2, d3, d4); \193 return new SHELLCOMMAND<T>(commandName, className, function, d1, d2, d3, d4); \ 193 194 } 194 195 195 196 //! registers a command with 5 parameters 196 197 #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) \ 198 199 { \ 199 200 if (isRegistered(commandName, className, 5, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM, t5##_PARAM)== true) \ … … 207 208 //! creates a command that takes no parameters 208 209 #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)()) \ 211 212 : ShellCommandBase(commandName, className, 0) \ 212 213 { \ … … 216 217 //! creates a command that takes one parameter 217 218 #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) \ 220 221 : ShellCommandBase(commandName, className, 1, t1##_PARAM, d1) \ 221 222 { \ … … 225 226 //! creates a command that takes two parameters 226 227 #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) \ 229 230 : ShellCommandBase(commandName, className, 2, t1##_PARAM, d1, t2##_PARAM, d2) \ 230 231 { \ … … 234 235 //! creates a command that takes three parameter 235 236 #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) \ 238 239 : ShellCommandBase(commandName, className, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \ 239 240 { \ … … 243 244 //! creates a command that takes four parameter 244 245 #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) \ 247 248 : ShellCommandBase(commandName, className, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \ 248 249 { \ … … 252 253 //! creates a command that takes five parameter 253 254 #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) \ 256 257 : ShellCommandBase(commandName, className, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \ 257 258 { \ … … 303 304 #undef SHELLCOMMAND 304 305 #endif 305 #define SHELLCOMMAND ShellCommand306 #define SHELLCOMMAND ShellCommand 306 307 #ifdef SHELLCOMMANDEXECUTER 307 308 #undef SHELLCOMMANDEXECUTER 308 309 #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) 310 315 311 316 //! FUNCTOR_LIST is the List of command-registerers … … 331 336 }; 332 337 338 //! keeps information about a ShellCommand, that points to a Static Function 333 339 template<class T> class ShellCommandStatic : public ShellCommandBase 334 340 { … … 345 351 #endif 346 352 #define SHELLCOMMANDEXECUTER(nameExt) T::functionPointer##nameExt 353 #ifdef SHELLCOMMANDINCLASS 354 #undef SHELLCOMMANDINCLASS 355 #endif 356 #define SHELLCOMMANDINCLASS(FUNCTION) (FUNCTION) 347 357 348 358 //! FUNCTOR_LIST is the List of command-registerers
Note: See TracChangeset
for help on using the changeset viewer.