Bromeon
Classes | Defines
Tools

Reusable C++ utility features, for instance multimethods (dynamic dispatch). More...

Classes

class  thor::DoubleDispatcher< B, R >
 Class that is able to perform dynamic dispatch on multiple functions with two parameters. More...
class  thor::Exception
 Exception base class. More...
class  thor::FunctionCallException
 Exception class for failed function calls. More...
class  thor::ResourceLoadingException
 Exception class for failed resource allocation. More...
class  thor::StringConversionException
 Exception class for failed string conversions. More...
class  thor::NonCopyable
 Non-copyable base class. More...
class  thor::SingleDispatcher< B, R >
 Class that is able to perform dynamic dispatch on multiple functions with one parameter. More...

Defines

#define THOR_FOREACH(ContainerType, containerVar, iteratorVar)
 Macro to iterate forward on a mutable sequence.
#define THOR_CONST_FOREACH(ContainerType, containerVar, iteratorVar)
 Macro to iterate forward on a constant sequence.
#define THOR_RTTI_BASE(BaseClass)
 Register runtime type information for a base class.
#define THOR_RTTI_DERIVED(DerivedClass)
 Register runtime type information for a derived class.

Detailed Description

Reusable C++ utility features, for instance multimethods (dynamic dispatch).


Define Documentation

#define THOR_RTTI_BASE (   BaseClass)

Register runtime type information for a base class.

You need this for the dynamic dispatchers to cope with derived-to-base conversions. Since C++ offers no possibility to recognize the base classes of a class at runtime, this must be done manually. Note that multiple inheritance is not supported.

Example class hierarchy:

 class Vehicle { public: virtual ~Vehicle(); }
 class Aircraft : public Vehicle {};
 class Watercraft : public Vehicle {};
 class Ship : public Watercraft {};
 class Submarine : public Watercraft {};

Register classes as follows (once inside a function):

 THOR_RTTI_BASE(Vehicle)
   THOR_RTTI_DERIVED(Aircraft)
   THOR_RTTI_DERIVED(Watercraft);
 THOR_RTTI_BASE(Watercraft)
   THOR_RTTI_DERIVED(Ship)
   THOR_RTTI_DERIVED(Submarine);
#define THOR_RTTI_DERIVED (   DerivedClass)

Register runtime type information for a derived class.

See also:
THOR_RTTI_BASE