Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ois_update/src/libraries/core/Super.h @ 7532

Last change on this file since 7532 was 7532, checked in by rgrieder, 14 years ago

Adding some compiler errors to test OS X stuff

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