ENH: refactor some function entries to reduce code duplication

This commit is contained in:
Mark Olesen
2019-08-21 11:19:54 +02:00
committed by Andrew Heather
parent 3f06722a07
commit c0fce5c762
18 changed files with 362 additions and 316 deletions

View File

@ -13,6 +13,7 @@
#sinclude | dict/primitive | string
#includeIfPresent | dict/primitive | string
#includeEtc | dict/primitive | string
#sincludeEtc | dict/primitive | string
#includeFunc | dict | word
| |
#calc | dict/primitive | string
@ -30,4 +31,4 @@ Pending future extensions
#undef | dict | keyType or List<keyType>
2018-05-28
2019-08-21

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2013 OpenFOAM Foundation
@ -54,17 +54,15 @@ namespace functionEntries
primitiveEntryIstream,
calc
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::functionEntries::calcEntry::execute
Foam::string Foam::functionEntries::calcEntry::evaluate
(
const dictionary& parentDict,
primitiveEntry& thisEntry,
Istream& is
)
{
@ -74,34 +72,40 @@ bool Foam::functionEntries::calcEntry::execute
dynamicCode::checkSecurity
(
"functionEntries::calcEntry::execute(..)",
"functionEntries::calcEntry::evaluate(..)",
parentDict
);
// Read string
string s(is);
// Make sure we stop this entry
//is.putBack(token(token::END_STATEMENT, is.lineNumber()));
// Construct codeDict for codeStream
// must reference parent for stringOps::expand to work nicely.
dictionary codeSubDict;
codeSubDict.add("code", "os << (" + s + ");");
dictionary codeDict(parentDict, codeSubDict);
codeStream::streamingFunctionType function = codeStream::getFunction
(
parentDict,
codeDict
);
// use function to write stream
// Use function to write stream
OStringStream os(is.format());
streamingFunctionType function = getFunction(parentDict, codeDict);
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
thisEntry.read(parentDict, resultStream);
// Return evaluated content as string
return os.str();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::calcEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
IStringStream result(evaluate(parentDict, is));
entry.read(parentDict, result);
return true;
}
@ -113,40 +117,8 @@ bool Foam::functionEntries::calcEntry::execute
Istream& is
)
{
DetailInfo
<< "Using #calc at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::calcEntry::execute(..)",
parentDict
);
// Read string
string s(is);
// Make sure we stop this entry
//is.putBack(token(token::END_STATEMENT, is.lineNumber()));
// Construct codeDict for codeStream
// must reference parent for stringOps::expand to work nicely.
dictionary codeSubDict;
codeSubDict.add("code", "os << (" + s + ");");
dictionary codeDict(parentDict, codeSubDict);
codeStream::streamingFunctionType function = codeStream::getFunction
(
parentDict,
codeDict
);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
parentDict.read(resultStream);
IStringStream result(evaluate(parentDict, is));
parentDict.read(result);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2013 OpenFOAM Foundation
@ -53,14 +53,12 @@ SourceFiles
#ifndef calcEntry_H
#define calcEntry_H
#include "functionEntry.H"
#include "codeStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class dlLibraryTable;
namespace functionEntries
{
@ -70,21 +68,26 @@ namespace functionEntries
class calcEntry
:
public functionEntry
public codeStream
{
// Private Member Functions
//- Evaluate dynamically compiled code, returning result as string
static string evaluate(const dictionary& parentDict, Istream& is);
public:
//- Execute in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,
primitiveEntry& thisEntry,
primitiveEntry& entry,
Istream& is
);
//- Execute in a sub-dict context
static bool execute(dictionary& parentDict, Istream& is);
};

View File

@ -57,8 +57,8 @@ namespace functionEntries
primitiveEntryIstream,
codeStream
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -327,12 +327,9 @@ Foam::functionEntries::codeStream::getFunction
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::codeStream::execute
Foam::string Foam::functionEntries::codeStream::evaluate
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
@ -342,23 +339,35 @@ bool Foam::functionEntries::codeStream::execute
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
"functionEntries::codeStream::evaluate(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
// Get code dictionary
dictionary codeDict("#codeStream", parentDict, is);
streamingFunctionType function = getFunction(parentDict, codeDict);
// use function to write stream
// Use function to write stream
OStringStream os(is.format());
streamingFunctionType function = getFunction(parentDict, codeDict);
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);
// Return evaluated content as string
return os.str();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::codeStream::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
IStringStream result(evaluate(parentDict, is));
entry.read(parentDict, result);
return true;
}
@ -370,29 +379,8 @@ bool Foam::functionEntries::codeStream::execute
Istream& is
)
{
DetailInfo
<< "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
streamingFunctionType function = getFunction(parentDict, codeDict);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
parentDict.read(resultStream);
IStringStream result(evaluate(parentDict, is));
parentDict.read(result);
return true;
}

