Changeset 5326 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Oct 8, 2005, 9:18:12 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r5249 r5326 432 432 // long completeType = SHELLC_NONE; //< the Type we'd like to complete. 433 433 SubString inputSplits(executionString, true); 434 435 printf("!!!!%s!!!\n", executionString);436 434 437 435 if (inputSplits.getCount() == 0) -
trunk/src/lib/shell/shell_command.h
r5279 r5326 127 127 /////////////////////////////////////////////////// 128 128 129 /////////////////////// 130 // MACRO DEFINITION S //131 /////////////////////// 129 ///////////////////////////////// 130 // MACRO DEFINITION EXTENSIONS // 131 ///////////////////////////////// 132 132 //! where to chek for default BOOL values 133 133 #define l_BOOL_DEFGRAB(i) this->defaultBools[i] … … 146 146 // COMMAND REGISTRATION // 147 147 ////////////////////////// 148 // SHELLCOMMAND can be redefined as ShellCommand or ShellCommandStatic 149 // SHELLCOMMANDEXECUTER can be redefined too. 148 150 //! registers a command without any parameters 149 151 #define ShellCommandRegister0() \ 150 static S hellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)()) \152 static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)()) \ 151 153 { \ 152 154 if (isRegistered(commandName, className, 0)== true) \ … … 157 159 //! registers a command with 1 parameter 158 160 #define ShellCommandRegister1(t1) \ 159 static S hellCommand<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \161 static SHELLCOMMAND<T>* registerCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1 = t1##_DEFAULT) \ 160 162 { \ 161 163 if (isRegistered(commandName, className, 1, t1##_PARAM)== true) \ … … 166 168 //! registers a command with 2 parameters 167 169 #define ShellCommandRegister2(t1,t2) \ 168 static S hellCommand<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) \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) \ 169 171 { \ 170 172 if (isRegistered(commandName, className, 2, t1##_PARAM, t2##_PARAM)== true) \ … … 175 177 //! registers a command with 3 parameters 176 178 #define ShellCommandRegister3(t1,t2,t3) \ 177 static S hellCommand<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) \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) \ 178 180 { \ 179 181 if (isRegistered(commandName, className, 3, t1##_PARAM, t2##_PARAM, t3##_PARAM)== true) \ … … 184 186 //! registers a command with 4 parameters 185 187 #define ShellCommandRegister4(t1,t2,t3,t4) \ 186 static S hellCommand<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) \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) \ 187 189 { \ 188 190 if (isRegistered(commandName, className, 4, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM)== true) \ … … 193 195 //! registers a command with 5 parameters 194 196 #define ShellCommandRegister5(t1,t2,t3,t4,t5) \ 195 static S hellCommand<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) \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) \ 196 198 { \ 197 199 if (isRegistered(commandName, className, 5, t1##_PARAM, t2##_PARAM, t3##_PARAM, t4##_PARAM, t5##_PARAM)== true) \ … … 206 208 #define ShellCommandConstructor0() \ 207 209 void (T::*functionPointer_0)(); \ 208 S hellCommand(const char* commandName, const char* className, void (T::*function)()) \210 SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)()) \ 209 211 : ShellCommandBase(commandName, className, 0) \ 210 212 { \ … … 215 217 #define ShellCommandConstructor1(t1) \ 216 218 void (T::*functionPointer_1_##t1)(t1##_TYPE); \ 217 S hellCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1) \219 SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE), t1##_TYPE d1) \ 218 220 : ShellCommandBase(commandName, className, 1, t1##_PARAM, d1) \ 219 221 { \ … … 224 226 #define ShellCommandConstructor2(t1,t2) \ 225 227 void (T::*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \ 226 S hellCommand(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \228 SHELLCOMMAND(const char* commandName, const char* className, void (T::*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \ 227 229 : ShellCommandBase(commandName, className, 2, t1##_PARAM, d1, t2##_PARAM, d2) \ 228 230 { \ … … 233 235 #define ShellCommandConstructor3(t1,t2,t3) \ 234 236 void (T::*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \ 235 S hellCommand(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 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) \ 236 238 : ShellCommandBase(commandName, className, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \ 237 239 { \ … … 242 244 #define ShellCommandConstructor4(t1,t2,t3,t4) \ 243 245 void (T::*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \ 244 S hellCommand(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 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) \ 245 247 : ShellCommandBase(commandName, className, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \ 246 248 { \ … … 251 253 #define ShellCommandConstructor5(t1,t2,t3,t4,t5) \ 252 254 void (T::*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \ 253 S hellCommand(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 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) \ 254 256 : ShellCommandBase(commandName, className, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \ 255 257 { \ … … 263 265 #define ShellCommandExecute0() \ 264 266 if (this->paramCount == 0) \ 265 (dynamic_cast<T*>(object)->*functionPointer_0)()267 SHELLCOMMANDEXECUTER(_0)() 266 268 267 269 //! execute-macro for functions with one parameter 268 270 #define ShellCommandExecute1(t1) \ 269 271 else if (this->paramCount == 1 && this->parameters[0] == t1##_PARAM) \ 270 (dynamic_cast<T*>(object)->*functionPointer_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0)))272 SHELLCOMMANDEXECUTER(_1_##t1)(t1##_FUNC(parameters, t1##_DEFGRAB(0))) 271 273 272 274 //! execute-macro for functions with two parameters 273 275 #define ShellCommandExecute2(t1,t2) \ 274 276 else if (this->paramCount == 2 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM) \ 275 (dynamic_cast<T*>(object)->*functionPointer_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))277 SHELLCOMMANDEXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1))) 276 278 277 279 //! execute-macro for functions with three parameters 278 280 #define ShellCommandExecute3(t1,t2,t3) \ 279 281 else if (this->paramCount == 3 && this->parameters[0] == t1##_PARAM && this->parameters[1] == t2##_PARAM && this->parameters[2] == t3##_PARAM) \ 280 (dynamic_cast<T*>(object)->*functionPointer_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)))282 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))) 281 283 282 284 //! execute-macro for functions with four parameters 283 285 #define ShellCommandExecute4(t1,t2,t3,t4) \ 284 286 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) \ 285 (dynamic_cast<T*>(object)->*functionPointer_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)))287 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))) 286 288 287 289 //! execute-macro for functions with five parameters 288 290 #define ShellCommandExecute5(t1,t2,t3,t4,t5) \ 289 291 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) \ 290 (dynamic_cast<T*>(object)->*functionPointer_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)))292 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))) 291 293 292 294 … … 295 297 { 296 298 public: 297 298 299 #ifdef FUNCTOR_LIST 299 300 #undef FUNCTOR_LIST 300 301 #endif 302 #ifdef SHELLCOMMAND 303 #undef SHELLCOMMAND 304 #endif 305 #define SHELLCOMMAND ShellCommand 306 #ifdef SHELLCOMMANDEXECUTER 307 #undef SHELLCOMMANDEXECUTER 308 #endif 309 #define SHELLCOMMANDEXECUTER(nameExt) (dynamic_cast<T*>(object)->*functionPointer##nameExt) 301 310 302 311 //! FUNCTOR_LIST is the List of command-registerers … … 314 323 virtual void executeCommand (BaseObject* object, const char* parameters) 315 324 { 316 // if (parameters != NULL)317 325 SubString sub(parameters, true); 326 //! FUNCTOR_LIST is the List of Executive Functions 327 #define FUNCTOR_LIST(x) ShellCommandExecute ## x 328 #include "functor_list.h" 329 #undef FUNCTOR_LIST 330 } 331 }; 332 333 template<class T> class ShellCommandStatic : public ShellCommandBase 334 { 335 public: 336 #ifdef FUNCTOR_LIST 337 #undef FUNCTOR_LIST 338 #endif 339 #ifdef SHELLCOMMAND 340 #undef SHELLCOMMAND 341 #endif 342 #define SHELLCOMMAND ShellCommandStatic 343 #ifdef SHELLCOMMANDEXECUTER 344 #undef SHELLCOMMANDEXECUTER 345 #endif 346 #define SHELLCOMMANDEXECUTER(nameExt) T::functionPointer##nameExt 347 348 //! FUNCTOR_LIST is the List of command-registerers 349 #define FUNCTOR_LIST(x) ShellCommandRegister ## x 350 #include "functor_list.h" 351 #undef FUNCTOR_LIST 352 353 private: 354 //! FUNCTOR_LIST is the List of CommandConstructors 355 #define FUNCTOR_LIST(x) ShellCommandConstructor ## x 356 #include "functor_list.h" 357 #undef FUNCTOR_LIST 358 359 virtual void executeCommand (BaseObject* object, const char* parameters) 360 { 361 SubString sub(parameters, true); 318 362 //! FUNCTOR_LIST is the List of Executive Functions 319 363 #define FUNCTOR_LIST(x) ShellCommandExecute ## x
Note: See TracChangeset
for help on using the changeset viewer.