Changeset 5551 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- Nov 12, 2005, 12:56:32 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.h
r5391 r5551 226 226 } 227 227 228 /////////////////////// 229 // FUNCTION POINTERS // 230 /////////////////////// 231 #define ShellCommandFunctionPoiter0() \ 232 void SHELLCOMMANDINCLASS(*functionPointer_0)(); 233 234 #define ShellCommandFunctionPoiter1(t1) \ 235 void SHELLCOMMANDINCLASS(*functionPointer_1_##t1)(t1##_TYPE); 236 237 #define ShellCommandFunctionPoiter2(t1, t2) \ 238 void SHELLCOMMANDINCLASS(*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); 239 240 241 #define ShellCommandFunctionPoiter3(t1, t2, t3) \ 242 void SHELLCOMMANDINCLASS(*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); 243 244 #define ShellCommandFunctionPoiter4(t1, t2, t3, t4) \ 245 void SHELLCOMMANDINCLASS(*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); 246 247 248 #define ShellCommandFunctionPoiter5(t1, t2, t3, t4, t5) \ 249 void SHELLCOMMANDINCLASS(*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \ 250 251 228 252 ////////////////// 229 253 // CONSTRUCTORS // … … 231 255 //! creates a command that takes no parameters 232 256 #define ShellCommandConstructor0() \ 233 void SHELLCOMMANDINCLASS(*functionPointer_0)(); \234 257 SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)()) \ 235 258 : ShellCommandBase(commandName, className, 0) \ 236 259 { \ 237 260 this->functorType = SHELLCOMMANDTYPE; \ 238 this->f unctionPointer_0 = function; \261 this->fp.functionPointer_0 = function; \ 239 262 } 240 263 241 264 //! creates a command that takes one parameter 242 265 #define ShellCommandConstructor1(t1) \ 243 void SHELLCOMMANDINCLASS(*functionPointer_1_##t1)(t1##_TYPE); \244 266 SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE), t1##_TYPE d1) \ 245 267 : ShellCommandBase(commandName, className, 1, t1##_PARAM, d1) \ 246 268 { \ 247 269 this->functorType = SHELLCOMMANDTYPE; \ 248 this->f unctionPointer_1_##t1 = function; \270 this->fp.functionPointer_1_##t1 = function; \ 249 271 } 250 272 251 273 //! creates a command that takes two parameters 252 274 #define ShellCommandConstructor2(t1,t2) \ 253 void SHELLCOMMANDINCLASS(*functionPointer_2_##t1##_##t2)(t1##_TYPE, t2##_TYPE); \254 275 SHELLCOMMAND(const char* commandName, const char* className, void SHELLCOMMANDINCLASS(*function)(t1##_TYPE, t2##_TYPE), t1##_TYPE d1, t2##_TYPE d2) \ 255 276 : ShellCommandBase(commandName, className, 2, t1##_PARAM, d1, t2##_PARAM, d2) \ 256 277 { \ 257 278 this->functorType = SHELLCOMMANDTYPE; \ 258 this->f unctionPointer_2_##t1##_##t2 = function; \279 this->fp.functionPointer_2_##t1##_##t2 = function; \ 259 280 } 260 281 261 282 //! creates a command that takes three parameter 262 283 #define ShellCommandConstructor3(t1,t2,t3) \ 263 void SHELLCOMMANDINCLASS(*functionPointer_3_##t1##_##t2##_##t3)(t1##_TYPE, t2##_TYPE, t3##_TYPE); \264 284 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) \ 265 285 : ShellCommandBase(commandName, className, 3, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3) \ 266 286 { \ 267 287 this->functorType = SHELLCOMMANDTYPE; \ 268 this->f unctionPointer_3_##t1##_##t2##_##t3 = function; \288 this->fp.functionPointer_3_##t1##_##t2##_##t3 = function; \ 269 289 } 270 290 271 291 //! creates a command that takes four parameter 272 292 #define ShellCommandConstructor4(t1,t2,t3,t4) \ 273 void SHELLCOMMANDINCLASS(*functionPointer_4_##t1##_##t2##_##t3##_##t4)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE); \274 293 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) \ 275 294 : ShellCommandBase(commandName, className, 4, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4) \ 276 295 { \ 277 296 this->functorType = SHELLCOMMANDTYPE; \ 278 this->f unctionPointer_4_##t1##_##t2##_##t3##_##t4 = function; \297 this->fp.functionPointer_4_##t1##_##t2##_##t3##_##t4 = function; \ 279 298 } 280 299 281 300 //! creates a command that takes five parameter 282 301 #define ShellCommandConstructor5(t1,t2,t3,t4,t5) \ 283 void SHELLCOMMANDINCLASS(*functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_TYPE, t2##_TYPE, t3##_TYPE, t4##_TYPE, t5##_TYPE); \284 302 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) \ 285 303 : ShellCommandBase(commandName, className, 5, t1##_PARAM, d1, t2##_PARAM, d2, t3##_PARAM, d3, t4##_PARAM, d4, t5##_PARAM, d5) \ 286 304 { \ 287 305 this->functorType = SHELLCOMMANDTYPE; \ 288 this->f unctionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5 = function; \306 this->fp.functionPointer_5_##t1##_##t2##_##t3##_##t4##_##t5 = function; \ 289 307 } 290 308 … … 337 355 #undef SHELLCOMMANDEXECUTER 338 356 #endif 339 #define SHELLCOMMANDEXECUTER(nameExt) (dynamic_cast<T*>(object)->* functionPointer##nameExt)357 #define SHELLCOMMANDEXECUTER(nameExt) (dynamic_cast<T*>(object)->*(fp.functionPointer##nameExt)) 340 358 #ifdef SHELLCOMMANDINCLASS 341 359 #undef SHELLCOMMANDINCLASS … … 353 371 354 372 private: 373 //! FUNCTOR_LIST is the List of FunctionPointers 374 union FunctionPointers { 375 #define FUNCTOR_LIST(x) ShellCommandFunctionPoiter ## x 376 #include "functor_list.h" 377 #undef FUNCTOR_LIST 378 } fp; 379 355 380 //! FUNCTOR_LIST is the List of CommandConstructors 356 381 #define FUNCTOR_LIST(x) ShellCommandConstructor ## x … … 382 407 #undef SHELLCOMMANDEXECUTER 383 408 #endif 384 #define SHELLCOMMANDEXECUTER(nameExt) f unctionPointer##nameExt409 #define SHELLCOMMANDEXECUTER(nameExt) fp.functionPointer##nameExt 385 410 #ifdef SHELLCOMMANDINCLASS 386 411 #undef SHELLCOMMANDINCLASS … … 398 423 399 424 private: 425 //! FUNCTOR_LIST is the List of FunctionPointers 426 union FunctionPointers { 427 #define FUNCTOR_LIST(x) ShellCommandFunctionPoiter ## x 428 #include "functor_list.h" 429 #undef FUNCTOR_LIST 430 } fp; 431 400 432 //! FUNCTOR_LIST is the List of CommandConstructors 401 433 #define FUNCTOR_LIST(x) ShellCommandConstructor ## x
Note: See TracChangeset
for help on using the changeset viewer.