Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
cb53ce36
Commit
cb53ce36
authored
Nov 12, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Nov 12, 2019
Browse files
COMP: improvements to selection table helper classes
- make constructors explicit, delete unused constructors
parent
3238a63a
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/OSspecific/MSwindows/signals/sigStopAtWriteNow.C
View file @
cb53ce36
...
...
@@ -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
);
}
...
...
src/OSspecific/MSwindows/signals/sigWriteNow.C
View file @
cb53ce36
...
...
@@ -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
);
}
...
...
src/OSspecific/POSIX/signals/sigStopAtWriteNow.C
View file @
cb53ce36
...
...
@@ -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
);
}
...
...
src/OSspecific/POSIX/signals/sigWriteNow.C
View file @
cb53ce36
...
...
@@ -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
);
}
...
...
src/OpenFOAM/db/IOobject/IOobject.C
View file @
cb53ce36
...
...
@@ -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 * * * * * * * * * * * * * //
...
...
src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H
View file @
cb53ce36
...
...
@@ -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
...
...
src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H
View file @
cb53ce36
...
...
@@ -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
...
...
src/OpenFOAM/dimensionSet/dimensionSets.C
View file @
cb53ce36
...
...
@@ -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
...
...
src/OpenFOAM/global/debug/defineDebugSwitch.H
View file @
cb53ce36
...
...
@@ -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)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment