mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: refactor IOobject options
- IOobjectOption class encapsulates read/write, storage flags for
lightweight handling, independent of objectRegistry etc.
ENH: add IOobject isReadRequired() and isReadOptional() queries
- encapsulates test of MUST_READ, MUST_READ_IF_MODIFIED,
READ_IF_PRESENT for convenience / less clutter.
Example,
if (isReadRequired() || (isReadOptional() && headerOk()))
{
...
}
Instead of
if
(
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
...
}
This commit is contained in:
@ -55,8 +55,8 @@ const Foam::Enum
|
||||
>
|
||||
Foam::functionObjects::writeObjects::writeOptionNames_
|
||||
({
|
||||
{ writeOption::AUTO_WRITE, "autoWrite" },
|
||||
{ writeOption::NO_WRITE, "noWrite" },
|
||||
{ writeOption::AUTO_WRITE, "autoWrite" },
|
||||
{ writeOption::ANY_WRITE, "anyWrite" },
|
||||
});
|
||||
|
||||
@ -173,16 +173,7 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
|
||||
switch (writeOption_)
|
||||
{
|
||||
case AUTO_WRITE:
|
||||
{
|
||||
if (obj.writeOpt() != IOobject::AUTO_WRITE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NO_WRITE:
|
||||
case writeOption::NO_WRITE:
|
||||
{
|
||||
if (obj.writeOpt() != IOobject::NO_WRITE)
|
||||
{
|
||||
@ -191,7 +182,16 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
|
||||
break;
|
||||
}
|
||||
case ANY_WRITE:
|
||||
case writeOption::AUTO_WRITE:
|
||||
{
|
||||
if (obj.writeOpt() != IOobject::AUTO_WRITE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case writeOption::ANY_WRITE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -83,8 +83,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_writeObjects_H
|
||||
#define functionObjects_writeObjects_H
|
||||
#ifndef Foam_functionObjects_writeObjects_H
|
||||
#define Foam_functionObjects_writeObjects_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordRes.H"
|
||||
@ -111,14 +111,14 @@ class writeObjects
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
// Public Data Types
|
||||
|
||||
//- Re-enumeration defining the write options, based on the original
|
||||
// ones at IOobject::writeOption
|
||||
//- Re-enumeration defining the write options,
|
||||
//- Naming based on the IOobjectOption::writeOption
|
||||
enum writeOption
|
||||
{
|
||||
AUTO_WRITE,
|
||||
NO_WRITE,
|
||||
AUTO_WRITE,
|
||||
ANY_WRITE
|
||||
};
|
||||
|
||||
@ -126,7 +126,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Reference to registry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
Reference in New Issue
Block a user