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-2018 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 "GlobalIOList.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 :
36  regIOobject(io)
37 {
38  // Check for MUST_READ_IF_MODIFIED
39  warnNoRereading<GlobalIOList<Type>>();
40 
41  readHeaderOk(IOstream::BINARY, typeName);
42 }
43 
44 
45 template<class Type>
47 :
48  regIOobject(io)
49 {
50  // Check for MUST_READ_IF_MODIFIED
51  warnNoRereading<GlobalIOList<Type>>();
52 
53  if (!readHeaderOk(IOstream::BINARY, typeName))
54  {
55  List<Type>::setSize(size);
56  }
57 }
58 
59 
60 template<class Type>
62 (
63  const IOobject& io,
64  const UList<Type>& content
65 )
66 :
67  regIOobject(io)
68 {
69  // Check for MUST_READ_IF_MODIFIED
70  warnNoRereading<GlobalIOList<Type>>();
71 
72  if (!readHeaderOk(IOstream::BINARY, typeName))
73  {
74  List<Type>::operator=(content);
75  }
76 }
77 
78 
79 template<class Type>
81 (
82  const IOobject& io,
83  List<Type>&& content
84 )
85 :
86  regIOobject(io)
87 {
88  // Check for MUST_READ_IF_MODIFIED
89  warnNoRereading<GlobalIOList<Type>>();
90 
91  List<Type>::transfer(content);
92 
93  readHeaderOk(IOstream::BINARY, typeName);
94 }
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
99 template<class Type>
101 {
102  is >> *this;
103  return is.good();
104 }
105 
106 
107 template<class Type>
109 {
110  return (os << *this).good();
111 }
112 
113 
114 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
115 
116 template<class Type>
118 {
120 }
121 
122 
123 // ************************************************************************* //
setSize
points setSize(newPointi)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
GlobalIOList.H
Foam::GlobalIOList::writeData
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition: GlobalIOList.C:108
Foam::GlobalIOList::readData
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition: GlobalIOList.C:100
Foam::IOstream::good
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
Foam::GlobalIOList::GlobalIOList
GlobalIOList(const GlobalIOList &)=default
Default copy construct.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::GlobalIOList::operator=
void operator=(const GlobalIOList< Type > &rhs)
Copy assignment of entries.
Definition: GlobalIOList.C:117
os
OBJstream os(runTime.globalPath()/outputName)
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList< Type >
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GlobalIOList
IOList with global data (so optionally read from master)
Definition: GlobalIOList.H:53