IOmapDistribute.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 | Copyright (C) 2014 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "IOmapDistribute.H"
27 
28 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
29 
30 namespace Foam
31 {
32  defineTypeNameAndDebug(IOmapDistribute, 0);
33 }
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
40  regIOobject(io)
41 {
42  // Temporary warning
44  {
45  WarningIn("IOmapDistribute::IOmapDistribute(const IOobject&)")
46  << "IOmapDistribute " << name()
47  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
48  " but IOmapDistribute does not support automatic rereading."
49  << endl;
50  }
51 
52  if
53  (
54  (
57  )
59  )
60  {
61  readStream(typeName) >> *this;
62  close();
63  }
64 }
65 
66 
68 (
69  const IOobject& io,
70  const mapDistribute& map
71 )
72 :
73  regIOobject(io)
74 {
75  // Temporary warning
77  {
78  WarningIn("IOmapDistribute::IOmapDistribute(const IOobject&)")
79  << "IOmapDistribute " << name()
80  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
81  " but IOmapDistribute does not support automatic rereading."
82  << endl;
83  }
84 
85  if
86  (
87  (
90  )
92  )
93  {
94  readStream(typeName) >> *this;
95  close();
96  }
97  else
98  {
100  }
101 }
102 
103 
105 (
106  const IOobject& io,
107  const Xfer<mapDistribute>& map
108 )
109 :
110  regIOobject(io)
111 {
112  // Temporary warning
114  {
115  WarningIn("IOmapDistribute::IOmapDistribute(const IOobject&)")
116  << "IOmapDistribute " << name()
117  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
118  " but IOmapDistribute does not support automatic rereading."
119  << endl;
120  }
121 
123 
124  if
125  (
126  (
129  )
130  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
131  )
132  {
133  readStream(typeName) >> *this;
134  close();
135  }
136 }
137 
138 
139 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
140 
142 {}
143 
144 
145 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 
148 {
149  return (is >> *this).good();
150 }
151 
152 
154 {
155  return (os << *this).good();
156 }
157 
158 
159 // ************************************************************************* //
readOption readOpt() const
Definition: IOobject.H:304
Class containing processor-to-processor mapping information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
void operator=(const mapDistribute &)
IOmapDistribute(const IOobject &)
Construct given an IOobject.
Namespace for OpenFOAM.
regIOobject(const IOobject &, const bool isTime=false)
Construct from IOobject. Optional flag for if IOobject is the.
Definition: regIOobject.C:121
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define WarningIn(functionName)
Report a warning using Foam::Warning.
void close()
Close Istream.
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
const word & name() const
Return name.
Definition: IOobject.H:260
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
void transfer(mapDistribute &)
Transfer the contents of the argument and annul the argument.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
bool headerOk()
Read and check header info.
Definition: IOobject.C:424
Istream & readStream(const word &)
Return Istream and check object type against that given.
virtual ~IOmapDistribute()
Destructor.
defineTypeNameAndDebug(combustionModel, 0)