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:
parent
f9ec26bada
commit
051eee5caa
@ -38,31 +38,49 @@ Description
|
||||
#define addToMemberFunctionSelectionTable\
|
||||
(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> \
|
||||
add##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_
|
||||
|
||||
#define addNamedToMemberFunctionSelectionTable\
|
||||
(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> \
|
||||
add_##lookup##_##thisType##memberFunction##argNames##MemberFunctionTo##baseType##Table_(#lookup)
|
||||
|
||||
// use when baseType doesn't need a template argument (eg, is a typedef)
|
||||
#define addTemplateToMemberFunctionSelectionTable\
|
||||
(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> > \
|
||||
add##thisType##Targ##memberFunction##argNames##MemberFunctionTo##baseType##Table_
|
||||
|
||||
// use when baseType doesn't need a template argument (eg, is a typedef)
|
||||
#define addNamedTemplateToMemberFunctionSelectionTable\
|
||||
(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> > \
|
||||
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)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -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(); \
|
||||
\
|
||||
/* Table destructor called from the table add function destructor */ \
|
||||
@ -89,7 +89,7 @@ Description
|
||||
#define defineMemberFunctionSelectionTableMemberFunction\
|
||||
(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()\
|
||||
{ \
|
||||
static bool constructed = false; \
|
||||
@ -119,14 +119,14 @@ Description
|
||||
#define defineMemberFunctionSelectionTablePtr\
|
||||
(baseType,memberFunction,argNames) \
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
/* Define the memberFunction table */ \
|
||||
baseType::memberFunction##argNames##MemberFunctionTable* \
|
||||
baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL
|
||||
|
||||
#define defineTemplateMemberFunctionSelectionTablePtr\
|
||||
(baseType,memberFunction,argNames) \
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
/* Define the memberFunction table */ \
|
||||
typename baseType::memberFunction##argNames##MemberFunctionTable* \
|
||||
baseType::memberFunction##argNames##MemberFunctionTablePtr_ = NULL
|
||||
|
||||
|
@ -35,31 +35,52 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define addToRunTimeSelectionTable(baseType,thisType,argNames) \
|
||||
#define addToRunTimeSelectionTable\
|
||||
(baseType,thisType,argNames) \
|
||||
\
|
||||
/* Add the thisType constructor function to the table */ \
|
||||
baseType::add##argNames##ConstructorToTable<thisType> \
|
||||
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> \
|
||||
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 */ \
|
||||
baseType::add##argNames##ConstructorToTable<thisType<Targ> > \
|
||||
add##thisType##Targ##argNames##ConstructorTo##baseType##Table_
|
||||
|
||||
// use when baseType doesn't need a template argument (eg, is a typedef)
|
||||
#define addNamedTemplateToRunTimeSelectionTable\
|
||||
(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> > \
|
||||
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
|
||||
|
@ -41,104 +41,104 @@ Description
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define declareRunTimeSelectionTable\
|
||||
(autoPtr,baseType,argNames,argList,parList) \
|
||||
\
|
||||
/* Construct from argList function pointer type */ \
|
||||
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
|
||||
\
|
||||
/* Construct from argList function table type */ \
|
||||
typedef HashTable<argNames##ConstructorPtr, word, string::hash> \
|
||||
argNames##ConstructorTable; \
|
||||
\
|
||||
/* Construct from argList function pointer table pointer */ \
|
||||
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
|
||||
\
|
||||
/* Class to add constructor from argList to table */ \
|
||||
template<class baseType##Type> \
|
||||
class add##argNames##ConstructorToTable \
|
||||
{ \
|
||||
public: \
|
||||
\
|
||||
static autoPtr<baseType> New argList \
|
||||
{ \
|
||||
return autoPtr<baseType>(new baseType##Type parList); \
|
||||
} \
|
||||
\
|
||||
add##argNames##ConstructorToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
{ \
|
||||
construct##argNames##ConstructorTables(); \
|
||||
argNames##ConstructorTablePtr_->insert(lookup, New); \
|
||||
} \
|
||||
\
|
||||
~add##argNames##ConstructorToTable() \
|
||||
{ \
|
||||
destroy##argNames##ConstructorTables(); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
/* Table Constructor called from the table add function */ \
|
||||
static void construct##argNames##ConstructorTables(); \
|
||||
\
|
||||
/* Table destructor called from the table add function destructor */\
|
||||
(autoPtr,baseType,argNames,argList,parList) \
|
||||
\
|
||||
/* Construct from argList function pointer type */ \
|
||||
typedef autoPtr<baseType> (*argNames##ConstructorPtr)argList; \
|
||||
\
|
||||
/* Construct from argList function table type */ \
|
||||
typedef HashTable<argNames##ConstructorPtr, word, string::hash> \
|
||||
argNames##ConstructorTable; \
|
||||
\
|
||||
/* Construct from argList function pointer table pointer */ \
|
||||
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
|
||||
\
|
||||
/* Class to add constructor from argList to table */ \
|
||||
template<class baseType##Type> \
|
||||
class add##argNames##ConstructorToTable \
|
||||
{ \
|
||||
public: \
|
||||
\
|
||||
static autoPtr<baseType> New argList \
|
||||
{ \
|
||||
return autoPtr<baseType>(new baseType##Type parList); \
|
||||
} \
|
||||
\
|
||||
add##argNames##ConstructorToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
{ \
|
||||
construct##argNames##ConstructorTables(); \
|
||||
argNames##ConstructorTablePtr_->insert(lookup, New); \
|
||||
} \
|
||||
\
|
||||
~add##argNames##ConstructorToTable() \
|
||||
{ \
|
||||
destroy##argNames##ConstructorTables(); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
/* Table constructor called from the table add function */ \
|
||||
static void construct##argNames##ConstructorTables(); \
|
||||
\
|
||||
/* Table destructor called from the table add function destructor */ \
|
||||
static void destroy##argNames##ConstructorTables()
|
||||
|
||||
|
||||
#define defineRunTimeSelectionTableConstructor(baseType,argNames) \
|
||||
\
|
||||
/* Table Constructor called from the table add function */ \
|
||||
void baseType::construct##argNames##ConstructorTables() \
|
||||
{ \
|
||||
static bool constructed = false; \
|
||||
\
|
||||
if (!constructed) \
|
||||
{ \
|
||||
baseType::argNames##ConstructorTablePtr_ \
|
||||
= new baseType::argNames##ConstructorTable; \
|
||||
\
|
||||
constructed = true; \
|
||||
} \
|
||||
#define defineRunTimeSelectionTableConstructor(baseType,argNames) \
|
||||
\
|
||||
/* Table constructor called from the table add function */ \
|
||||
void baseType::construct##argNames##ConstructorTables() \
|
||||
{ \
|
||||
static bool constructed = false; \
|
||||
\
|
||||
if (!constructed) \
|
||||
{ \
|
||||
baseType::argNames##ConstructorTablePtr_ \
|
||||
= new baseType::argNames##ConstructorTable; \
|
||||
\
|
||||
constructed = true; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define defineRunTimeSelectionTableDestructor(baseType,argNames) \
|
||||
\
|
||||
/* Table destructor called from the table add function destructor */\
|
||||
void baseType::destroy##argNames##ConstructorTables() \
|
||||
{ \
|
||||
if (baseType::argNames##ConstructorTablePtr_) \
|
||||
{ \
|
||||
delete baseType::argNames##ConstructorTablePtr_; \
|
||||
baseType::argNames##ConstructorTablePtr_ = NULL; \
|
||||
} \
|
||||
#define defineRunTimeSelectionTableDestructor(baseType,argNames) \
|
||||
\
|
||||
/* Table destructor called from the table add function destructor */ \
|
||||
void baseType::destroy##argNames##ConstructorTables() \
|
||||
{ \
|
||||
if (baseType::argNames##ConstructorTablePtr_) \
|
||||
{ \
|
||||
delete baseType::argNames##ConstructorTablePtr_; \
|
||||
baseType::argNames##ConstructorTablePtr_ = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define defineRunTimeSelectionTablePtr(baseType,argNames) \
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
baseType::argNames##ConstructorTable* \
|
||||
#define defineRunTimeSelectionTablePtr(baseType,argNames) \
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
baseType::argNames##ConstructorTable* \
|
||||
baseType::argNames##ConstructorTablePtr_ = NULL
|
||||
|
||||
#define defineTemplateRunTimeSelectionTablePtr(baseType,argNames) \
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
typename baseType::argNames##ConstructorTable* \
|
||||
#define defineTemplateRunTimeSelectionTablePtr(baseType,argNames) \
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
typename baseType::argNames##ConstructorTable* \
|
||||
baseType::argNames##ConstructorTablePtr_ = NULL
|
||||
|
||||
#define defineRunTimeSelectionTable(baseType,argNames) \
|
||||
\
|
||||
defineRunTimeSelectionTablePtr(baseType,argNames); \
|
||||
defineRunTimeSelectionTableConstructor(baseType,argNames) \
|
||||
#define defineRunTimeSelectionTable(baseType,argNames) \
|
||||
\
|
||||
defineRunTimeSelectionTablePtr(baseType,argNames); \
|
||||
defineRunTimeSelectionTableConstructor(baseType,argNames) \
|
||||
defineRunTimeSelectionTableDestructor(baseType,argNames)
|
||||
|
||||
#define defineTemplateRunTimeSelectionTable(baseType,argNames) \
|
||||
\
|
||||
template<> \
|
||||
defineRunTimeSelectionTablePtr(baseType,argNames); \
|
||||
template<> \
|
||||
defineRunTimeSelectionTableConstructor(baseType,argNames) \
|
||||
template<> \
|
||||
#define defineTemplateRunTimeSelectionTable(baseType,argNames) \
|
||||
\
|
||||
template<> \
|
||||
defineRunTimeSelectionTablePtr(baseType,argNames); \
|
||||
template<> \
|
||||
defineRunTimeSelectionTableConstructor(baseType,argNames) \
|
||||
template<> \
|
||||
defineRunTimeSelectionTableDestructor(baseType,argNames)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user