Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickup3/src/libraries/core/Super.h @ 6514

Last change on this file since 6514 was 6466, checked in by dafrick, 15 years ago

Lots of things done in pickups module. Compiles, but it seems, that I've also introduced an error preventing steering of the spaceship.

  • Property svn:eol-style set to native
File size: 26.1 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @brief Definition of all super-function related macros.
32
33    This file defines all macros needed to add a new "super-function".
34    If you add a super-function, you can call SUPER(myclass, functionname) inside your
35    code and the function of the parentclass gets called. This is comparable with
36    super.functionname() in Java or other languages.
37
38    This works only with virtual functions that return nothing (void) and belong to
39    classes that have an Identifier. Arguments however are supported.
40
41    To add a new super-function, you have process 4 steps:
42
43    1) Add a new SUPER macro
44       This allows you to call the super-function in your code.
45       Location: This file (Super.h), marked with --> HERE <-- comments (1/3)
46
47    2) Call the SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros.
48       This defines some global classes and templates, needed to create and call the super-functions.
49       Location: This file (Super.h), marked with --> HERE <-- comments (2/3)
50
51    3) Call the SUPER_INTRUSIVE_DECLARATION macro.
52       This will be included into the declaration of ClassIdentifier<T>.
53       Location: This file (Super.h), marked with --> HERE <-- comments (3/3)
54
55    4) Call the SUPER_FUNCTION macro.
56       This defines a partially specialized template that will decide if a class is "super" to another class.
57       If the check returns true, a SuperFunctionCaller gets created, which will be used by the SUPER macro.
58       You have to add this into the header-file of the baseclass of the super-function (the class that first
59       implements the function), below the class declaration. You can't call it directly in this file, because
60       otherwise you had to include the headerfile right here, which would cause some ugly backdependencies,
61       include loops and slower compilation.
62       Dont forget to include Super.h in the header-file.
63       Location: The header-file of the baseclass (Baseclass.h), below the class declaration
64*/
65
66#ifndef _Super_H__
67#define _Super_H__
68
69#include "CorePrereqs.h"
70
71#include "util/Debug.h"
72#include "Event.h"
73
74///////////////////////
75// Macro definitions //
76///////////////////////
77
78//// Common macros ////
79
80    /**
81        @brief Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.
82        @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
83        @param baseclass The baseclass of the super-function (~the root)
84        @param functionname The name of the super-function
85        @param purevirtualbase "true" if the function is pure virtual in the baseclass, "false" if the function is implemented (without "")
86    */
87    #define SUPER_FUNCTION(functionnumber, baseclass, functionname, purevirtualbase) \
88        template <class T, int templatehack2> \
89        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2> \
90        { \
91            static void check() \
92            { \
93                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>(0)); \
94                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check(); \
95            } \
96            \
97            static void apply(void* temp) {} \
98            \
99            static void apply(baseclass* temp) \
100            { \
101                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \
102                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
103                { \
104                    if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
105                    { \
106                        delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; \
107                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; \
108                        ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \
109                    } \
110                    \
111                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
112                    { \
113                        COUT(5) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \
114                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
115                    } \
116                } \
117            } \
118        }; \
119        \
120        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase(functionnumber, baseclass)
121
122    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
123    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
124    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
125    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass) \
126        template <int templatehack2> \
127        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
128        { \
129            static void check() \
130            { \
131                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
132            } \
133        };
134
135
136    /*
137    //// Comments about the macro ////
138
139        // Partially specialized template (templatehack is now specialized too).
140        //
141        // This ensures the compiler takes THIS template if the header-file of the super-function
142        // is included. In any other case, the compiler just uses the fallback template which is
143        // defined in this file.
144        template <class T, templatehack2>
145        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2>
146        {
147            static void check()
148            {
149                // This call to the apply-function is the whole check. By calling the function with
150                // a T* pointer, the right function get's called.
151                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply(static_cast<T*>(0));
152
153                // Go go the check for of next super-function (functionnumber + 1)
154                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check();
155            }
156
157            // This function gets called if T is not a child of the baseclass.
158            // The function does nothing.
159            static void apply(void* temp) {}
160
161            // This function gets called if T is a child of the baseclass and can therefore be converted.
162            // The function adds a SuperFunctionCaller to the Identifier of all subclasses of T.
163            static void apply(baseclass* temp)
164            {
165                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
166
167                // Iterate through all children
168                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
169                {
170                    // Check if the caller is a fallback-caller
171                    if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
172                    {
173                        // Delete the fallback caller an prepare to get a real caller
174                        delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_;
175                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0;
176                        ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false;
177                    }
178
179                    // Check if there's not already a caller
180                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
181                    {
182                        // Add the SuperFunctionCaller
183                        COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;
184                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
185                    }
186                }
187            }
188        };
189        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase
190
191
192        // The following piece of code is only added if purevirtualbase = true
193
194        // Explicit specialization of the Condition template for the baseclass to avoid
195        // errors if the function is pure virtual in the baseclass.
196        template <int templatehack2> \
197        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
198        { \
199            // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1)
200            static void check() \
201            { \
202                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
203            } \
204        };
205    */
206
207    // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent of classname
208    #ifdef ORXONOX_COMPILER_MSVC
209        #define SUPER(classname, functionname, ...) \
210            __super::functionname(__VA_ARGS__)
211    #else
212        #define SUPER(classname, functionname, ...) \
213            SUPER_##functionname(classname, functionname, __VA_ARGS__)
214    #endif
215
216    // helper macro: for functions without arguments
217    #define SUPER_NOARGS(classname, functionname) \
218        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
219
220    // helper macro: for functions with arguments
221    #define SUPER_ARGS(classname, functionname, ...) \
222        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)
223
224
225//// Function-specific macros ////
226
227    /*
228        Add a macro for each super-function
229
230        Example (no arguments):
231        #define SUPER_myfunction(classname, functionname, ...) \
232            SUPER_NOARGS(classname, functionname)
233
234        Example (with arguments):
235        #define SUPER_myfunction(classname, functionname, ...) \
236            SUPER_ARGS(classname, functionname, __VA_ARGS__)
237    */
238
239    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
240    #define SUPER_XMLPort(classname, functionname, ...) \
241        SUPER_ARGS(classname, functionname, __VA_ARGS__)
242
243    #define SUPER_tick(classname, functionname, ...) \
244        SUPER_ARGS(classname, functionname, __VA_ARGS__)
245
246    #define SUPER_changedActivity(classname, functionname, ...) \
247        SUPER_NOARGS(classname, functionname)
248
249    #define SUPER_changedVisibility(classname, functionname, ...) \
250        SUPER_NOARGS(classname, functionname)
251
252    #define SUPER_XMLEventPort(classname, functionname, ...) \
253        SUPER_ARGS(classname, functionname, __VA_ARGS__)
254
255    #define SUPER_changedScale(classname, functionname, ...) \
256        SUPER_NOARGS(classname, functionname)
257
258    #define SUPER_changedOwner(classname, functionname, ...) \
259        SUPER_NOARGS(classname, functionname)
260
261    #define SUPER_changedOverlayGroup(classname, functionname, ...) \
262        SUPER_NOARGS(classname, functionname)
263
264    #define SUPER_changedName(classname, functionname, ...) \
265        SUPER_NOARGS(classname, functionname)
266
267    #define SUPER_changedGametype(classname, functionname, ...) \
268        SUPER_NOARGS(classname, functionname)
269       
270    #define SUPER_changedUsed(classname, functionname, ...) \
271        SUPER_NOARGS(classname, functionname)
272       
273    #define SUPER_clone(classname, functionname, ...) \
274        SUPER_ARGS(classname, functionname, __VA_ARGS__)
275       
276    #define SUPER_changedCarrier(classname, functionname, ...) \
277        SUPER_NOARGS(classname, functionname)
278       
279    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
280
281
282namespace orxonox
283{
284    /////////////////////////////////////////////////////////////////////////////////////////////////////
285    // This code gets included by Identifier.h and every other header file that needs a super-function //
286    /////////////////////////////////////////////////////////////////////////////////////////////////////
287
288    //// Common code ////
289
290        // Base templates
291        /**
292            @brief Creates the SuperFunctionCaller if T is a child of the super-functions baseclass.
293        */
294        template <int functionnumber, class T, int templatehack1, int templatehack2>
295        struct SuperFunctionCondition
296        {
297            static void check() {}
298        };
299
300        /**
301            @brief Initializes the SuperFunctionCaller-pointer with zero.
302        */
303        template <int functionnumber, class T>
304        struct SuperFunctionInitialization
305        {
306            static void initialize(ClassIdentifier<T>* identifier) {}
307        };
308
309        /**
310            @brief Deletes the SuperFunctionCaller.
311        */
312        template <int functionnumber, class T>
313        struct SuperFunctionDestruction
314        {
315            static void destroy(ClassIdentifier<T>* identifier) {}
316        };
317
318
319    //// Function-specific code ////
320
321        /**
322            @brief Creates the needed objects and templates to call a super-function.
323            @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
324            @param functionname The name of the super-function
325            @param hasarguments "false" if the function doesn't take any arguments, "true" if it does (without "")
326            @param ... Variadic: If the function takes arguments, add them here with type and name. Example: int myvalue, float myothervalue
327        */
328        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(functionnumber, functionname, hasarguments, ...) \
329            template <class T, int templatehack1, int templatehack2> \
330            struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2> \
331            { \
332                static void check() \
333                { \
334                    SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check(); \
335                } \
336            }; \
337            \
338            class _CoreExport SuperFunctionCaller_##functionname \
339            { \
340                public: \
341                    virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
342                    virtual ~SuperFunctionCaller_##functionname () {} \
343            }; \
344            \
345            template <class T> \
346            class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname \
347            { \
348                public: \
349                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
350                    { \
351                    } \
352            }; \
353            \
354            template <class T> \
355            struct SuperFunctionInitialization<functionnumber, T> \
356            { \
357                static void initialize(ClassIdentifier<T>* identifier) \
358                { \
359                    identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \
360                    identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \
361                    SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \
362                } \
363            }; \
364            \
365            template <class T> \
366            struct SuperFunctionDestruction<functionnumber, T> \
367            { \
368                static void destroy(ClassIdentifier<T>* identifier) \
369                { \
370                    if (identifier->superFunctionCaller_##functionname##_) \
371                        delete identifier->superFunctionCaller_##functionname##_; \
372                    SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); \
373                } \
374            }; \
375            \
376            template <class T> \
377            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
378            { \
379                public: \
380                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
381                    { \
382                        (dynamic_cast<T*>(object))->T:: functionname
383
384        /*
385            JUST ADD THE FUNCTION ARGUMENTS BETWEEN BOTH MACROS, ENCLOSED BY BRACKETS
386            EXAMPLE:
387
388              SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, myfunction, true, int myvalue, float myothervalue) <-- !!! DONT ADD A SEMICOLON HERE !!!
389                (myvalue, myothervalue)
390              SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
391        */
392
393        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2 \
394                                                        ; \
395                    } \
396            };
397
398        #define SUPER_CALL_ARGUMENTSfalse(...) OrxonoxClass* object
399        #define SUPER_CALL_ARGUMENTS0(...)     OrxonoxClass* object
400        #define SUPER_CALL_ARGUMENTStrue(...) OrxonoxClass* object, __VA_ARGS__
401        #define SUPER_CALL_ARGUMENTS1(...)    OrxonoxClass* object, __VA_ARGS__
402
403
404    /*
405    //// COMMENTS ABOUT THE MACRO ////
406
407        // Partially specialized template (templatehack not yet specialized, this
408        // will be done by the real condition in the header-file of the super-function)
409        // Only used as fallback
410        template <class T, int templatehack1, int templatehack2>
411        struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2>
412        {
413            // If this function gets called, the header-file of the super function is not
414            // included, so this fallback template (templatehack not specialized) is used
415            static void check()
416            {
417                // Calls the condition-check of the next super-function (functionnumber + 1)
418                SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check();
419            }
420        };
421
422        // Baseclass of the super-function caller. The real call will be done by a
423        // templatized subclass through the virtual () operator.
424        class _CoreExport SuperFunctionCaller_##functionname
425        {
426            public:
427                virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
428                virtual ~SuperFunctionCaller_##functionname () {}
429        };
430
431        // Fallback if the base is pure virtual
432        template <class T>
433        class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname
434        {
435            public:
436                // Fallback does nothing
437                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
438                {
439                }
440        };
441
442        // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual
443        template <class T>
444        struct SuperFunctionInitialization<functionnumber, T>
445        {
446            static void initialize(ClassIdentifier<T>* identifier)
447            {
448                identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>;
449                identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true;
450
451                // Calls the initialization of the next super-function (functionnumber + 1)
452                SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier);
453            }
454        };
455
456        // Deletes the SuperFunctionCaller.
457        template <class T>
458        struct SuperFunctionDestruction<functionnumber, T>
459        {
460            static void destroy(ClassIdentifier<T>* identifier)
461            {
462                if (identifier->superFunctionCaller_##functionname##_)
463                    delete identifier->superFunctionCaller_##functionname##_;
464
465                // Calls the destruction of the next super-function (functionnumber + 1)
466                SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier);
467            }
468        };
469
470        // The real super-function caller: Calls T::functionname()
471        // T should be the parent, but this will be done by the spezialized condition template
472        template <class T>
473        class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname
474        {
475            public:
476                // @brief Calls the function.
477                // @param object The object to call the function on
478                // @param ... The arguments of the function
479                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
480                {
481                    (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
482                }
483        }
484    */
485
486
487    //// Execute the code for each super-function ////
488
489        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
490        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, XMLPort, true, Element& xmlelement, XMLPort::Mode mode)
491            (xmlelement, mode)
492        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
493
494        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(1, tick, true, float dt)
495            (dt)
496        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
497
498        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(2, changedActivity, false)
499            ()
500        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
501
502        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(3, changedVisibility, false)
503            ()
504        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
505
506        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, XMLEventPort, true, Element& xmlelement, XMLPort::Mode mode)
507            (xmlelement, mode)
508        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
509
510        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(5, changedScale, false)
511            ()
512        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
513
514        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedOwner, false)
515            ()
516        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
517
518        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOverlayGroup, false)
519            ()
520        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
521
522        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedName, false)
523            ()
524        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
525
526        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
527            ()
528        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
529       
530        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
531            ()
532        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
533
534        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, clone, true, OrxonoxClass* item)
535            (item)
536        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
537       
538        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedCarrier, false)
539            ()
540        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
541
542        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
543
544}
545
546#else /* _Super_H__ */
547  #ifdef SUPER_INTRUSIVE_DECLARATION_INCLUDE
548
549//////////////////////////////////////////////////////////////////////////
550// This code gets included within the declaration of ClassIdentifier<T> //
551//////////////////////////////////////////////////////////////////////////
552
553//// Common code ////
554
555    private:
556
557        template <int functionnumber, class TT, int templatehack1, int templatehack2>
558        friend struct SuperFunctionCondition;
559
560        // Creates the super-function-callers by calling the first SuperFunctionCondition check
561        // This get's called within the initialization of an Identifier
562        virtual void createSuperFunctionCaller() const
563        {
564            SuperFunctionCondition<0, T, 0, 0>::check();
565        }
566
567
568//// Function-specific code ////
569
570    public:
571        /**
572            @brief Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.
573            @param functionname The name of the super-function
574        */
575        #ifndef SUPER_INTRUSIVE_DECLARATION
576          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
577            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \
578            bool bSuperFunctionCaller_##functionname##_isFallback_
579        #endif
580
581
582//// Execute the code for each super-function ////
583
584    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
585    SUPER_INTRUSIVE_DECLARATION(XMLPort);
586    SUPER_INTRUSIVE_DECLARATION(tick);
587    SUPER_INTRUSIVE_DECLARATION(changedActivity);
588    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
589    SUPER_INTRUSIVE_DECLARATION(XMLEventPort);
590    SUPER_INTRUSIVE_DECLARATION(changedScale);
591    SUPER_INTRUSIVE_DECLARATION(changedOwner);
592    SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
593    SUPER_INTRUSIVE_DECLARATION(changedName);
594    SUPER_INTRUSIVE_DECLARATION(changedGametype);
595    SUPER_INTRUSIVE_DECLARATION(changedUsed);
596    SUPER_INTRUSIVE_DECLARATION(clone);
597    SUPER_INTRUSIVE_DECLARATION(changedCarrier);
598    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
599
600
601    #undef SUPER_INTRUSIVE_DECLARATION_INCLUDE
602  #endif /* SUPER_INTRUSIVE_DECLARATION_INCLUDE */
603#endif /* _Super_H__ */
Note: See TracBrowser for help on using the repository browser.