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-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
37 template<class Type>
39 (
40  const bool checkType,
41  const bool search,
42  const bool verbose
43 )
44 {
45  return readAndCheckHeader
46  (
48  Type::typeName,
49  checkType,
51  verbose
52  );
53 }
54 
55 
56 template<class Type>
58 {
59  return
60  (
62  ? this->globalFilePath(Type::typeName, search)
63  : this->localFilePath(Type::typeName, search)
64  );
65 }
66 
67 
68 template<class Type>
70 {
71  if (readOpt() == IOobjectOption::READ_MODIFIED)
72  {
74  << Type::typeName << ' ' << name()
75  << " constructed with READ_MODIFIED but "
76  << Type::typeName << " does not support automatic rereading."
77  << endl;
78  }
79 }
80 
81 
82 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
Trait for specifying global vs. local file types.
Definition: IOobject.H:981
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
fileName typeFilePath(const bool search=true) const
Call localFilePath or globalFilePath for given type depending on its is_globalIOobject trait...
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
#define WarningInFunction
Report a warning using Foam::Warning.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:642
void warnNoRereading() const
Helper: warn that type does not support re-reading.