COMP: improvements to selection table helper classes
- make constructors explicit, delete unused constructors
This commit is contained in:
parent
3238a63a10
commit
cb53ce3678
@ -58,7 +58,11 @@ struct addstopAtWriteNowSignalToOpt
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
addstopAtWriteNowSignalToOpt(const char* name)
|
||||
addstopAtWriteNowSignalToOpt(const addstopAtWriteNowSignalToOpt&) = delete;
|
||||
|
||||
void operator=(const addstopAtWriteNowSignalToOpt&) = delete;
|
||||
|
||||
explicit addstopAtWriteNowSignalToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
@ -67,7 +71,7 @@ struct addstopAtWriteNowSignalToOpt
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
sigStopAtWriteNow::signal_ = readLabel(is);
|
||||
is >> sigStopAtWriteNow::signal_;
|
||||
sigStopAtWriteNow::set(true);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,11 @@ struct addwriteNowSignalToOpt
|
||||
:
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
addwriteNowSignalToOpt(const char* name)
|
||||
addwriteNowSignalToOpt(const addwriteNowSignalToOpt&) = delete;
|
||||
|
||||
void operator=(const addwriteNowSignalToOpt&) = delete;
|
||||
|
||||
explicit addwriteNowSignalToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
@ -67,7 +71,7 @@ struct addwriteNowSignalToOpt
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
sigWriteNow::signal_ = readLabel(is);
|
||||
is >> sigWriteNow::signal_;
|
||||
sigWriteNow::set(true);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,11 @@ class addstopAtWriteNowSignalToOpt
|
||||
{
|
||||
public:
|
||||
|
||||
addstopAtWriteNowSignalToOpt(const char* name)
|
||||
addstopAtWriteNowSignalToOpt(const addstopAtWriteNowSignalToOpt&) = delete;
|
||||
|
||||
void operator=(const addstopAtWriteNowSignalToOpt&) = delete;
|
||||
|
||||
explicit addstopAtWriteNowSignalToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
@ -69,7 +73,7 @@ public:
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
sigStopAtWriteNow::signal_ = readLabel(is);
|
||||
is >> sigStopAtWriteNow::signal_;
|
||||
sigStopAtWriteNow::set(true);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,11 @@ class addwriteNowSignalToOpt
|
||||
{
|
||||
public:
|
||||
|
||||
addwriteNowSignalToOpt(const char* name)
|
||||
addwriteNowSignalToOpt(const addwriteNowSignalToOpt&) = delete;
|
||||
|
||||
void operator=(const addwriteNowSignalToOpt&) = delete;
|
||||
|
||||
explicit addwriteNowSignalToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
@ -69,7 +73,7 @@ public:
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
sigWriteNow::signal_ = readLabel(is);
|
||||
is >> sigWriteNow::signal_;
|
||||
sigWriteNow::set(true);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ Foam::IOobject::fileCheckTypes Foam::IOobject::fileModificationChecking
|
||||
);
|
||||
|
||||
|
||||
//! \cond file-scope
|
||||
namespace Foam
|
||||
{
|
||||
// Register re-reader
|
||||
@ -70,7 +71,13 @@ namespace Foam
|
||||
{
|
||||
public:
|
||||
|
||||
addfileModificationCheckingToOpt(const char* name)
|
||||
addfileModificationCheckingToOpt
|
||||
(const addfileModificationCheckingToOpt&) = delete;
|
||||
|
||||
void operator=
|
||||
(const addfileModificationCheckingToOpt&) = delete;
|
||||
|
||||
explicit addfileModificationCheckingToOpt(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||
{}
|
||||
@ -94,7 +101,9 @@ namespace Foam
|
||||
(
|
||||
"fileModificationChecking"
|
||||
);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
//! \endcond
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -74,7 +75,7 @@ Description
|
||||
return autoPtr<baseType>(new baseType##Type parList); \
|
||||
} \
|
||||
\
|
||||
add##argNames##ConstructorToTable \
|
||||
explicit add##argNames##ConstructorToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
@ -93,6 +94,12 @@ Description
|
||||
{ \
|
||||
destroy##argNames##ConstructorTables(); \
|
||||
} \
|
||||
\
|
||||
add##argNames##ConstructorToTable \
|
||||
(const add##argNames##ConstructorToTable&) = delete; \
|
||||
\
|
||||
void operator= \
|
||||
(const add##argNames##ConstructorToTable&) = delete; \
|
||||
}; \
|
||||
\
|
||||
/* Class to add constructor from argList to table */ \
|
||||
@ -100,22 +107,21 @@ Description
|
||||
template<class baseType##Type> \
|
||||
class addRemovable##argNames##ConstructorToTable \
|
||||
{ \
|
||||
/* retain lookup name for later removal */ \
|
||||
const word& lookup_; \
|
||||
\
|
||||
public: \
|
||||
\
|
||||
const word name; /* Lookup name for later removal */ \
|
||||
\
|
||||
static autoPtr<baseType> New argList \
|
||||
{ \
|
||||
return autoPtr<baseType>(new baseType##Type parList); \
|
||||
} \
|
||||
\
|
||||
addRemovable##argNames##ConstructorToTable \
|
||||
explicit addRemovable##argNames##ConstructorToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
: \
|
||||
lookup_(lookup) \
|
||||
name(lookup) \
|
||||
{ \
|
||||
construct##argNames##ConstructorTables(); \
|
||||
argNames##ConstructorTablePtr_->set(lookup, New); \
|
||||
@ -125,9 +131,15 @@ Description
|
||||
{ \
|
||||
if (argNames##ConstructorTablePtr_) \
|
||||
{ \
|
||||
argNames##ConstructorTablePtr_->erase(lookup_); \
|
||||
argNames##ConstructorTablePtr_->erase(name); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
addRemovable##argNames##ConstructorToTable \
|
||||
(const addRemovable##argNames##ConstructorToTable&) = delete; \
|
||||
\
|
||||
void operator= \
|
||||
(const addRemovable##argNames##ConstructorToTable&) = delete; \
|
||||
};
|
||||
|
||||
|
||||
@ -163,7 +175,7 @@ Description
|
||||
return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
|
||||
} \
|
||||
\
|
||||
add##argNames##ConstructorToTable \
|
||||
explicit add##argNames##ConstructorToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
@ -189,28 +201,33 @@ Description
|
||||
{ \
|
||||
destroy##argNames##ConstructorTables(); \
|
||||
} \
|
||||
\
|
||||
add##argNames##ConstructorToTable \
|
||||
(const add##argNames##ConstructorToTable&) = delete; \
|
||||
\
|
||||
void operator= \
|
||||
(const add##argNames##ConstructorToTable&) = delete; \
|
||||
}; \
|
||||
\
|
||||
/* 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_; \
|
||||
\
|
||||
public: \
|
||||
\
|
||||
const word name; /* Lookup name for later removal */ \
|
||||
\
|
||||
static autoPtr<baseType> New##baseType argList \
|
||||
{ \
|
||||
return autoPtr<baseType>(baseType##Type::New parList.ptr()); \
|
||||
} \
|
||||
\
|
||||
addRemovable##argNames##ConstructorToTable \
|
||||
explicit addRemovable##argNames##ConstructorToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
: \
|
||||
lookup_(lookup) \
|
||||
name(lookup) \
|
||||
{ \
|
||||
construct##argNames##ConstructorTables(); \
|
||||
argNames##ConstructorTablePtr_->set \
|
||||
@ -224,9 +241,15 @@ Description
|
||||
{ \
|
||||
if (argNames##ConstructorTablePtr_) \
|
||||
{ \
|
||||
argNames##ConstructorTablePtr_->erase(lookup_); \
|
||||
argNames##ConstructorTablePtr_->erase(name); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
addRemovable##argNames##ConstructorToTable \
|
||||
(const addRemovable##argNames##ConstructorToTable&) = delete; \
|
||||
\
|
||||
void operator= \
|
||||
(const addRemovable##argNames##ConstructorToTable&) = delete; \
|
||||
};
|
||||
|
||||
|
||||
@ -265,7 +288,7 @@ Description
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
baseType::argNames##ConstructorTable* \
|
||||
baseType::argNames##ConstructorTablePtr_ = nullptr
|
||||
baseType::argNames##ConstructorTablePtr_(nullptr)
|
||||
|
||||
|
||||
|
||||
@ -329,7 +352,7 @@ Description
|
||||
\
|
||||
/* Define the constructor function table */ \
|
||||
baseType<Targ>::argNames##ConstructorTable* \
|
||||
baseType<Targ>::argNames##ConstructorTablePtr_ = nullptr
|
||||
baseType<Targ>::argNames##ConstructorTablePtr_(nullptr)
|
||||
|
||||
|
||||
//- Define run-time selection table for template classes
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,9 +24,6 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::memberFunctionSelectionTables
|
||||
|
||||
Description
|
||||
Macros to enable the easy declaration of member function selection tables.
|
||||
|
||||
@ -62,7 +60,7 @@ Description
|
||||
{ \
|
||||
public: \
|
||||
\
|
||||
add##memberFunction##argNames##MemberFunctionToTable \
|
||||
explicit add##memberFunction##argNames##MemberFunctionToTable \
|
||||
( \
|
||||
const word& lookup = baseType##Type::typeName \
|
||||
) \
|
||||
@ -114,9 +112,10 @@ Description
|
||||
{ \
|
||||
if (baseType::memberFunction##argNames##MemberFunctionTablePtr_) \
|
||||
{ \
|
||||
delete baseType::memberFunction##argNames##MemberFunctionTablePtr_;\
|
||||
baseType::memberFunction##argNames##MemberFunctionTablePtr_ = \
|
||||
nullptr; \
|
||||
delete baseType::memberFunction##argNames## \
|
||||
MemberFunctionTablePtr_; \
|
||||
baseType::memberFunction##argNames## \
|
||||
MemberFunctionTablePtr_ = nullptr; \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -126,8 +125,7 @@ Description
|
||||
\
|
||||
/* Define the memberFunction table */ \
|
||||
baseType::memberFunction##argNames##MemberFunctionTable* \
|
||||
baseType::memberFunction##argNames##MemberFunctionTablePtr_ = nullptr
|
||||
|
||||
baseType::memberFunction##argNames##MemberFunctionTablePtr_(nullptr)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -189,10 +187,7 @@ Description
|
||||
void baseType<Targ>::destroy##memberFunction##argNames## \
|
||||
MemberFunctionTables() \
|
||||
{ \
|
||||
if \
|
||||
( \
|
||||
baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ \
|
||||
) \
|
||||
if (baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_) \
|
||||
{ \
|
||||
delete baseType<Targ>::memberFunction##argNames## \
|
||||
MemberFunctionTablePtr_; \
|
||||
@ -209,8 +204,8 @@ Description
|
||||
\
|
||||
/* Define the memberFunction table */ \
|
||||
baseType<Targ>::memberFunction##argNames##MemberFunctionTable* \
|
||||
baseType<Targ>::memberFunction##argNames##MemberFunctionTablePtr_ = \
|
||||
nullptr
|
||||
baseType<Targ>::memberFunction##argNames## \
|
||||
MemberFunctionTablePtr_(nullptr)
|
||||
|
||||
|
||||
//- Define run-time selection table for template classes
|
||||
|
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,6 +45,8 @@ dictionary* dimensionSystemsPtr_(nullptr);
|
||||
HashTable<dimensionedScalar>* unitSetPtr_(nullptr);
|
||||
dimensionSets* writeUnitSetPtr_(nullptr);
|
||||
|
||||
//! \cond file-scope
|
||||
|
||||
// Helper class to
|
||||
// register re-reader
|
||||
// deallocate demand-driven data
|
||||
@ -52,17 +55,22 @@ class addDimensionSetsToDebug
|
||||
public ::Foam::simpleRegIOobject
|
||||
{
|
||||
public:
|
||||
addDimensionSetsToDebug(const char* name)
|
||||
|
||||
addDimensionSetsToDebug(const addDimensionSetsToDebug&) = delete;
|
||||
void operator=(const addDimensionSetsToDebug&) = delete;
|
||||
|
||||
explicit addDimensionSetsToDebug(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addDimensionSetObject, name)
|
||||
{}
|
||||
|
||||
virtual ~addDimensionSetsToDebug()
|
||||
{
|
||||
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||
deleteDemandDrivenData(unitSetPtr_);
|
||||
deleteDemandDrivenData(writeUnitSetPtr_);
|
||||
|
||||
}
|
||||
|
||||
virtual void readData(Foam::Istream& is)
|
||||
{
|
||||
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||
@ -70,19 +78,23 @@ public:
|
||||
deleteDemandDrivenData(writeUnitSetPtr_);
|
||||
dimensionSystemsPtr_ = new dictionary(is);
|
||||
}
|
||||
|
||||
virtual void writeData(Foam::Ostream& os) const
|
||||
{
|
||||
os << dimensionSystems();
|
||||
}
|
||||
};
|
||||
|
||||
addDimensionSetsToDebug addDimensionSetsToDebug_("DimensionSets");
|
||||
|
||||
//! \endcond
|
||||
|
||||
|
||||
dictionary& dimensionSystems()
|
||||
{
|
||||
if (!dimensionSystemsPtr_)
|
||||
{
|
||||
dictionary* cachedPtr = nullptr;
|
||||
dictionary* cachedPtr(nullptr);
|
||||
dimensionSystemsPtr_ = new dictionary
|
||||
(
|
||||
debug::switchSet
|
||||
@ -158,8 +170,8 @@ const HashTable<dimensionedScalar>& unitSet()
|
||||
}
|
||||
|
||||
writeUnitSetPtr_ = new dimensionSets(*unitSetPtr_, writeUnitNames);
|
||||
|
||||
}
|
||||
|
||||
return *unitSetPtr_;
|
||||
}
|
||||
|
||||
@ -208,6 +220,7 @@ const dimensionSet dimDynamicViscosity(dimDensity*dimViscosity);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::dimensionSets::dimensionSets
|
||||
|
@ -52,9 +52,15 @@ public:
|
||||
//- The unique RegisterDebugSwitch object
|
||||
static const RegisterDebugSwitch registerDebugSwitch;
|
||||
|
||||
RegisterDebugSwitch(const char* name)
|
||||
//- No copy construct
|
||||
RegisterDebugSwitch(const RegisterDebugSwitch<Type>&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const RegisterDebugSwitch<Type>&) = delete;
|
||||
|
||||
explicit RegisterDebugSwitch(const char* name)
|
||||
:
|
||||
::Foam::simpleRegIOobject(Foam::debug::addDebugObject, name)
|
||||
::Foam::simpleRegIOobject(::Foam::debug::addDebugObject, name)
|
||||
{}
|
||||
|
||||
virtual ~RegisterDebugSwitch() = default;
|
||||
@ -72,6 +78,7 @@ public:
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define registerTemplateDebugSwitchWithName(Type,Name) \
|
||||
@ -87,19 +94,26 @@ public:
|
||||
public ::Foam::simpleRegIOobject \
|
||||
{ \
|
||||
public: \
|
||||
add##Tag##ToDebug(const char* name) \
|
||||
\
|
||||
explicit add##Tag##ToDebug(const char* name) \
|
||||
: \
|
||||
::Foam::simpleRegIOobject(::Foam::debug::addDebugObject, name) \
|
||||
{} \
|
||||
\
|
||||
virtual ~add##Tag##ToDebug() = default; \
|
||||
\
|
||||
virtual void readData(::Foam::Istream& is) \
|
||||
{ \
|
||||
is >> Type::debug; \
|
||||
} \
|
||||
\
|
||||
virtual void writeData(::Foam::Ostream& os) const \
|
||||
{ \
|
||||
os << Type::debug; \
|
||||
} \
|
||||
\
|
||||
add##Tag##ToDebug(const add##Tag##ToDebug&) = delete; \
|
||||
void operator=(const add##Tag##ToDebug&) = delete; \
|
||||
}; \
|
||||
add##Tag##ToDebug add##Tag##ToDebug_(Name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user