Loading...
Searching...
No Matches
IOobjectTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015-2017 OpenFOAM Foundation
9 Copyright (C) 2016-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "IOobject.H"
30#include "IOstreams.H"
31#include "fileOperation.H" // legacy include
32#include "Istream.H" // legacy include
33#include "Pstream.H" // legacy include
34
35// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36
37template<class Type>
39(
40 const bool checkType,
41 const bool search,
42 const bool verbose
43)
44{
45 if constexpr (std::is_void_v<Type>)
46 {
47 return readAndCheckHeader
48 (
49 false, // isGlobal (false)
50 word::null, // typeName (n/a)
51 false, // checkType (false)
52 search,
53 verbose
54 );
55 }
56 else
57 {
58 return readAndCheckHeader
59 (
61 Type::typeName,
62 checkType,
63 search,
64 verbose
65 );
66 }
67}
68
69
70template<class Type, bool Searching>
71bool Foam::IOobject::typeHeaderOk(const bool checkType, const bool verbose)
72{
73 return typeHeaderOk<Type>(checkType, Searching, verbose);
74}
75
76
77template<class Type>
79{
81 {
82 return this->globalFilePath(Type::typeName, search);
83 }
84 else
85 {
86 return this->localFilePath(Type::typeName, search);
87 }
88}
89
90
91template<class Type>
93{
94 if (readOpt() == IOobjectOption::READ_MODIFIED)
95 {
97 << Type::typeName << ' ' << name()
98 << " constructed with READ_MODIFIED but "
99 << Type::typeName << " does not support automatic rereading."
100 << endl;
101 }
102}
103
104
105// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
readOption readOpt() const noexcept
Get the read option.
void warnNoRereading() const
Helper: warn that type does not support re-reading.
fileName typeFilePath(const bool search=true) const
Call localFilePath or globalFilePath for given type depending on its is_globalIOobject trait.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info. A void type suppresses trait and t...
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition IOobject.C:604
fileName localFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching locally.
Definition IOobject.C:593
A class for handling file names.
Definition fileName.H:75
static const word null
An empty word.
Definition word.H:84
auto & name
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition fileName.C:642
Trait for specifying global vs. local IOobject file types.
Definition IOobject.H:175