diff --git a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H
index f0978ed635..5535ad7510 100644
--- a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H
+++ b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -21,9 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
-InClass
- Foam::runTimeSelectionTables
-
Description
Macros for easy insertion into run-time selection tables
@@ -53,6 +50,26 @@ Description
add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_ \
(#lookup)
+
+// add to hash-table of functions with typename as the key
+#define addRemovableToRunTimeSelectionTable\
+(baseType,thisType,argNames) \
+ \
+ /* Add the thisType constructor function to the table */ \
+ baseType::addRemovable##argNames##ConstructorToTable< thisType > \
+ addRemovable##thisType##argNames##ConstructorTo##baseType##Table_
+
+
+// add to hash-table of functions with 'lookup' as the key
+#define addRemovableNamedToRunTimeSelectionTable\
+(baseType,thisType,argNames,lookup) \
+ \
+ /* Add the thisType constructor function to the table, find by lookup */ \
+ baseType::addRemovable##argNames##ConstructorToTable< thisType > \
+ addRemovable_##lookup##_##thisType##argNames##ConstructorTo \
+ ##baseType##Table_(#lookup)
+
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H
index 4ca3c15f55..977e0f124a 100644
--- a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H
+++ b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -21,11 +21,8 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
-Class
- Foam::runTimeSelectionTables
-
Description
- Macros to enable the easy declaration of run-time selection tables.
+ Macros to ease 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.
@@ -62,6 +59,12 @@ Description
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
+ /* 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(); \
+ \
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
@@ -88,11 +91,41 @@ Description
} \
}; \
\
- /* Table constructor called from the table add function */ \
- static void construct##argNames##ConstructorTables(); \
+ /* Class to add constructor from argList to table */ \
+ /* Remove only the entry (not the table) upon destruction */ \
+ template< class baseType##Type > \
+ class addRemovable##argNames##ConstructorToTable \
+ { \
+ /* retain lookup name for later removal */ \
+ const word& lookup_; \
\
- /* Table destructor called from the table add function destructor */ \
- static void destroy##argNames##ConstructorTables()
+ public: \
+ \
+ static autoPtr< baseType > New argList \
+ { \
+ return autoPtr< baseType >(new baseType##Type parList); \
+ } \
+ \
+ addRemovable##argNames##ConstructorToTable \
+ ( \
+ const word& lookup = baseType##Type::typeName \
+ ) \
+ : \
+ lookup_(lookup) \
+ { \
+ construct##argNames##ConstructorTables(); \
+ argNames##ConstructorTablePtr_->set(lookup, New); \
+ } \
+ \
+ ~addRemovable##argNames##ConstructorToTable() \
+ { \
+ if (argNames##ConstructorTablePtr_) \
+ { \
+ argNames##ConstructorTablePtr_->erase(lookup_); \
+ } \
+ } \
+ };
+
// external use:
@@ -111,6 +144,12 @@ Description
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
+ /* 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(); \
+ \
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
@@ -141,11 +180,43 @@ Description
} \
}; \
\
- /* Table constructor called from the table add function */ \
- static void construct##argNames##ConstructorTables(); \
+ /* Class to add constructor from argList to table */ \
+ template< class baseType##Type > \
+ class addRemovable##argNames##ConstructorToTable \
+ { \
+ /* retain lookup name for later removal */ \
+ const word& lookup_; \
\
- /* Table destructor called from the table add function destructor */ \
- static void destroy##argNames##ConstructorTables()
+ public: \
+ \
+ static autoPtr< baseType > New##baseType argList \
+ { \
+ return autoPtr< baseType >(baseType##Type::New parList.ptr()); \
+ } \
+ \
+ addRemovable##argNames##ConstructorToTable \
+ ( \
+ const word& lookup = baseType##Type::typeName \
+ ) \
+ : \
+ lookup_(lookup) \
+ { \
+ construct##argNames##ConstructorTables(); \
+ argNames##ConstructorTablePtr_->set \
+ ( \
+ lookup, \
+ New##baseType \
+ ); \
+ } \
+ \
+ ~addRemovable##argNames##ConstructorToTable() \
+ { \
+ if (argNames##ConstructorTablePtr_) \
+ { \
+ argNames##ConstructorTablePtr_->erase(lookup_); \
+ } \
+ } \
+ };
// internal use:
@@ -157,13 +228,11 @@ Description
void baseType::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType::argNames##ConstructorTablePtr_ \
= new baseType::argNames##ConstructorTable; \
- \
- constructed = true; \
} \
}
@@ -244,13 +313,11 @@ Description
void baseType< Targ >::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType< Targ >::argNames##ConstructorTablePtr_ \
= new baseType< Targ >::argNames##ConstructorTable; \
- \
- constructed = true; \
} \
}
diff --git a/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H
index 76481db279..1601c172a0 100644
--- a/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H
+++ b/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H
@@ -85,13 +85,14 @@ Description
} \
}
+
// internal use:
// constructor/destructor aid
#define defineGlobalFunctionSelectionTableConstructDestruct\
(memberFunction,argNames) \
\
/* Table constructor called from the table add function */ \
- void construct##memberFunction##argNames##MemberFunctionTables()\
+ void construct##memberFunction##argNames##MemberFunctionTables() \
{ \
static bool constructed = false; \
if (!constructed) \
@@ -103,7 +104,7 @@ Description
} \
\
/* Table destructor called from the table add function destructor */ \
- void destroy##memberFunction##argNames##MemberFunctionTables()\
+ void destroy##memberFunction##argNames##MemberFunctionTables() \
{ \
if (memberFunction##argNames##MemberFunctionTablePtr_) \
{ \
diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H
index 13835fbb3c..16a3accd41 100644
--- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H
+++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -98,13 +98,11 @@ Description
void baseType::construct##memberFunction##argNames##MemberFunctionTables()\
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType::memberFunction##argNames##MemberFunctionTable;\
- \
- constructed = true; \
} \
}
@@ -191,14 +189,12 @@ Description
MemberFunctionTables() \
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType::memberFunction##argNames## \
MemberFunctionTable; \
- \
- constructed = true; \
} \
}
@@ -254,6 +250,7 @@ Description
defineTemplatedMemberFunctionSelectionTableDestructor \
(baseType,memberFunction,argNames,Targ)
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
index c534d3e83c..a91f61c577 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -73,7 +73,7 @@ Ostream& operator<<(Ostream&, const fvPatchField&);
/*---------------------------------------------------------------------------*\
- Class patch Declaration
+ Class fvPatchField Declaration
\*---------------------------------------------------------------------------*/
template
@@ -516,11 +516,40 @@ public:
);
+// use with caution
+#define addRemovableToPatchFieldRunTimeSelection\
+(PatchTypeField, typePatchTypeField) \
+ \
+ addRemovableToRunTimeSelectionTable \
+ ( \
+ PatchTypeField, \
+ typePatchTypeField, \
+ patch \
+ ); \
+ addRemovableToRunTimeSelectionTable \
+ ( \
+ PatchTypeField, \
+ typePatchTypeField, \
+ patchMapper \
+ ); \
+ addRemovableToRunTimeSelectionTable \
+ ( \
+ PatchTypeField, \
+ typePatchTypeField, \
+ dictionary \
+ );
+
+
// for non-templated patch fields
#define makePatchTypeField(PatchTypeField, typePatchTypeField) \
defineTypeNameAndDebug(typePatchTypeField, 0); \
addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
+// for non-templated patch fields - use with caution
+#define makeRemovablePatchTypeField(PatchTypeField, typePatchTypeField) \
+ defineTypeNameAndDebug(typePatchTypeField, 0); \
+ addRemovableToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
+
// for templated patch fields
#define makeTemplatePatchTypeField(PatchTypeField, typePatchTypeField) \