Changeset 2485 for code/branches/presentation/src/core/Super.h
- Timestamp:
- Dec 16, 2008, 6:01:13 PM (15 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/src/core/Super.h
r2171 r2485 99 99 \ 100 100 static void apply(void* temp) {} \ 101 \ 101 102 static void apply(baseclass* temp) \ 102 103 { \ … … 104 105 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \ 105 106 { \ 107 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 108 { \ 109 delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; \ 110 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; \ 111 ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \ 112 } \ 113 \ 106 114 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 107 115 { \ … … 163 171 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) 164 172 { 173 // Check if the caller is a fallback-caller 174 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) 175 { 176 // Delete the fallback caller an prepare to get a real caller 177 delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; 178 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; 179 ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; 180 } 181 165 182 // Check if there's not already a caller 166 183 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) … … 183 200 struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \ 184 201 { \ 185 // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)202 // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1) 186 203 static void check() \ 187 204 { \ … … 233 250 #define SUPER_processEvent(classname, functionname, ...) \ 234 251 SUPER_ARGS(classname, functionname, __VA_ARGS__) 252 253 #define SUPER_changedScale(classname, functionname, ...) \ 254 SUPER_NOARGS(classname, functionname) 255 256 #define SUPER_changedMainState(classname, functionname, ...) \ 257 SUPER_NOARGS(classname, functionname) 258 259 #define SUPER_changedOwner(classname, functionname, ...) \ 260 SUPER_NOARGS(classname, functionname) 261 262 #define SUPER_changedOverlayGroup(classname, functionname, ...) \ 263 SUPER_NOARGS(classname, functionname) 264 265 #define SUPER_changedName(classname, functionname, ...) \ 266 SUPER_NOARGS(classname, functionname) 267 268 #define SUPER_changedGametype(classname, functionname, ...) \ 269 SUPER_NOARGS(classname, functionname) 235 270 // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 236 271 … … 292 327 }; \ 293 328 \ 329 class _CoreExport SuperFunctionCaller_##functionname \ 330 { \ 331 public: \ 332 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \ 333 virtual ~SuperFunctionCaller_##functionname () {} \ 334 }; \ 335 \ 336 template <class T> \ 337 class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname \ 338 { \ 339 public: \ 340 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \ 341 { \ 342 } \ 343 }; \ 344 \ 294 345 template <class T> \ 295 346 struct SuperFunctionInitialization<functionnumber, T> \ … … 297 348 static void initialize(ClassIdentifier<T>* identifier) \ 298 349 { \ 299 identifier->superFunctionCaller_##functionname##_ = 0; \ 350 identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \ 351 identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \ 300 352 SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \ 301 353 } \ … … 313 365 }; \ 314 366 \ 315 class _CoreExport SuperFunctionCaller_##functionname \316 { \317 public: \318 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \319 virtual ~SuperFunctionCaller_##functionname () {} \320 }; \321 \322 367 template <class T> \ 323 368 class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \ … … 366 411 }; 367 412 368 // Initializes the SuperFunctionCaller-pointer with zero. 413 // Baseclass of the super-function caller. The real call will be done by a 414 // templatized subclass through the virtual () operator. 415 class _CoreExport SuperFunctionCaller_##functionname 416 { 417 public: 418 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; 419 virtual ~SuperFunctionCaller_##functionname () {} 420 }; 421 422 // Fallback if the base is pure virtual 423 template <class T> 424 class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname 425 { 426 public: 427 // Fallback does nothing 428 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) 429 { 430 } 431 }; 432 433 // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual 369 434 template <class T> 370 435 struct SuperFunctionInitialization<functionnumber, T> … … 372 437 static void initialize(ClassIdentifier<T>* identifier) 373 438 { 374 identifier->superFunctionCaller_##functionname##_ = 0; 439 identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; 440 identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; 375 441 376 442 // Calls the initialization of the next super-function (functionnumber + 1) … … 391 457 SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); 392 458 } 393 };394 395 // Baseclass of the super-function caller. The real call will be done by a396 // templatized subclass through the virtual () operator.397 class _CoreExport SuperFunctionCaller_##functionname398 {399 public:400 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;401 virtual ~SuperFunctionCaller_##functionname () {}402 459 }; 403 460 … … 441 498 (event) 442 499 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 500 501 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(5, changedScale, false) 502 () 503 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 504 505 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedMainState, false) 506 () 507 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 508 509 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOwner, false) 510 () 511 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 512 513 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedOverlayGroup, false) 514 () 515 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 516 517 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedName, false) 518 () 519 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 520 521 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedGametype, false) 522 () 523 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 443 524 // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 444 525 … … 476 557 #ifndef SUPER_INTRUSIVE_DECLARATION 477 558 #define SUPER_INTRUSIVE_DECLARATION(functionname) \ 478 SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_ 559 SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \ 560 bool bSuperFunctionCaller_##functionname##_isFallback_ 479 561 #endif 480 562 … … 488 570 SUPER_INTRUSIVE_DECLARATION(changedVisibility); 489 571 SUPER_INTRUSIVE_DECLARATION(processEvent); 572 SUPER_INTRUSIVE_DECLARATION(changedScale); 573 SUPER_INTRUSIVE_DECLARATION(changedMainState); 574 SUPER_INTRUSIVE_DECLARATION(changedOwner); 575 SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup); 576 SUPER_INTRUSIVE_DECLARATION(changedName); 577 SUPER_INTRUSIVE_DECLARATION(changedGametype); 490 578 // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 491 579
Note: See TracChangeset
for help on using the changeset viewer.