Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2008, 4:32:31 AM (16 years ago)
Author:
landauf
Message:
  • packed all super-function-related code into a bunch of macros and commented the code.
  • added tick, XMLPort, changedActivity and changedVisibility as super-functions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/Super.h

    r1683 r1684  
    2727 */
    2828
     29/**
     30    @file Super.h
     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 6 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/5)
     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/5)
     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/5)
     54
     55    4) Call the SUPER_INTRUSIVE_CONSTRUCTOR macro.
     56       This will be included into the constructor of ClassIdentifier<T>.
     57       Location: This file (Super.h), marked with --> HERE <-- comments (4/5)
     58
     59    5) Call the SUPER_INTRUSIVE_DESTRUCTOR macro.
     60       This will be included into the destructor of ClassIdentifier<T>.
     61       Location: This file (Super.h), marked with --> HERE <-- comments (5/5)
     62
     63    6) Call the SUPER_FUNCTION macro.
     64       This defines a partially specialized template that will decide if a class is "super" to another class.
     65       If the check returns true, a SuperFunctionCaller gets created, which will be used by the SUPER macro.
     66       You have to add this into the header-file of the baseclass of the super-function (the class that first
     67       implements the function), below the class declaration. You can't call it directly in this file, because
     68       otherwise you had to include the headerfile right here, which would cause some ugly backdependencies,
     69       include loops and slower compilation.
     70       Dont forget to include Super.h in the header-file.
     71       Location: The header-file of the baseclass (Baseclass.h), below the class declaration
     72*/
     73
    2974#ifndef _Super_H__
    3075#define _Super_H__
     
    3277#include <iostream>
    3378
    34 //////////////////
    35 // Common macro //
    36 //////////////////
    37 #define SUPER(classname, functionname, ...) \
    38     SUPER_##functionname(classname, functionname, __VA_ARGS__)
    39 
    40 /////////////////////////////
    41 // Function-specific macro //
    42 /////////////////////////////
    43 #define SUPER_testfunction(classname, functionname, ...) \
    44     (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
     79#include "CorePrereqs.h"
     80
     81#include "util/Debug.h"
     82#include "util/XMLIncludes.h"
     83
     84///////////////////////
     85// Macro definitions //
     86///////////////////////
     87
     88//// Common macros ////
     89
     90    /**
     91        @brief Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.
     92        @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
     93        @param baseclass The baseclass of the super-function (~the root)
     94        @param functionname The name of the super-function
     95        @param purevirtualbase "true" if the function is pure virtual in the baseclass, "false" if the function is implemented (without "")
     96    */
     97    #define SUPER_FUNCTION(functionnumber, baseclass, functionname, purevirtualbase) \
     98        template <class T, int templatehack2> \
     99        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2> \
     100        { \
     101            static void check() \
     102            { \
     103                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0); \
     104                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check(); \
     105            } \
     106            \
     107            static void apply(void* temp) {} \
     108            static void apply(baseclass* temp) \
     109            { \
     110                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \
     111                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
     112                { \
     113                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
     114                    { \
     115                        COUT(0) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \
     116                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
     117                    } \
     118                } \
     119            } \
     120        }; \
     121        \
     122        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase(functionnumber, baseclass)
     123
     124    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
     125    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
     126    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
     127    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass) \
     128        template <int templatehack2> \
     129        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
     130        { \
     131            static void check() \
     132            { \
     133                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
     134            } \
     135        };
     136
     137
     138    /*
     139    //// Comments about the macro ////
     140
     141        // Partially specialized template (templatehack is now specialized too).
     142        //
     143        // This ensures the compiler takes THIS template if the header-file of the super-function
     144        // is included. In any other case, the compiler just uses the fallback template which is
     145        // defined in this file.
     146        template <class T, templatehack2>
     147        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2>
     148        {
     149            static void check()
     150            {
     151                // This call to the apply-function is the whole check. By calling the function with
     152                // a T* pointer, the right function get's called.
     153                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0);
     154
     155                // Go go the check for of next super-function (functionnumber + 1)
     156                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check();
     157            }
     158
     159            // This function gets called if T is not a child of the baseclass.
     160            // The function does nothing.
     161            static void apply(void* temp) {}
     162
     163            // This function gets called if T is a child of the baseclass and can therefore be converted.
     164            // The function adds a SuperFunctionCaller to the Identifier of all subclasses of T.
     165            static void apply(baseclass* temp)
     166            {
     167                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
     168
     169                // Iterate through all children
     170                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
     171                {
     172                    // Check if there's not already a caller
     173                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
     174                    {
     175                        // Add the SuperFunctionCaller
     176                        COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;
     177                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
     178                    }
     179                }
     180            }
     181        };
     182        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase
     183
     184
     185        // The following piece of code is only added if purevirtualbase = true
     186
     187        // Explicit specialization of the Condition template for the baseclass to avoid
     188        // errors if the function is pure virtual in the baseclass.
     189        template <int templatehack2> \
     190        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
     191        { \
     192            // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)
     193            static void check() \
     194            { \
     195                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
     196            } \
     197        };
     198    */
     199
     200    // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent of classname
     201    #define SUPER(classname, functionname, ...) \
     202        SUPER_##functionname(classname, functionname, __VA_ARGS__)
     203
     204    // helper macro: for functions without arguments
     205    #define SUPER_NOARGS(classname, functionname) \
     206        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
     207
     208    // helper macro: for functions with arguments
     209    #define SUPER_ARGS(classname, functionname, ...) \
     210        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)
     211
     212
     213//// Function-specific macros ////
     214
     215    /*
     216        Add a macro for each super-function
     217
     218        Example (no arguments):
     219        #define SUPER_myfunction(classname, functionname, ...) \
     220            SUPER_NOARGS(classname, functionname)
     221
     222        Example (with arguments):
     223        #define SUPER_myfunction(classname, functionname, ...) \
     224            SUPER_ARGS(classname, functionname, __VA_ARGS__)
     225    */
     226
     227    // (1/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     228    #define SUPER_testfunction(classname, functionname, ...) \
     229        SUPER_NOARGS(classname, functionname)
     230
     231    #define SUPER_XMLPort(classname, functionname, ...) \
     232        SUPER_ARGS(classname, functionname, __VA_ARGS__)
     233
     234    #define SUPER_tick(classname, functionname, ...) \
     235        SUPER_ARGS(classname, functionname, __VA_ARGS__)
     236
     237    #define SUPER_changedActivity(classname, functionname, ...) \
     238        SUPER_NOARGS(classname, functionname)
     239
     240    #define SUPER_changedVisibility(classname, functionname, ...) \
     241        SUPER_NOARGS(classname, functionname)
     242    // (1/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     243
    45244
    46245namespace orxonox
    47246{
    48     /////////////////
    49     // Common code //
    50     /////////////////
    51     class SuperDummy {};
    52 
    53     // Base template
    54     template <int functionnumber, int templatehack, class T>
    55     struct SuperFunctionCondition
    56     {
    57         static void check() {}
    58     };
    59 
    60     ////////////////////////////
    61     // Function-specific code //
    62     ////////////////////////////
    63     // Partially specialized template (templatehack not yet specialized, this will be done by the real condition in the header file of the super-function)
    64     template <int templatehack, class T>
    65     struct SuperFunctionCondition<0, templatehack, T>
    66     {
    67         // Calls the condition of the next super-function
    68         static void check()
    69         {
    70             std::cout << "ignore superfunction \"testfunction\" in " << ClassIdentifier<T>::getIdentifier()->getName() << std::endl;
    71             SuperFunctionCondition<0 + 1, templatehack, T>::check();
     247    /////////////////////////////////////////////////////////////////////////////////////////////////////
     248    // This code gets included by Identifier.h and every other header file that needs a super-function //
     249    /////////////////////////////////////////////////////////////////////////////////////////////////////
     250
     251    //// Common code ////
     252
     253        // Dummy - only needed to cast Identifier* to ClassIdentifier<SuperDummy>* (the real class doesn't matter)
     254        class SuperDummy {};
     255
     256        // Base template
     257        template <int functionnumber, class T, int templatehack1, int templatehack2>
     258        struct SuperFunctionCondition
     259        {
     260            static void check() {}
     261        };
     262
     263
     264    //// Function-specific code ////
     265
     266        /**
     267            @brief Creates the needed objects and templates to call a super-function.
     268            @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
     269            @param functionname The name of the super-function
     270            @param hasarguments "false" if the function doesn't take any arguments, "true" if it does (without "")
     271            @param ... Variadic: If the function takes arguments, add them here with type and name. Example: int myvalue, float myothervalue
     272        */
     273        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(functionnumber, functionname, hasarguments, ...) \
     274            template <class T, int templatehack1, int templatehack2> \
     275            struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2> \
     276            { \
     277                static void check() \
     278                { \
     279                    SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check(); \
     280                } \
     281            }; \
     282            \
     283            class _CoreExport SuperFunctionCaller_##functionname \
     284            { \
     285                public: \
     286                    virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
     287                    virtual ~SuperFunctionCaller_##functionname () {} \
     288            }; \
     289            \
     290            template <class T> \
     291            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
     292            { \
     293                public: \
     294                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
     295                    { \
     296                        (dynamic_cast<T*>(object))->T:: functionname
     297
     298        /*
     299            JUST ADD THE FUNCTION ARGUMENTS BETWEEN BOTH MACROS, ENCLOSED BY BRACKETS
     300            EXAMPLE:
     301
     302              SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, myfunction, true, int myvalue, float myothervalue) <-- !!! DONT ADD A SEMICOLON HERE !!!
     303                (myvalue, myothervalue)
     304              SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
     305        */
     306
     307        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2 \
     308                                                        ; \
     309                    } \
     310            };
     311
     312        #define SUPER_CALL_ARGUMENTSfalse(...) OrxonoxClass* object
     313        #define SUPER_CALL_ARGUMENTS0(...)     OrxonoxClass* object
     314        #define SUPER_CALL_ARGUMENTStrue(...) OrxonoxClass* object, __VA_ARGS__
     315        #define SUPER_CALL_ARGUMENTS1(...)    OrxonoxClass* object, __VA_ARGS__
     316
     317
     318    /*
     319    //// COMMENTS ABOUT THE MACRO ////
     320
     321        // Partially specialized template (templatehack not yet specialized, this
     322        // will be done by the real condition in the header-file of the super-function)
     323        // Only used as fallback
     324        template <class T, int templatehack1, int templatehack2>
     325        struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2>
     326        {
     327            // If this function gets called, the header-file of the super function is not
     328            // included, so this fallback template (templatehack not specialized) is used
     329            static void check()
     330            {
     331                // Calls the condition-check of the next super-function (functionnumber + 1)
     332                SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check();
     333            }
     334        };
     335
     336        // Baseclass of the super-function caller. The real call will be done by a
     337        // templatized subclass through the virtual () operator.
     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        // The real super-function caller: Calls T::functionname()
     346        // T should be the parent, but this will be done by the spezialized condition template
     347        template <class T>
     348        class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname
     349        {
     350            public:
     351                // @brief Calls the function.
     352                // @param object The object to call the function on
     353                // @param ... The arguments of the function
     354                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
     355                {
     356                    (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
     357                }
    72358        }
    73     };
    74 
    75     class SuperFunctionCaller_testfunction
    76     {
    77         public:
    78             virtual void operator()(void* object) = 0;
    79             virtual ~SuperFunctionCaller_testfunction() {}
    80     };
    81 
    82     template <class T>
    83     class SuperFunctionClassCaller_testfunction : public SuperFunctionCaller_testfunction
    84     {
    85         public:
    86             inline void operator()(void* object)
    87             {
    88                 ((T*)object)->T::testfunction();
    89             }
    90     };
     359    */
     360
     361    //// Execute the code for each super-function ////
     362        // (2/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     363        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, testfunction, false)
     364            ()
     365        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     366
     367        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(1, XMLPort, true, Element& xmlelement, XMLPort::Mode mode)
     368            (xmlelement, mode)
     369        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     370
     371        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(2, tick, true, float dt)
     372            (dt)
     373        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     374
     375        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(3, changedActivity, false)
     376            ()
     377        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     378
     379        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(4, changedVisibility, false)
     380            ()
     381        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     382        // (2/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     383
    91384}
    92385
    93386#else /* _Super_H__ */
    94   #ifdef SUPER_INTRUSIVE_DECLARATION
    95 
    96 /////////////////
    97 // Common code //
    98 /////////////////
    99 private:
    100     template <int functionnumber, int templatehack, class TT>
    101     friend struct SuperFunctionCondition;
    102 
    103     // Creates the function pointers by calling the first SuperFunctionCondition check
    104     virtual void createSuperFunctionCaller() const
    105     {
    106         SuperFunctionCondition<0, 0, T>::check();
    107     }
    108 
    109 ////////////////////////////
     387  #ifdef SUPER_INTRUSIVE_DECLARATION_INCLUDE
     388
     389//////////////////////////////////////////////////////////////////////////
     390// This code gets included within the declaration of ClassIdentifier<T> //
     391//////////////////////////////////////////////////////////////////////////
     392
     393//// Common code ////
     394
     395    private:
     396        template <int functionnumber, class TT, int templatehack1, int templatehack2>
     397        friend struct SuperFunctionCondition;
     398
     399        // Creates the super-function-callers by calling the first SuperFunctionCondition check
     400        // This get's called within the initialization of an Identifier
     401        virtual void createSuperFunctionCaller() const
     402        {
     403            SuperFunctionCondition<0, T, 0, 0>::check();
     404        }
     405
     406
     407//// Function-specific code ////
     408
     409    public:
     410        /**
     411            @brief Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.
     412            @param functionname The name of the super-function
     413        */
     414        #ifndef SUPER_INTRUSIVE_DECLARATION
     415          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
     416            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_
     417        #endif
     418
     419
     420//// Execute the code for each super-function ////
     421    // (3/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     422    SUPER_INTRUSIVE_DECLARATION(testfunction);
     423    SUPER_INTRUSIVE_DECLARATION(XMLPort);
     424    SUPER_INTRUSIVE_DECLARATION(tick);
     425    SUPER_INTRUSIVE_DECLARATION(changedActivity);
     426    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
     427    // (3/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     428
     429
     430    #undef SUPER_INTRUSIVE_DECLARATION_INCLUDE
     431  #endif /* SUPER_INTRUSIVE_DECLARATION_INCLUDE */
     432
     433  #ifdef SUPER_INTRUSIVE_CONSTRUCTOR_INCLUDE
     434
     435//////////////////////////////////////////////////////////////////////////
     436// This code gets included inside the constructor of ClassIdentifier<T> //
     437//////////////////////////////////////////////////////////////////////////
     438
    110439// Function-specific code //
    111 ////////////////////////////
    112 public:
    113     // The function caller
    114     SuperFunctionCaller_testfunction* superFunctionCaller_testfunction_;
    115 
    116     #undef SUPER_INTRUSIVE_DECLARATION
    117   #endif /* SUPER_INTRUSIVE_DECLARATION */
    118 
    119   #ifdef SUPER_INTRUSIVE_CONSTRUCTOR
    120 
    121 ////////////////////////////
     440
     441    /**
     442        @brief Initializes the SuperFunctionCaller pointer with zero.
     443        @param functionname The name of the super-function
     444    */
     445    #ifndef SUPER_INTRUSIVE_CONSTRUCTOR
     446      #define SUPER_INTRUSIVE_CONSTRUCTOR(functionname) \
     447        this->superFunctionCaller_##functionname##_ = 0
     448    #endif
     449
     450
     451//// Execute the code for each super-function ////
     452    // (4/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     453    SUPER_INTRUSIVE_CONSTRUCTOR(testfunction);
     454    SUPER_INTRUSIVE_CONSTRUCTOR(XMLPort);
     455    SUPER_INTRUSIVE_CONSTRUCTOR(tick);
     456    SUPER_INTRUSIVE_CONSTRUCTOR(changedActivity);
     457    SUPER_INTRUSIVE_CONSTRUCTOR(changedVisibility);
     458    // (4/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     459
     460    #undef SUPER_INTRUSIVE_CONSTRUCTOR_INCLUDE
     461  #endif /* SUPER_INTRUSIVE_CONSTRUCTOR_INCLUDE */
     462
     463  #ifdef SUPER_INTRUSIVE_DESTRUCTOR_INCLUDE
     464
     465/////////////////////////////////////////////////////////////////////////
     466// This code gets included inside the destructor of ClassIdentifier<T> //
     467/////////////////////////////////////////////////////////////////////////
     468
    122469// Function-specific code //
    123 ////////////////////////////
    124 this->superFunctionCaller_testfunction_ = 0;
    125 
    126     #undef SUPER_INTRUSIVE_CONSTRUCTOR
    127   #endif /* SUPER_INTRUSIVE_CONSTRUCTOR */
    128 
    129   #ifdef SUPER_INTRUSIVE_DESTRUCTOR
    130 
    131 ////////////////////////////
    132 // Function-specific code //
    133 ////////////////////////////
    134 
    135 if (this->superFunctionCaller_testfunction_)
    136     delete this->superFunctionCaller_testfunction_;
    137 
    138     #undef SUPER_INTRUSIVE_DESTRUCTOR
    139   #endif /* SUPER_INTRUSIVE_DESTRUCTOR */
     470
     471    /**
     472        @brief Deletes the SuperFunctionCaller.
     473        @param functionname The name of the super-function
     474    */
     475    #ifndef SUPER_INTRUSIVE_DESTRUCTOR
     476      #define SUPER_INTRUSIVE_DESTRUCTOR(functionname) \
     477        if (this->superFunctionCaller_##functionname##_) \
     478          delete this->superFunctionCaller_##functionname##_
     479    #endif
     480
     481
     482//// Execute the code for each super-function ////
     483    // (5/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     484    SUPER_INTRUSIVE_DESTRUCTOR(testfunction);
     485    SUPER_INTRUSIVE_DESTRUCTOR(XMLPort);
     486    SUPER_INTRUSIVE_DESTRUCTOR(tick);
     487    SUPER_INTRUSIVE_DESTRUCTOR(changedActivity);
     488    SUPER_INTRUSIVE_DESTRUCTOR(changedVisibility);
     489    // (5/5) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
     490
     491    #undef SUPER_INTRUSIVE_DESTRUCTOR_INCLUDE
     492  #endif /* SUPER_INTRUSIVE_DESTRUCTOR_INCLUDE */
    140493#endif /* _Super_H__ */
Note: See TracChangeset for help on using the changeset viewer.