Super.h File Reference

Definition of all super-function related macros. More...

#include "CorePrereqs.h"
#include "util/Debug.h"
#include "Event.h"

Namespaces

namespace  orxonox

Classes

struct  orxonox::SuperFunctionCondition< functionnumber, T, templatehack1, templatehack2 >
 Creates the SuperFunctionCaller if T is a child of the super-functions baseclass. More...
struct  orxonox::SuperFunctionDestruction< functionnumber, T >
 Deletes the SuperFunctionCaller. More...
struct  orxonox::SuperFunctionInitialization< functionnumber, T >
 Initializes the SuperFunctionCaller-pointer with zero. More...

Defines

#define SUPER(classname, functionname,...)   SUPER_##functionname(classname, functionname, __VA_ARGS__)
#define SUPER_ARGS(classname, functionname,...)   (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)
#define SUPER_CALL_ARGUMENTS0(...)   OrxonoxClass* object
#define SUPER_CALL_ARGUMENTS1(...)   OrxonoxClass* object, __VA_ARGS__
#define SUPER_CALL_ARGUMENTSfalse(...)   OrxonoxClass* object
#define SUPER_CALL_ARGUMENTStrue(...)   OrxonoxClass* object, __VA_ARGS__
#define SUPER_changedActivity(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedGametype(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedMainState(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedName(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedOverlayGroup(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedOwner(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedScale(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_changedVisibility(classname, functionname,...)   SUPER_NOARGS(classname, functionname)
#define SUPER_FUNCTION(functionnumber, baseclass, functionname, purevirtualbase)
 Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.
#define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(functionnumber, functionname, hasarguments,...)
 Creates the needed objects and templates to call a super-function.
#define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0(functionnumber, baseclass)   SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1(functionnumber, baseclass)   SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
#define SUPER_INTRUSIVE_DECLARATION(functionname)
 Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.
#define SUPER_NOARGS(classname, functionname)   (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
#define SUPER_processEvent(classname, functionname,...)   SUPER_ARGS(classname, functionname, __VA_ARGS__)
#define SUPER_tick(classname, functionname,...)   SUPER_ARGS(classname, functionname, __VA_ARGS__)
#define SUPER_XMLPort(classname, functionname,...)   SUPER_ARGS(classname, functionname, __VA_ARGS__)

Variables

mode orxonox::SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
 orxonox::xmlelement


Detailed Description

Definition of all super-function related macros.

This file defines all macros needed to add a new "super-function". If you add a super-function, you can call SUPER(myclass, functionname) inside your code and the function of the parentclass gets called. This is comparable with super.functionname() in Java or other languages.

This works only with virtual functions that return nothing (void) and belong to classes that have an Identifier. Arguments however are supported.

To add a new super-function, you have process 4 steps:

1) Add a new SUPER macro This allows you to call the super-function in your code. Location: This file (Super.h), marked with --> HERE <-- comments (1/3)

2) Call the SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros. This defines some global classes and templates, needed to create and call the super-functions. Location: This file (Super.h), marked with --> HERE <-- comments (2/3)

3) Call the SUPER_INTRUSIVE_DECLARATION macro. This will be included into the declaration of ClassIdentifier<T>. Location: This file (Super.h), marked with --> HERE <-- comments (3/3)

4) Call the SUPER_FUNCTION macro. This defines a partially specialized template that will decide if a class is "super" to another class. If the check returns true, a SuperFunctionCaller gets created, which will be used by the SUPER macro. You have to add this into the header-file of the baseclass of the super-function (the class that first implements the function), below the class declaration. You can't call it directly in this file, because otherwise you had to include the headerfile right here, which would cause some ugly backdependencies, include loops and slower compilation. Dont forget to include Super.h in the header-file. Location: The header-file of the baseclass (Baseclass.h), below the class declaration


Define Documentation

#define SUPER ( classname,
functionname,
...   )     SUPER_##functionname(classname, functionname, __VA_ARGS__)

