mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
use runtime selection mechanism
This commit is contained in:
@ -30,8 +30,7 @@ Description
|
|||||||
|
|
||||||
#include "arcEdge.H"
|
#include "arcEdge.H"
|
||||||
#include "mathematicalConstants.H"
|
#include "mathematicalConstants.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -40,8 +39,7 @@ namespace Foam
|
|||||||
defineTypeNameAndDebug(arcEdge, 0);
|
defineTypeNameAndDebug(arcEdge, 0);
|
||||||
|
|
||||||
// Add the curvedEdge constructor functions to the hash tables
|
// Add the curvedEdge constructor functions to the hash tables
|
||||||
curvedEdge::addIstreamConstructorToTable<arcEdge>
|
addToRunTimeSelectionTable(curvedEdge, arcEdge, Istream);
|
||||||
addArcEdgeIstreamConstructorToTable_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,26 +41,7 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
defineTypeNameAndDebug(curvedEdge, 0);
|
defineTypeNameAndDebug(curvedEdge, 0);
|
||||||
|
defineRunTimeSelectionTable(curvedEdge, Istream);
|
||||||
// Define the constructor function hash tables
|
|
||||||
HashTable<curvedEdge::IstreamConstructorPtr_>*
|
|
||||||
curvedEdge::IstreamConstructorTablePtr_;
|
|
||||||
|
|
||||||
|
|
||||||
// Hash table Constructor called from the table add functions.
|
|
||||||
|
|
||||||
void curvedEdge::constructTables()
|
|
||||||
{
|
|
||||||
static bool constructed = false;
|
|
||||||
|
|
||||||
if (!constructed)
|
|
||||||
{
|
|
||||||
curvedEdge::IstreamConstructorTablePtr_
|
|
||||||
= new HashTable<curvedEdge::IstreamConstructorPtr_>;
|
|
||||||
|
|
||||||
constructed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -117,10 +98,11 @@ autoPtr<curvedEdge> curvedEdge::New(const pointField& points, Istream& is)
|
|||||||
|
|
||||||
word curvedEdgeType(is);
|
word curvedEdgeType(is);
|
||||||
|
|
||||||
HashTable<IstreamConstructorPtr_>::iterator curvedEdgeConstructorIter =
|
IstreamConstructorTable::iterator cstrIter =
|
||||||
IstreamConstructorTablePtr_->find(curvedEdgeType);
|
IstreamConstructorTablePtr_
|
||||||
|
->find(curvedEdgeType);
|
||||||
|
|
||||||
if (curvedEdgeConstructorIter == IstreamConstructorTablePtr_->end())
|
if (cstrIter == IstreamConstructorTablePtr_->end())
|
||||||
{
|
{
|
||||||
FatalErrorIn("curvedEdge::New(const pointField&, Istream&)")
|
FatalErrorIn("curvedEdge::New(const pointField&, Istream&)")
|
||||||
<< "Unknown curvedEdge type " << curvedEdgeType << endl << endl
|
<< "Unknown curvedEdge type " << curvedEdgeType << endl << endl
|
||||||
@ -129,7 +111,7 @@ autoPtr<curvedEdge> curvedEdge::New(const pointField& points, Istream& is)
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return autoPtr<curvedEdge>(curvedEdgeConstructorIter()(points, is));
|
return autoPtr<curvedEdge>(cstrIter()(points, is));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -177,7 +159,6 @@ Ostream& operator<<(Ostream& os, const curvedEdge& p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -63,51 +63,23 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor Hash tables
|
//- Runtime type information
|
||||||
|
TypeName("curvedEdge");
|
||||||
//- Construct from Istream function pointer type
|
|
||||||
typedef autoPtr<curvedEdge> (*IstreamConstructorPtr_)
|
|
||||||
(const pointField&, Istream&);
|
|
||||||
|
|
||||||
//- Construct from Istream function pointer table pointer
|
|
||||||
static HashTable<IstreamConstructorPtr_>*
|
|
||||||
IstreamConstructorTablePtr_;
|
|
||||||
|
|
||||||
|
|
||||||
// Hash table constructor classes and functions
|
// Declare run-time constructor selection tables
|
||||||
|
|
||||||
//- Hash table Constructor.
|
declareRunTimeSelectionTable
|
||||||
// Must be called from the table add functions below.
|
(
|
||||||
static void constructTables();
|
autoPtr,
|
||||||
|
curvedEdge,
|
||||||
|
Istream,
|
||||||
//- Class to add constructor from Istream to Hash table
|
|
||||||
template<class curvedEdgeType>
|
|
||||||
class addIstreamConstructorToTable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
static autoPtr<curvedEdge> New
|
|
||||||
(
|
(
|
||||||
const pointField& points,
|
const pointField& points,
|
||||||
Istream& is
|
Istream& is
|
||||||
)
|
),
|
||||||
{
|
(points, is)
|
||||||
return autoPtr<curvedEdge>(new curvedEdgeType(points, is));
|
);
|
||||||
}
|
|
||||||
|
|
||||||
addIstreamConstructorToTable()
|
|
||||||
{
|
|
||||||
curvedEdge::constructTables();
|
|
||||||
|
|
||||||
curvedEdge::IstreamConstructorTablePtr_
|
|
||||||
->insert(curvedEdgeType::typeName, New);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//- Runtime type information
|
|
||||||
TypeName("curvedEdge");
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|||||||
@ -26,6 +26,7 @@ License
|
|||||||
|
|
||||||
#include "polySplineEdge.H"
|
#include "polySplineEdge.H"
|
||||||
#include "BSpline.H"
|
#include "BSpline.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -34,8 +35,7 @@ namespace Foam
|
|||||||
defineTypeNameAndDebug(polySplineEdge, 0);
|
defineTypeNameAndDebug(polySplineEdge, 0);
|
||||||
|
|
||||||
// Add the curvedEdge constructor functions to the hash tables
|
// Add the curvedEdge constructor functions to the hash tables
|
||||||
curvedEdge::addIstreamConstructorToTable<polySplineEdge>
|
addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream);
|
||||||
addPolySplineEdgeIstreamConstructorToTable_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream setting pointsList
|
//- Construct from Istream setting pointsList
|
||||||
polySplineEdge(const pointField& points,Istream& is);
|
polySplineEdge(const pointField& points, Istream& is);
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|||||||
@ -27,9 +27,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
|
|
||||||
#include "simpleSplineEdge.H"
|
#include "simpleSplineEdge.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -39,10 +38,8 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
defineTypeNameAndDebug(simpleSplineEdge, 0);
|
defineTypeNameAndDebug(simpleSplineEdge, 0);
|
||||||
|
addToRunTimeSelectionTable(curvedEdge, simpleSplineEdge, Istream);
|
||||||
|
|
||||||
// Add the curvedEdge constructor functions to the hash tables
|
|
||||||
curvedEdge::addIstreamConstructorToTable<simpleSplineEdge>
|
|
||||||
addSimpleSplineEdgeIstreamConstructorToTable_;
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user