All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IOPtrList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 "IOPtrList.H"
27 
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
29 
30 template<class T>
31 template<class INew>
33 :
34  regIOobject(io)
35 {
36  if
37  (
38  (
41  )
43  )
44  {
45  // For if MUST_READ_IF_MODIFIED
46  addWatch();
47 
48  PtrList<T>::read(readStream(typeName), inewt);
49  close();
50  }
51 }
52 
53 
54 template<class T>
56 :
57  regIOobject(io)
58 {
59  if
60  (
61  (
64  )
66  )
67  {
68  // For if MUST_READ_IF_MODIFIED
69  addWatch();
70 
71  PtrList<T>::read(readStream(typeName), INew<T>());
72  close();
73  }
74 }
75 
76 
77 template<class T>
79 :
80  regIOobject(io),
81  PtrList<T>(s)
82 {
83  if (io.readOpt() != IOobject::NO_READ)
84  {
86  << "NO_READ must be set if specifying size" << nl
87  << exit(FatalError);
88  }
89 }
90 
91 
92 template<class T>
94 :
95  regIOobject(io)
96 {
97  if
98  (
99  (
102  )
103  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
104  )
105  {
106  // For if MUST_READ_IF_MODIFIED
107  addWatch();
108 
109  PtrList<T>::read(readStream(typeName), INew<T>());
110  close();
111  }
112  else
113  {
114  PtrList<T>::operator=(list);
115  }
116 }
117 
118 
119 template<class T>
121 :
122  regIOobject(io),
123  PtrList<T>(move(list))
124 {
125  if
126  (
127  (
130  )
131  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
132  )
133  {
134  // For if MUST_READ_IF_MODIFIED
135  addWatch();
136 
137  PtrList<T>::read(readStream(typeName), INew<T>());
138  close();
139  }
140 }
141 
142 
143 template<class T>
145 :
146  regIOobject(move(list)),
147  PtrList<T>(move(list))
148 {}
149 
150 
151 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
152 
153 template<class T>
155 {}
156 
157 
158 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
159 
160 template<class T>
162 {
163  return (os << *this).good();
164 }
165 
166 
167 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
168 
169 template<class T>
171 {
173 }
174 
175 
176 template<class T>
178 {
179  PtrList<T>::operator=(move(rhs));
180 }
181 
182 
183 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
bool headerOk()
Read and check header info.
Definition: regIOobject.C:443
void read(Istream &, const INew &inewt)
Read from Istream using given Istream constructor class.
Definition: PtrListIO.C:36
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void close()
Close Istream.
void operator=(const PtrList< T > &)
Assignment operator.
Definition: PtrList.C:274
Istream & readStream(const word &, const bool read=true)
Return Istream and check object type against that given.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
Definition: regIOobject.C:259
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
A PtrList of objects of type <T> with automated input and output.
Definition: IOPtrList.H:50
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:49
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
void operator=(const IOPtrList< T > &)
Definition: IOPtrList.C:170
virtual ~IOPtrList()
Destructor.
Definition: IOPtrList.C:154
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IOPtrList.C:161
readOption readOpt() const
Definition: IOobject.H:365
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
IOPtrList(const IOobject &, const INew &)
Construct from IOobject using given Istream constructor class.
Definition: IOPtrList.C:32