Loading...
Searching...
No Matches
GlobalIOList.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 OpenFOAM Foundation
9 Copyright (C) 2016-2024 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 "GlobalIOList.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35:
37{
38 // Check for MUST_READ_IF_MODIFIED
49{
50 // Check for MUST_READ_IF_MODIFIED
52
54}
55
56
57template<class Type>
59:
61{
62 // Check for MUST_READ_IF_MODIFIED
64
66 {
68 }
69}
70
71
72template<class Type>
74(
75 const IOobject& io,
76 const UList<Type>& content
77)
78:
79 regIOobject(io)
80{
81 // Check for MUST_READ_IF_MODIFIED
83
85 {
86 List<Type>::operator=(content);
87 }
88}
89
90
91template<class Type>
93(
94 const IOobject& io,
95 List<Type>&& content
96)
97:
98 regIOobject(io)
99{
100 // Check for MUST_READ_IF_MODIFIED
102
103 List<Type>::transfer(content);
104
106}
107
108
109// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
110
111template<class Type>
113{
115 if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
116 {
117 rio.readOpt(IOobjectOption::MUST_READ);
118 }
119 rio.resetHeader();
120
121 // The object is global
122 rio.globalObject(true);
123
124 GlobalIOList<Type> reader(rio);
125
126 return List<Type>(std::move(static_cast<List<Type>&>(reader)));
127}
128
129
130// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131
132template<class Type>
135 is >> *this;
136 return is.good();
137}
138
139
140template<class Type>
142{
144 return os.good();
145}
146
147
148// ************************************************************************* //
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
static List< Type > readContents(const IOobject &io)
Read and return contents. The IOobject is never registered.
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
GlobalIOList(const GlobalIOList &)=default
Default copy construct.
@ NO_REGISTER
Do not request registration (bool: false).
bool globalObject() const noexcept
True if object is treated the same for all processors.
readOption readOpt() const noexcept
Get the read option.
@ MUST_READ
Reading required.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
void warnNoRereading() const
Helper: warn that type does not support re-reading.
void resetHeader(const word &newName=word::null)
Clear various bits (headerClassName, note, sizeof...) that would be obtained when reading from a file...
Definition IOobject.C:644
bool good() const noexcept
True if next operation might succeed.
Definition IOstream.H:281
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition List.C:347
void operator=(const UList< T > &list)
Assignment to UList operator. Takes linear time.
Definition List.C:381
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
bool readHeaderOk(const IOstreamOption::streamFormat fmt, const word &typeName)
Helper: check readOpt flags and read if necessary.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
OBJstream os(runTime.globalPath()/outputName)
const auto & io
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")