Base Class Traversion (baseclassiter.h)

Base class traversion comes in three flavours - unary access to a root instance, binary access to root instances and no access to a root instance.
template<class ReflectedClass, class CompileTimeRecursion> 
void foreachBaseClass(ReflectedClass& root,CompileTimeRecursion& ctRecursion);

template<class ReflectedClass, class CompileTimeRecursion> 
void foreachBaseClass(ReflectedClass& lhsRoot, ReflectedClass& rhsRoot, CompileTimeRecursion& ctRecursion);   

template<class ReflectedClass, class CompileTimeRecursion> 
void foreachBaseClass(CompileTimeRecursion& ctRecursion);   

ReflectedClass may of course contain a const qualification. A user defined function that can be used with the first form must have overloaded function call operators that can be called with a reference to an instance of a reflected class and of each of its baseclasses. These operators can be declared as member template function like this:

struct UserDefinedUnaryBaseClassVisitor
{
    template<class ReflectedClass> 
    void operator()(ReflectedClass& dataTuple);
};

A user defined function that can be used with the second form must have overloaded function call operators that can be called with two references to an instance of a reflected class and of each of its baseclasses. These operators can be declared as member template function like this:

struct UserDefinedBinaryBaseClassVisitor
{
    template<class ReflectedClass> 
    void operator()(ReflectedClass& lhsTuple, ReflectedClass& rhsTuple);
};

A user defined function that can be used with the third form must have overloaded function call operators that can be called with the type of each base class as explicit template argument. These operators can be declared as member template function like this:

struct UserDefinedStaticBaseClassVisitor
{
    template<class ReflectedClass> 
    void operator()();
};

The library uses base class traversion only in combination with attributewise traversions (that is like "foreach member variable of each base class") and that is why the template parameter is named CompileTimeRecursion. The implementation of that (and in particular the filtering of already traversed virtual base classes at compile time) is not exactly trivial but is documented for template junkies.

Because you cannot explicitly specifiy member template function parameters and because partial ordering of function templates does not work out of the box with VisualC++ 6.0 the version without a root instance looks like this for that compiler:

struct UserDefinedStaticBaseClassVisitor
{
    template<class ReflectedClass > 
    void operator()(PassType<ReflectedClass>,ClassVariableTag);
};
Last revised: September 13, 2004 Copyright 2004 Arne Adams