Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/Super.h @ 2798

Last change on this file since 2798 was 2662, checked in by rgrieder, 16 years ago

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 25.3 KB
RevLine 
[1679]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
[1684]29/**
[2171]30    @file
[1684]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
[1687]41    To add a new super-function, you have process 4 steps:
[1684]42
43    1) Add a new SUPER macro
44       This allows you to call the super-function in your code.
[1687]45       Location: This file (Super.h), marked with --> HERE <-- comments (1/3)
[1684]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.
[1687]49       Location: This file (Super.h), marked with --> HERE <-- comments (2/3)
[1684]50
51    3) Call the SUPER_INTRUSIVE_DECLARATION macro.
52       This will be included into the declaration of ClassIdentifier<T>.
[1687]53       Location: This file (Super.h), marked with --> HERE <-- comments (3/3)
[1684]54
[1687]55    4) Call the SUPER_FUNCTION macro.
[1684]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
[1679]66#ifndef _Super_H__
67#define _Super_H__
68
69#include <iostream>
70
[1684]71#include "CorePrereqs.h"
[1679]72
[1684]73#include "util/Debug.h"
[1841]74#include "XMLIncludes.h"
[2087]75#include "Event.h"
[1679]76
[1684]77///////////////////////
78// Macro definitions //
79///////////////////////
80
81//// Common macros ////
82
83    /**
84        @brief Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.
85        @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
86        @param baseclass The baseclass of the super-function (~the root)
87        @param functionname The name of the super-function
88        @param purevirtualbase "true" if the function is pure virtual in the baseclass, "false" if the function is implemented (without "")
89    */
90    #define SUPER_FUNCTION(functionnumber, baseclass, functionname, purevirtualbase) \
91        template <class T, int templatehack2> \
92        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2> \
93        { \
94            static void check() \
95            { \
96                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0); \
97                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check(); \
98            } \
99            \
100            static void apply(void* temp) {} \
[2662]101            \
[1684]102            static void apply(baseclass* temp) \
103            { \
104                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \
105                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
106                { \
[2662]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                    \
[1684]114                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
115                    { \
[1736]116                        COUT(5) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \
[1684]117                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
118                    } \
119                } \
120            } \
121        }; \
122        \
123        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase(functionnumber, baseclass)
124
125    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
126    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
127    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
128    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass) \
129        template <int templatehack2> \
130        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
131        { \
132            static void check() \
133            { \
134                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
135            } \
136        };
137
138
139    /*
140    //// Comments about the macro ////
141
142        // Partially specialized template (templatehack is now specialized too).
143        //
144        // This ensures the compiler takes THIS template if the header-file of the super-function
145        // is included. In any other case, the compiler just uses the fallback template which is
146        // defined in this file.
147        template <class T, templatehack2>
148        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2>
149        {
150            static void check()
151            {
152                // This call to the apply-function is the whole check. By calling the function with
153                // a T* pointer, the right function get's called.
154                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0);
155
156                // Go go the check for of next super-function (functionnumber + 1)
157                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check();
158            }
159
160            // This function gets called if T is not a child of the baseclass.
161            // The function does nothing.
162            static void apply(void* temp) {}
163
164            // This function gets called if T is a child of the baseclass and can therefore be converted.
165            // The function adds a SuperFunctionCaller to the Identifier of all subclasses of T.
166            static void apply(baseclass* temp)
167            {
168                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
169
170                // Iterate through all children
171                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
172                {
[2662]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
[1684]182                    // Check if there's not already a caller
183                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
184                    {
185                        // Add the SuperFunctionCaller
186                        COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;
187                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
188                    }
189                }
190            }
191        };
192        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase
193
194
195        // The following piece of code is only added if purevirtualbase = true
196
197        // Explicit specialization of the Condition template for the baseclass to avoid
198        // errors if the function is pure virtual in the baseclass.
199        template <int templatehack2> \
200        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
201        { \
[2662]202            // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1)
[1684]203            static void check() \
204            { \
205                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
206            } \
207        };
208    */
209
210    // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent of classname
211    #define SUPER(classname, functionname, ...) \
212        SUPER_##functionname(classname, functionname, __VA_ARGS__)
213
214    // helper macro: for functions without arguments
215    #define SUPER_NOARGS(classname, functionname) \
216        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
217
218    // helper macro: for functions with arguments
219    #define SUPER_ARGS(classname, functionname, ...) \
220        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)
221
222
223//// Function-specific macros ////
224
225    /*
226        Add a macro for each super-function
227
228        Example (no arguments):
229        #define SUPER_myfunction(classname, functionname, ...) \
230            SUPER_NOARGS(classname, functionname)
231
232        Example (with arguments):
233        #define SUPER_myfunction(classname, functionname, ...) \
234            SUPER_ARGS(classname, functionname, __VA_ARGS__)
235    */
236
[1687]237    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
[1684]238    #define SUPER_XMLPort(classname, functionname, ...) \
239        SUPER_ARGS(classname, functionname, __VA_ARGS__)
240
241    #define SUPER_tick(classname, functionname, ...) \
242        SUPER_ARGS(classname, functionname, __VA_ARGS__)
243
244    #define SUPER_changedActivity(classname, functionname, ...) \
245        SUPER_NOARGS(classname, functionname)
246
247    #define SUPER_changedVisibility(classname, functionname, ...) \
248        SUPER_NOARGS(classname, functionname)
[2087]249
250    #define SUPER_processEvent(classname, functionname, ...) \
251        SUPER_ARGS(classname, functionname, __VA_ARGS__)
[2662]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)
[1687]270    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
[1684]271
272
[1679]273namespace orxonox
274{
[1684]275    /////////////////////////////////////////////////////////////////////////////////////////////////////
276    // This code gets included by Identifier.h and every other header file that needs a super-function //
277    /////////////////////////////////////////////////////////////////////////////////////////////////////
[1679]278
[1684]279    //// Common code ////
[1679]280
[1687]281        // Base templates
282        /**
283            @brief Creates the SuperFunctionCaller if T is a child of the super-functions baseclass.
284        */
[1684]285        template <int functionnumber, class T, int templatehack1, int templatehack2>
286        struct SuperFunctionCondition
[1679]287        {
[1684]288            static void check() {}
289        };
[1679]290
[1687]291        /**
292            @brief Initializes the SuperFunctionCaller-pointer with zero.
293        */
294        template <int functionnumber, class T>
295        struct SuperFunctionInitialization
296        {
297            static void initialize(ClassIdentifier<T>* identifier) {}
298        };
[1679]299
[1687]300        /**
301            @brief Deletes the SuperFunctionCaller.
302        */
303        template <int functionnumber, class T>
304        struct SuperFunctionDestruction
305        {
306            static void destroy(ClassIdentifier<T>* identifier) {}
307        };
308
309
[1684]310    //// Function-specific code ////
311
312        /**
313            @brief Creates the needed objects and templates to call a super-function.
314            @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
315            @param functionname The name of the super-function
316            @param hasarguments "false" if the function doesn't take any arguments, "true" if it does (without "")
317            @param ... Variadic: If the function takes arguments, add them here with type and name. Example: int myvalue, float myothervalue
318        */
319        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(functionnumber, functionname, hasarguments, ...) \
320            template <class T, int templatehack1, int templatehack2> \
321            struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2> \
322            { \
323                static void check() \
324                { \
325                    SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check(); \
326                } \
327            }; \
328            \
[2662]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            \
[1687]336            template <class T> \
[2662]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            \
345            template <class T> \
[1687]346            struct SuperFunctionInitialization<functionnumber, T> \
347            { \
348                static void initialize(ClassIdentifier<T>* identifier) \
349                { \
[2662]350                    identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \
351                    identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \
[1687]352                    SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \
353                } \
354            }; \
355            \
356            template <class T> \
357            struct SuperFunctionDestruction<functionnumber, T> \
358            { \
359                static void destroy(ClassIdentifier<T>* identifier) \
360                { \
361                    if (identifier->superFunctionCaller_##functionname##_) \
362                        delete identifier->superFunctionCaller_##functionname##_; \
363                    SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); \
364                } \
365            }; \
366            \
[1684]367            template <class T> \
368            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
369            { \
370                public: \
371                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
372                    { \
373                        (dynamic_cast<T*>(object))->T:: functionname
374
375        /*
376            JUST ADD THE FUNCTION ARGUMENTS BETWEEN BOTH MACROS, ENCLOSED BY BRACKETS
377            EXAMPLE:
378
379              SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, myfunction, true, int myvalue, float myothervalue) <-- !!! DONT ADD A SEMICOLON HERE !!!
380                (myvalue, myothervalue)
381              SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
382        */
383
384        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2 \
385                                                        ; \
386                    } \
387            };
388
389        #define SUPER_CALL_ARGUMENTSfalse(...) OrxonoxClass* object
390        #define SUPER_CALL_ARGUMENTS0(...)     OrxonoxClass* object
391        #define SUPER_CALL_ARGUMENTStrue(...) OrxonoxClass* object, __VA_ARGS__
392        #define SUPER_CALL_ARGUMENTS1(...)    OrxonoxClass* object, __VA_ARGS__
393
394
395    /*
396    //// COMMENTS ABOUT THE MACRO ////
397
398        // Partially specialized template (templatehack not yet specialized, this
399        // will be done by the real condition in the header-file of the super-function)
400        // Only used as fallback
401        template <class T, int templatehack1, int templatehack2>
402        struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2>
403        {
404            // If this function gets called, the header-file of the super function is not
405            // included, so this fallback template (templatehack not specialized) is used
406            static void check()
[1679]407            {
[1684]408                // Calls the condition-check of the next super-function (functionnumber + 1)
409                SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check();
[1679]410            }
[1684]411        };
412
[2662]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
[1687]423        template <class T>
[2662]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
434        template <class T>
[1687]435        struct SuperFunctionInitialization<functionnumber, T>
436        {
437            static void initialize(ClassIdentifier<T>* identifier)
438            {
[2662]439                identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>;
440                identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true;
[1687]441
442                // Calls the initialization of the next super-function (functionnumber + 1)
443                SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier);
444            }
445        };
446
447        // Deletes the SuperFunctionCaller.
448        template <class T>
449        struct SuperFunctionDestruction<functionnumber, T>
450        {
451            static void destroy(ClassIdentifier<T>* identifier)
452            {
453                if (identifier->superFunctionCaller_##functionname##_)
454                    delete identifier->superFunctionCaller_##functionname##_;
455
456                // Calls the destruction of the next super-function (functionnumber + 1)
457                SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier);
458            }
459        };
460
[1684]461        // The real super-function caller: Calls T::functionname()
462        // T should be the parent, but this will be done by the spezialized condition template
463        template <class T>
464        class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname
465        {
466            public:
467                // @brief Calls the function.
468                // @param object The object to call the function on
469                // @param ... The arguments of the function
470                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
471                {
472                    (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
473                }
474        }
475    */
476
[1687]477
[1684]478    //// Execute the code for each super-function ////
[1687]479
480        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
[1736]481        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, XMLPort, true, Element& xmlelement, XMLPort::Mode mode)
[1684]482            (xmlelement, mode)
483        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
484
[1736]485        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(1, tick, true, float dt)
[1684]486            (dt)
487        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
488
[1736]489        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(2, changedActivity, false)
[1684]490            ()
491        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
492
[1736]493        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(3, changedVisibility, false)
[1684]494            ()
495        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
[2087]496
497        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, processEvent, true, Event& event)
498            (event)
499        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
[2662]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;
[1687]524        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
[1684]525
[1679]526}
527
528#else /* _Super_H__ */
[1684]529  #ifdef SUPER_INTRUSIVE_DECLARATION_INCLUDE
[1679]530
[1684]531//////////////////////////////////////////////////////////////////////////
532// This code gets included within the declaration of ClassIdentifier<T> //
533//////////////////////////////////////////////////////////////////////////
[1679]534
[1684]535//// Common code ////
[1679]536
[1684]537    private:
[1687]538
[1684]539        template <int functionnumber, class TT, int templatehack1, int templatehack2>
540        friend struct SuperFunctionCondition;
[1679]541
[1684]542        // Creates the super-function-callers by calling the first SuperFunctionCondition check
543        // This get's called within the initialization of an Identifier
544        virtual void createSuperFunctionCaller() const
545        {
546            SuperFunctionCondition<0, T, 0, 0>::check();
547        }
[1679]548
549
[1684]550//// Function-specific code ////
551
552    public:
553        /**
554            @brief Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.
555            @param functionname The name of the super-function
556        */
557        #ifndef SUPER_INTRUSIVE_DECLARATION
558          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
[2662]559            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \
560            bool bSuperFunctionCaller_##functionname##_isFallback_
[1684]561        #endif
562
563
564//// Execute the code for each super-function ////
[1687]565
566    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
[1684]567    SUPER_INTRUSIVE_DECLARATION(XMLPort);
568    SUPER_INTRUSIVE_DECLARATION(tick);
569    SUPER_INTRUSIVE_DECLARATION(changedActivity);
570    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
[2087]571    SUPER_INTRUSIVE_DECLARATION(processEvent);
[2662]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);
[1687]578    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
[1684]579
580
581    #undef SUPER_INTRUSIVE_DECLARATION_INCLUDE
582  #endif /* SUPER_INTRUSIVE_DECLARATION_INCLUDE */
[1679]583#endif /* _Super_H__ */
Note: See TracBrowser for help on using the repository browser.