Referenced by orxonox::CheckPoint::changedActivity(), orxonox::ParticleEmitter::changedActivity(), orxonox::FadingBillboard::changedActivity(), orxonox::Attacher::changedActivity(), orxonox::PickupSpawner::changedActivity(), orxonox::Engine::changedActivity(), orxonox::PongCenterpoint::changedGametype(), orxonox::OrxonoxOverlay::changedName(), orxonox::HUDHealthBar::changedName(), orxonox::PlayerInfo::changedName(), orxonox::EventTarget::changedName(), orxonox::Template::changedName(), orxonox::HUDHealthBar::changedOverlayGroup(), orxonox::Map::changedOwner(), orxonox::UnderAttackHealthBar::changedOwner(), orxonox::TeamBaseMatchScore::changedOwner(), orxonox::PongScore::changedOwner(), orxonox::KillMessage::changedOwner(), orxonox::HUDTimer::changedOwner(), orxonox::HUDSpeedBar::changedOwner(), orxonox::HUDRadar::changedOwner(), orxonox::HUDHealthBar::changedOwner(), orxonox::GametypeStatus::changedOwner(), orxonox::DeathMessage::changedOwner(), orxonox::AnnounceMessage::changedOwner(), orxonox::Backlight::changedScale(), orxonox::Scoreboard::changedVisibility(), orxonox::HUDHealthBar::changedVisibility(), orxonox::GUIOverlay::changedVisibility(), orxonox::Trigger::changedVisibility(), orxonox::Planet::changedVisibility(), orxonox::ParticleEmitter::changedVisibility(), orxonox::Model::changedVisibility(), orxonox::Light::changedVisibility(), orxonox::FadingBillboard::changedVisibility(), orxonox::Billboard::changedVisibility(), orxonox::Backlight::changedVisibility(), orxonox::Attacher::changedVisibility(), orxonox::ParticleProjectile::changedVisibility(), orxonox::BillboardProjectile::changedVisibility(), orxonox::GlobalShader::changedVisibility(), orxonox::EventTrigger::processEvent(), orxonox::ParticleSpawner::processEvent(), orxonox::QuestEffectBeacon::processEvent(), orxonox::Shader::tick(), orxonox::TeamBaseMatchScore::tick(), orxonox::PongScore::tick(), orxonox::HUDTimer::tick(), orxonox::HUDSpeedBar::tick(), orxonox::HUDNavigation::tick(), orxonox::HUDHealthBar::tick(), orxonox::GametypeStatus::tick(), orxonox::DebugRTRText::tick(), orxonox::DebugFPSText::tick(), orxonox::Trigger::tick(), orxonox::PongBat::tick(), orxonox::PongBall::tick(), orxonox::Planet::tick(), orxonox::Spectator::tick(), orxonox::SpaceShip::tick(), orxonox::Pawn::tick(), orxonox::FadingBillboard::tick(), orxonox::ExplosionChunk::tick(), orxonox::Camera::tick(), orxonox::BlinkingBillboard::tick(), orxonox::BigExplosion::tick(), orxonox::Backlight::tick(), orxonox::Projectile::tick(), orxonox::Radar::tick(), orxonox::MultiStateEngine::tick(), orxonox::Engine::tick(), orxonox::UnderAttack::tick(), orxonox::Gametype::tick(), orxonox::Asteroids::tick(), orxonox::WaypointPatrolController::tick(), orxonox::AIController::tick(), orxonox::Scoreboard::XMLPort(), orxonox::OverlayText::XMLPort(), orxonox::OverlayGroup::XMLPort(), orxonox::OrxonoxOverlay::XMLPort(), orxonox::NotificationQueue::XMLPort(), orxonox::Map::XMLPort(), orxonox::UnderAttackHealthBar::XMLPort(), orxonox::TeamBaseMatchScore::XMLPort(), orxonox::PongScore::XMLPort(), orxonox::HUDRadar::XMLPort(), orxonox::HUDNavigation::XMLPort(), orxonox::HUDHealthBar::XMLPort(), orxonox::HUDBar::XMLPort(), orxonox::BarColour::XMLPort(), orxonox::GUIOverlay::XMLPort(), orxonox::FadeoutText::XMLPort(), orxonox::WorldEntity::XMLPort(), orxonox::Trigger::XMLPort(), orxonox::PlayerTrigger::XMLPort(), orxonox::DistanceTrigger::XMLPort(), orxonox::CheckPoint::XMLPort(), orxonox::TeamSpawnPoint::XMLPort(), orxonox::SpawnPoint::XMLPort(), orxonox::PongCenterpoint::XMLPort(), orxonox::Planet::XMLPort(), orxonox::SpaceShip::XMLPort(), orxonox::Pawn::XMLPort(), orxonox::ParticleSpawner::XMLPort(), orxonox::ParticleEmitter::XMLPort(), orxonox::MovableEntity::XMLPort(), orxonox::Model::XMLPort(), orxonox::MobileEntity::XMLPort(), orxonox::Light::XMLPort(), orxonox::ForceField::XMLPort(), orxonox::FadingBillboard::XMLPort(), orxonox::ControllableEntity::XMLPort(), orxonox::CameraPosition::XMLPort(), orxonox::BlinkingBillboard::XMLPort(), orxonox::Billboard::XMLPort(), orxonox::Backlight::XMLPort(), orxonox::Attacher::XMLPort(), orxonox::WeaponSlot::XMLPort(), orxonox::WeaponSet::XMLPort(), orxonox::WeaponPack::XMLPort(), orxonox::HsW01::XMLPort(), orxonox::EnergyDrink::XMLPort(), orxonox::WeaponMode::XMLPort(), orxonox::Weapon::XMLPort(), orxonox::DefaultWeaponmodeLink::XMLPort(), orxonox::Scene::XMLPort(), orxonox::QuestListener::XMLPort(), orxonox::QuestItem::XMLPort(), orxonox::QuestHint::XMLPort(), orxonox::QuestEffectBeacon::XMLPort(), orxonox::QuestDescription::XMLPort(), orxonox::Quest::XMLPort(), orxonox::LocalQuest::XMLPort(), orxonox::GlobalQuest::XMLPort(), orxonox::FailQuest::XMLPort(), orxonox::CompleteQuest::XMLPort(), orxonox::ChangeQuestStatus::XMLPort(), orxonox::AddReward::XMLPort(), orxonox::AddQuestHint::XMLPort(), orxonox::AddQuest::XMLPort(), orxonox::PickupSpawner::XMLPort(), orxonox::ModifierPickup::XMLPort(), orxonox::Jump::XMLPort(), orxonox::HealthUsable::XMLPort(), orxonox::HealthImmediate::XMLPort(), orxonox::BaseItem::XMLPort(), orxonox::Level::XMLPort(), orxonox::MultiStateEngine::XMLPort(), orxonox::Engine::XMLPort(), orxonox::GlobalShader::XMLPort(), orxonox::EventListener::XMLPort(), orxonox::EventDispatcher::XMLPort(), orxonox::WaypointPatrolController::XMLPort(), orxonox::WaypointController::XMLPort(), orxonox::SphereCollisionShape::XMLPort(), orxonox::PlaneCollisionShape::XMLPort(), orxonox::ConeCollisionShape::XMLPort(), orxonox::CompoundCollisionShape::XMLPort(), orxonox::CollisionShape::XMLPort(), orxonox::BoxCollisionShape::XMLPort(), orxonox::Template::XMLPort(), and orxonox::Namespace::XMLPort().