View File

@ -117,15 +117,15 @@ class codeStream
:
public functionEntry
{
protected:
//- Interpreter function type
typedef void (*streamingFunctionType)(Ostream&, const dictionary&);
// Private Member Functions
// Protected Member Functions
//- Helper function: access IOobject for master-only-reading
// functionality
//- Helper: access IOobject for master-only-reading functionality
static bool doingMasterOnlyReading(const dictionary& dict);
//- Helper function: access to dlLibraryTable of Time
@ -139,27 +139,14 @@ class codeStream
);
//- No copy construct
codeStream(const codeStream&) = delete;
//- No copy assignment
void operator=(const codeStream&) = delete;
//- Evaluate dynamically compiled code, returning result as string
static string evaluate(const dictionary& parentDict, Istream& is);
public:
// Static Data Members
//- Name of the C code template to be used
static constexpr const char* const codeTemplateC
= "codeStreamTemplate.C";
// Related types
//- Declare friendship with the calcEntry class
friend class calcEntry;
//- Name of the C code template to be used
static constexpr const char* const codeTemplateC = "codeStreamTemplate.C";
//- Runtime type information
ClassName("codeStream");
@ -167,10 +154,7 @@ public:
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream& is);
//- Execute the functionEntry in a primitiveEntry context
//- Execute in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,
@ -178,6 +162,8 @@ public:
Istream& is
);
//- Execute in a sub-dict context
static bool execute(dictionary& parentDict, Istream& is);
};

View File

