Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/Super.h @ 9563

Last change on this file since 9563 was 9348, checked in by landauf, 12 years ago

merged branch presentation2012merge back to trunk

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