#define SUPER_ARGS ( classname,
functionname,
...   )     (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)

#define SUPER_CALL_ARGUMENTS0 ( ...   )     OrxonoxClass* object

#define SUPER_CALL_ARGUMENTS1 ( ...   )     OrxonoxClass* object, __VA_ARGS__

#define SUPER_CALL_ARGUMENTSfalse ( ...   )     OrxonoxClass* object

#define SUPER_CALL_ARGUMENTStrue ( ...   )     OrxonoxClass* object, __VA_ARGS__

#define SUPER_changedActivity ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedGametype ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedMainState ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedName ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedOverlayGroup ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedOwner ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedScale ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_changedVisibility ( classname,
functionname,
...   )     SUPER_NOARGS(classname, functionname)

#define SUPER_FUNCTION ( functionnumber,
baseclass,
functionname,
purevirtualbase   ) 

Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.

Parameters:
functionnumber Each super-function needs a unique number, starting with zero, increasing by one
baseclass The baseclass of the super-function (~the root)
functionname The name of the super-function
purevirtualbase "true" if the function is pure virtual in the baseclass, "false" if the function is implemented (without "")

#define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1 ( functionnumber,
functionname,
hasarguments,
...   ) 

Creates the needed objects and templates to call a super-function.

Parameters:
functionnumber Each super-function needs a unique number, starting with zero, increasing by one
functionname The name of the super-function
hasarguments "false" if the function doesn't take any arguments, "true" if it does (without "")
... Variadic: If the function takes arguments, add them here with type and name. Example: int myvalue, float myothervalue

#define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2

Value:

; \
                    } \
            };

#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0 ( functionnumber,
baseclass   )     SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)

#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1 ( functionnumber,
baseclass   )     SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)

#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse ( functionnumber,
baseclass   ) 

#define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue ( functionnumber,
baseclass   ) 

Value:

template <int templatehack2> \
        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
        { \
            static void check() \
            { \
                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
            } \
        };

#define SUPER_INTRUSIVE_DECLARATION ( functionname   ) 

Value:

SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \
            bool bSuperFunctionCaller_##functionname##_isFallback_
Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.

Parameters:
functionname The name of the super-function

#define SUPER_NOARGS ( classname,
functionname   )     (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)

#define SUPER_processEvent ( classname,
functionname,
...   )     SUPER_ARGS(classname, functionname, __VA_ARGS__)

#define SUPER_tick ( classname,
functionname,
...   )     SUPER_ARGS(classname, functionname, __VA_ARGS__)

#define SUPER_XMLPort ( classname,
functionname,
...   )     SUPER_ARGS(classname, functionname, __VA_ARGS__)


Generated on Tue Jul 28 16:21:09 2009 for Orxonox by  doxygen 1.5.6