@ -46,7 +46,7 @@ namespace Foam
execute,
primitiveEntryIstream
);
}
} // End namespace Foam
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -90,9 +90,8 @@ bool Foam::functionEntry::execute
if (!executedictionaryIstreamMemberFunctionTablePtr_)
{
cerr<< "functionEntry::execute"
<< "(const word&, dictionary&, Istream&)"
<< " not yet initialized, function = "
cerr<< FUNCTION_NAME << nl
<< "Not yet initialized, function = "
<< functionName.c_str() << std::endl;
// Return true to keep reading
@ -129,12 +128,11 @@ bool Foam::functionEntry::execute
if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
{
cerr<< "functionEntry::execute"
<< "(const word&, const dictionary&, primitiveEntry&, Istream&)"
<< " not yet initialized, function = "
cerr<< FUNCTION_NAME << nl
<< "Not yet initialized, function = "
<< functionName.c_str() << std::endl;
// return true to keep reading anyhow
// Return true to keep reading anyhow
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,25 +32,25 @@ template<class StringType>
Foam::List<StringType>
Foam::functionEntry::readStringList(Istream& is)
{
List<StringType> list;
ISstream& iss = dynamic_cast<ISstream&>(is);
token firstToken(iss);
List<StringType> list;
const bool isStringTok = firstToken.isStringType();
if (firstToken.isWord() || firstToken.isString())
iss.putBack(firstToken);
if (isStringTok)
{
// The first token appears viable as non-list
// - treated like list with one entry
// - treated like list with a single entry
iss.putBack(firstToken);
list.setSize(1);
iss >> list[0];
list.resize(1);
iss >> list.first();
}
else
{
iss.putBack(firstToken);
iss >> list;
}

View File

@ -45,8 +45,8 @@ namespace functionEntries
dictionaryIstream,
if
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -86,13 +86,6 @@ class ifEntry
Istream& is
);
//- Disallow default bitwise copy construct
ifEntry(const ifEntry&);
//- Disallow default bitwise assignment
void operator=(const ifEntry&);
public:
//- Runtime type information

View File

@ -47,8 +47,8 @@ namespace functionEntries
dictionaryIstream,
ifeq
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -81,7 +81,7 @@ Foam::token Foam::functionEntries::ifeqEntry::expand
{
if (keyword[0] == '$')
{
const word varName(keyword.substr(1, keyword.size()-1));
const word varName(keyword.substr(1));
// Lookup the variable name in the given dictionary
const entry* ePtr = dict.findScoped(varName, keyType::REGEX_RECURSIVE);
@ -264,7 +264,8 @@ void Foam::functionEntries::ifeqEntry::skipUntil
}
FatalIOErrorInFunction(parentDict)
<< "Did not find matching " << endWord << exit(FatalIOError);
<< "Did not find matching " << endWord << nl
<< exit(FatalIOError);
}

View File

@ -158,17 +158,6 @@ protected:
);
private:
// Private Member Functions
//- Disallow default bitwise copy construct
ifeqEntry(const ifeqEntry&);
//- Disallow default bitwise assignment
void operator=(const ifeqEntry&);
public:
//- Runtime type information

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -96,8 +96,8 @@ namespace functionEntries
primitiveEntryIstream,
includeIfPresent
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
@ -125,6 +125,107 @@ Foam::fileName Foam::functionEntries::includeEntry::resolveFile
}
bool Foam::functionEntries::includeEntry::execute
(
const bool mandatory,
dictionary& parentDict,
Istream& is
)
{
const fileName rawName(is);
const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
auto& ifs = *ifsPtr;
if (ifs)
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
}
// Add watch on included file
const dictionary& top = parentDict.topDict();
if (isA<regIOobject>(top))
{
regIOobject& rio = const_cast<regIOobject&>
(
dynamic_cast<const regIOobject&>(top)
);
rio.addWatch(fName);
}
parentDict.read(ifs);
return true;
}
if (!mandatory)
{
return true; // Never fails if optional
}
FatalIOErrorInFunction(is)
<< "Cannot open include file "
<< (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
return false;
}
bool Foam::functionEntries::includeEntry::execute
(
const bool mandatory,
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
const fileName rawName(is);
const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
auto& ifs = *ifsPtr;
if (ifs)
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
}
// Add watch on included file
const dictionary& top = parentDict.topDict();
if (isA<regIOobject>(top))
{
regIOobject& rio = const_cast<regIOobject&>
(
dynamic_cast<const regIOobject&>(top)
);
rio.addWatch(fName);
}
entry.read(parentDict, ifs);
return true;
}
if (!mandatory)
{
return true; // Never fails if optional
}
FatalIOErrorInFunction(is)
<< "Cannot open include file "
<< (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
return false;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeEntry::execute
@ -133,41 +234,7 @@ bool Foam::functionEntries::includeEntry::execute
Istream& is
)
{
const fileName rawName(is);
const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
auto& ifs = *ifsPtr;
if (ifs)
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
}
// Add watch on included file
const dictionary& top = parentDict.topDict();
if (isA<regIOobject>(top))
{
regIOobject& rio = const_cast<regIOobject&>
(
dynamic_cast<const regIOobject&>(top)
);
rio.addWatch(fName);
}
parentDict.read(ifs);
return true;
}
FatalIOErrorInFunction(is)
<< "Cannot open include file "
<< (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
return false;
return includeEntry::execute(true, parentDict, is);
}
@ -178,41 +245,7 @@ bool Foam::functionEntries::includeEntry::execute
Istream& is
)
{
const fileName rawName(is);
const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
auto& ifs = *ifsPtr;
if (ifs)
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
}
// Add watch on included file
const dictionary& top = parentDict.topDict();
if (isA<regIOobject>(top))
{
regIOobject& rio = const_cast<regIOobject&>
(
dynamic_cast<const regIOobject&>(top)
);
rio.addWatch(fName);
}
entry.read(parentDict, ifs);
return true;
}
FatalIOErrorInFunction(is)
<< "Cannot open include file "
<< (ifs.name().size() ? ifs.name() : rawName)
<< " while reading dictionary " << parentDict.name()
<< exit(FatalIOError);
return false;
return includeEntry::execute(true, parentDict, entry, is);
}
@ -222,34 +255,7 @@ bool Foam::functionEntries::sincludeEntry::execute
Istream& is
)
{
const fileName rawName(is);
const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
auto& ifs = *ifsPtr;
if (ifs)
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
}
// Add watch on included file
const dictionary& top = parentDict.topDict();
if (isA<regIOobject>(top))
{
regIOobject& rio = const_cast<regIOobject&>
(
dynamic_cast<const regIOobject&>(top)
);
rio.addWatch(fName);
}
parentDict.read(ifs);
}
return true; // Never fails
return includeEntry::execute(false, parentDict, is);
}
@ -260,34 +266,7 @@ bool Foam::functionEntries::sincludeEntry::execute
Istream& is
)
{
const fileName rawName(is);
const fileName fName(resolveFile(is.name().path(), rawName, parentDict));
autoPtr<ISstream> ifsPtr(fileHandler().NewIFstream(fName));
auto& ifs = *ifsPtr;
if (ifs)
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
}
// Add watch on included file
const dictionary& top = parentDict.topDict();
if (isA<regIOobject>(top))
{
regIOobject& rio = const_cast<regIOobject&>
(
dynamic_cast<const regIOobject&>(top)
);
rio.addWatch(fName);
}
entry.read(parentDict, ifs);
}
return true; // Never fails
return includeEntry::execute(false, parentDict, entry, is);
}

View File

