Skip to content
Snippets Groups Projects
Commit 6dc5b6e9 authored by henry's avatar henry
Browse files

Added support for selection tables containing New functions rather than constructors.

parent 83bf5a7f
Branches
Tags
No related merge requests found
......@@ -28,6 +28,12 @@ Class
Description
Macros to enable the easy declaration of run-time selection tables.
declareRunTimeSelectionTable is used to create a run-time selection table
for a base-class which holds constructor pointers on the table.
declareRunTimeNewSelectionTable is used to create a run-time selection
table for a derived-class which holds "New" pointers on the table.
\*---------------------------------------------------------------------------*/
#include "token.H"
......@@ -86,6 +92,56 @@ Description
static void destroy##argNames##ConstructorTables()
#define declareRunTimeNewSelectionTable\
(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##baseType argList \
{ \
return autoPtr<baseType>(baseType##Type::New parList.ptr());\
} \
\
add##argNames##ConstructorToTable \
( \
const word& lookup = baseType##Type::typeName \
) \
{ \
construct##argNames##ConstructorTables(); \
argNames##ConstructorTablePtr_->insert \
( \
lookup, \
New##baseType \
); \
} \
\
~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 */ \
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment