runTimeSelection/memberFunctionSelection templated forms

- useful when the baseType isn't a typedef and thus requires the same
   template argument as the derived class
This commit is contained in:
Mark Olesen
2008-11-13 09:44:03 +01:00
parent f9ec26bada
commit 051eee5caa
4 changed files with 137 additions and 98 deletions

View File

@ -38,31 +38,49 @@ Description
#define addToMemberFunctionSelectionTable\ #define addToMemberFunctionSelectionTable\
(baseType,thisType,memberFunction,argNames) \ (baseType,thisType,memberFunction,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType memberFunction to the table */ \
baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType> \ baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType> \
add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_ add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_
#define addNamedToMemberFunctionSelectionTable\ #define addNamedToMemberFunctionSelectionTable\
(baseType,thisType,memberFunction,argNames,lookup) \ (baseType,thisType,memberFunction,argNames,lookup) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType memberFunction to the table, find by lookup name */ \
baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType> \ baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType> \
add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup) add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup)
// use when baseType doesn't need a template argument (eg, is a typedef)
#define addTemplateToMemberFunctionSelectionTable\ #define addTemplateToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames) \ (baseType,thisType,Targ,memberFunction,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType memberFunction to the table */ \
baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType<Targ> > \ baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType<Targ> > \
add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_ add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_
// use when baseType doesn't need a template argument (eg, is a typedef)
#define addNamedTemplateToMemberFunctionSelectionTable\ #define addNamedTemplateToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames,lookup) \ (baseType,thisType,Targ,memberFunction,argNames,lookup) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType memberFunction to the table, find by lookup name */ \
baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType<Targ> > \ baseType::add##memberFunction##argNames##MemberFunctionToTable<thisType<Targ> > \
add_##lookup##_##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup) add_##lookup##_##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup)
// use when baseType requires the Targ template argument as well
#define addTemplatedToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames) \
\
/* Add the thisType memberFunction to the table */ \
baseType<Targ>::add##memberFunction##argNames##MemberFunctionToTable<thisType<Targ> > \
add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Targ##Table_
// use when baseType requires the Targ template argument as well
#define addNamedTemplatedToMemberFunctionSelectionTable\
(baseType,thisType,Targ,memberFunction,argNames,lookup) \
\
/* Add the thisType memberFunction to the table, find by lookup name */ \
baseType<Targ>::add##memberFunction##argNames##MemberFunctionToTable<thisType<Targ> > \
add_##lookup##_##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Targ##Table_(#lookup)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -79,7 +79,7 @@ Description
} \ } \
}; \ }; \
\ \
/* Table MemberFunction called from the table add function */ \ /* Table memberFunction called from the table add function */ \
static void construct##memberFunction##argNames##MemberFunctionTables(); \ static void construct##memberFunction##argNames##MemberFunctionTables(); \
\ \
/* Table destructor called from the table add function destructor */ \ /* Table destructor called from the table add function destructor */ \
@ -89,7 +89,7 @@ Description
#define defineMemberFunctionSelectionTableMemberFunction\ #define defineMemberFunctionSelectionTableMemberFunction\
(baseType,memberFunction,argNames) \ (baseType,memberFunction,argNames) \
\ \
/* Table MemberFunction called from the table add function */ \ /* Table memberFunction called from the table add function */ \
void baseType::construct##memberFunction##argNames##MemberFunctionTables()\ void baseType::construct##memberFunction##argNames##MemberFunctionTables()\
{ \ { \
static bool constructed = false; \ static bool constructed = false; \
@ -119,14 +119,14 @@ Description
#define defineMemberFunctionSelectionTablePtr\ #define defineMemberFunctionSelectionTablePtr\
(baseType,memberFunction,argNames) \ (baseType,memberFunction,argNames) \
\ \
/* Define the constructor function table */ \ /* Define the memberFunction table */ \
baseType::memberFunction##argNames##MemberFunctionTable* \ baseType::memberFunction##argNames##MemberFunctionTable* \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL
#define defineTemplateMemberFunctionSelectionTablePtr\ #define defineTemplateMemberFunctionSelectionTablePtr\
(baseType,memberFunction,argNames) \ (baseType,memberFunction,argNames) \
\ \
/* Define the constructor function table */ \ /* Define the memberFunction table */ \
typename baseType::memberFunction##argNames##MemberFunctionTable* \ typename baseType::memberFunction##argNames##MemberFunctionTable* \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL

View File

@ -35,31 +35,52 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define addToRunTimeSelectionTable(baseType,thisType,argNames) \ #define addToRunTimeSelectionTable\
(baseType,thisType,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType constructor function to the table */ \
baseType::add##argNames##ConstructorToTable<thisType> \ baseType::add##argNames##ConstructorToTable<thisType> \
add##thisType##argNames##ConstructorTo##baseType##Table_ add##thisType##argNames##ConstructorTo##baseType##Table_
#define addNamedToRunTimeSelectionTable(baseType,thisType,argNames,lookup) \ #define addNamedToRunTimeSelectionTable\
(baseType,thisType,argNames,lookup) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType constructor function to the table, find by lookup */ \
baseType::add##argNames##ConstructorToTable<thisType> \ baseType::add##argNames##ConstructorToTable<thisType> \
add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_(#lookup) add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_(#lookup)
#define addTemplateToRunTimeSelectionTable(baseType,thisType,Targ,argNames) \ // use when baseType doesn't need a template argument (eg, is a typedef)
#define addTemplateToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType constructor function to the table */ \
baseType::add##argNames##ConstructorToTable<thisType<Targ> > \ baseType::add##argNames##ConstructorToTable<thisType<Targ> > \
add##thisType##Targ##argNames##ConstructorTo##baseType##Table_ add##thisType##Targ##argNames##ConstructorTo##baseType##Table_
// use when baseType doesn't need a template argument (eg, is a typedef)
#define addNamedTemplateToRunTimeSelectionTable\ #define addNamedTemplateToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup) \ (baseType,thisType,Targ,argNames,lookup) \
\ \
/* Add the thisType constructor function to the table */ \ /* Add the thisType constructor function to the table, find by lookup */ \
baseType::add##argNames##ConstructorToTable<thisType<Targ> > \ baseType::add##argNames##ConstructorToTable<thisType<Targ> > \
add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Table_(#lookup) add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Table_(#lookup)
// use when baseType requires the Targ template argument as well
#define addTemplatedToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames) \
\
/* Add the thisType constructor function to the table */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ> > \
add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_
// use when baseType requires the Targ template argument as well
#define addNamedTemplatedToRunTimeSelectionTable\
(baseType,thisType,Targ,argNames,lookup) \
\
/* Add the thisType constructor function to the table, find by lookup */ \
baseType<Targ>::add##argNames##ConstructorToTable<thisType<Targ> > \
add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_(#lookup)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif

View File

@ -79,16 +79,16 @@ Description
} \ } \
}; \ }; \
\ \
/* Table Constructor called from the table add function */ \ /* Table constructor called from the table add function */ \
static void construct##argNames##ConstructorTables(); \ static void construct##argNames##ConstructorTables(); \
\ \
/* Table destructor called from the table add function destructor */\ /* Table destructor called from the table add function destructor */ \
static void destroy##argNames##ConstructorTables() static void destroy##argNames##ConstructorTables()
#define defineRunTimeSelectionTableConstructor(baseType,argNames) \ #define defineRunTimeSelectionTableConstructor(baseType,argNames) \
\ \
/* Table Constructor called from the table add function */ \ /* Table constructor called from the table add function */ \
void baseType::construct##argNames##ConstructorTables() \ void baseType::construct##argNames##ConstructorTables() \
{ \ { \
static bool constructed = false; \ static bool constructed = false; \
@ -104,7 +104,7 @@ Description
#define defineRunTimeSelectionTableDestructor(baseType,argNames) \ #define defineRunTimeSelectionTableDestructor(baseType,argNames) \
\ \
/* Table destructor called from the table add function destructor */\ /* Table destructor called from the table add function destructor */ \
void baseType::destroy##argNames##ConstructorTables() \ void baseType::destroy##argNames##ConstructorTables() \
{ \ { \
if (baseType::argNames##ConstructorTablePtr_) \ if (baseType::argNames##ConstructorTablePtr_) \