@ -84,10 +84,27 @@ protected:
const dictionary& dict
);
//- Include file in a sub-dict context
static bool execute
(
const bool mandatory,
dictionary& parentDict,
Istream& is
);
//- Include file in a primitiveEntry context
static bool execute
(
const bool mandatory,
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
);
public:
// Static data members
// Static Data Members
//- Report to stdout which file is included
static bool log;
@ -115,8 +132,8 @@ public:
//- A dictionary directive for conditionally including a file,
//- expects a single string to follow.
//
// The \c \#sinclude directive (and the \c \#includeIfPresent alias) behaves
// identically to the \c \#include directive, but does not generate an error
// The \c \#sinclude directive behaves identically to the
// \c \#include directive, but does not generate an error
// if the file does not exist.
class sincludeEntry
:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015-2017 OpenFOAM Foundation
@ -59,8 +59,27 @@ namespace functionEntries
primitiveEntryIstream,
includeEtc
);
}
}
addNamedToMemberFunctionSelectionTable
(
functionEntry,
sincludeEtcEntry,
execute,
dictionaryIstream,
sincludeEtc
);
addNamedToMemberFunctionSelectionTable
(
functionEntry,
sincludeEtcEntry,
execute,
primitiveEntryIstream,
sincludeEtc
);
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
@ -86,10 +105,9 @@ Foam::fileName Foam::functionEntries::includeEtcEntry::resolveEtcFile
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeEtcEntry::execute
(
const bool mandatory,
dictionary& parentDict,
Istream& is
)
@ -110,6 +128,11 @@ bool Foam::functionEntries::includeEtcEntry::execute
return true;
}
if (!mandatory)
{
return true; // Never fails if optional
}
FatalIOErrorInFunction(is)
<< "Cannot open etc file "
<< (ifs.name().size() ? ifs.name() : rawName)
@ -122,6 +145,7 @@ bool Foam::functionEntries::includeEtcEntry::execute
bool Foam::functionEntries::includeEtcEntry::execute
(
const bool mandatory,
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
@ -143,6 +167,11 @@ bool Foam::functionEntries::includeEtcEntry::execute
return true;
}
if (!mandatory)
{
return true; // Never fails if optional
}
FatalIOErrorInFunction(is)
<< "Cannot open etc file "
<< (ifs.name().size() ? ifs.name() : rawName)
@ -153,4 +182,48 @@ bool Foam::functionEntries::includeEtcEntry::execute
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeEtcEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
return includeEtcEntry::execute(true, parentDict, is);
}
bool Foam::functionEntries::includeEtcEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
return includeEtcEntry::execute(true, parentDict, entry, is);
}
bool Foam::functionEntries::sincludeEtcEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
return includeEtcEntry::execute(false, parentDict, is);
}
bool Foam::functionEntries::sincludeEtcEntry::execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
)
{
return includeEtcEntry::execute(false, parentDict, entry, is);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015-2016 OpenFOAM Foundation
@ -80,9 +80,26 @@ protected:
const dictionary& dict
);
//- Include file in a sub-dict context
static bool execute
(
const bool mandatory,
dictionary& parentDict,
Istream& is
);
//- Include file in a primitiveEntry context
static bool execute
(
const bool mandatory,
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
);
public:
// Static data members
// Static Data Members
//- Report to stdout which file is included
static bool log;
@ -90,10 +107,10 @@ public:
// Member Functions
//- Include file in a sub-dict context
//- Include etc file in a sub-dict context
static bool execute(dictionary& parentDict, Istream& is);
//- Include file in a primitiveEntry context
//- Include etc file in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,
@ -103,6 +120,35 @@ public:
};
/*---------------------------------------------------------------------------*\
Class sincludeEtcEntry Declaration
\*---------------------------------------------------------------------------*/
//- A dictionary directive for conditionally including an etc file,
//- expects a single string to follow.
//
// The \c \#sincludeEtc directive is identically to the
// \c \#includeEtc directive, but does not generate an error
// if the file does not exist.
class sincludeEtcEntry
:
public includeEtcEntry
{
public:
//- Include etc file (if it exists) in a sub-dict context
static bool execute(dictionary& parentDict, Istream& is);
//- Include etc file (if it exists) in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,
primitiveEntry& entry,
Istream& is
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries

View File

@ -43,8 +43,8 @@ namespace functionEntries
dictionaryIstream,
includeFunc
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -86,8 +86,8 @@ namespace functionEntries
dictionaryIstream,
error
);
}
}
} // End namespace functionEntries
} // End namespace Foam
const Foam::Enum
@ -119,7 +119,7 @@ bool Foam::functionEntries::inputMode::execute
// Like Enum::lookupOrDefault() with failsafe behaviour
if (selectableNames.found(modeName))
{
entry::globalInputMode = selectableNames[modeName];
entry::globalInputMode = selectableNames.get(modeName);
}
else
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
@ -44,8 +44,8 @@ namespace functionEntries
dictionaryIstream,
remove
);
}
}
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //