Good news for the people who use the dynamic dispatchers: They have become much more powerful, they support now implicit derived-to-base conversions. If the argument types don't match exactly, the dispatcher tries to find functions taking base class pointers/references. Here is a complete example:
// For this code, you needn't compile or link Thor, the dispatchers are a header-only feature
#define THOR_STATIC
#include <Thor/Tools/DoubleDispatcher.hpp>
#include <iostream>
// Example class hierarchy
class Object { public: virtual ~Object() {} };
class Asteroid : public Object {};
class Ship : public Object {};
class Missile : public Object {};
// Functions for collision with different argument types
void Collision(Asteroid*, Asteroid*) { std::cout << "Asteroid-Asteroid\n"; }
void Collision(Asteroid*, Ship*) { std::cout << "Asteroid-Ship\n"; }
void Collision(Ship*, Ship*) { std::cout << "Ship-Ship\n"; }
void Collision(Object*, Object*) { std::cout << "Other objects\n"; }
int main()
{
// Register class hierarchy (required to know derived-base relations at runtime)
THOR_RTTI_BASE(Object)
THOR_RTTI_DERIVED(Asteroid)
THOR_RTTI_DERIVED(Ship)
THOR_RTTI_DERIVED(Missile);
// Create dispatcher and register functions
thor::DoubleDispatcher<Object*> dispatcher(true, true);
dispatcher.Register<Asteroid, Asteroid>(&Collision);
dispatcher.Register<Asteroid, Ship> (&Collision);
dispatcher.Register<Ship, Ship> (&Collision);
dispatcher.Register<Object, Object> (&Collision);
// Base class pointers (no static type information about derived classes)
Object* a = new Asteroid;
Object* s = new Ship;
Object* m = new Missile;
// Invoke functions, let dispatcher choose the correct overload
dispatcher.Call(a, s); // Output: "Asteroid-Ship"
dispatcher.Call(a, a); // Output: "Asteroid-Asteroid"
dispatcher.Call(s, s); // Output: "Ship-Ship"
dispatcher.Call(a, m); // Output: "Other objects"
delete m;
delete s;
delete a;
}
I have also updated the Events module according to SFML's new input system. Next, I am probably going to set Animation progresses to [0,1], and maybe to use std::tr1::shared_ptr for resources.