OpenFOAM
6
The OpenFOAM Foundation
src
OpenFOAM
db
regIOobject
regIOobject.H
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-2018 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
Class
25
Foam::regIOobject
26
27
Description
28
regIOobject is an abstract class derived from IOobject to handle
29
automatic object registration with the objectRegistry.
30
31
SourceFiles
32
regIOobject.C
33
regIOobjectRead.C
34
regIOobjectWrite.C
35
36
\*---------------------------------------------------------------------------*/
37
38
#ifndef regIOobject_H
39
#define regIOobject_H
40
41
#include "
IOobject.H
"
42
#include "
typeInfo.H
"
43
#include "
OSspecific.H
"
44
#include "
NamedEnum.H
"
45
46
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48
49
namespace
Foam
50
{
51
52
namespace
functionEntries
53
{
54
class
codeStream;
55
}
56
namespace
fileOperations
57
{
58
class
uncollatedFileOperation
;
59
class
masterUncollatedFileOperation
;
60
}
61
62
/*---------------------------------------------------------------------------*\
63
Class regIOobject Declaration
64
\*---------------------------------------------------------------------------*/
65
66
class
regIOobject
67
:
68
public
IOobject
69
{
70
protected
:
71
//- Helper: check readOpt flags and read if necessary
72
bool
readHeaderOk
73
(
74
const
IOstream::streamFormat
PstreamFormat,
75
const
word
& typeName
76
);
77
78
//- To flag master-only reading of objects
79
static
bool
masterOnlyReading;
80
81
82
private
:
83
84
// Private data
85
86
//- Is this object registered with the registry
87
bool
registered_;
88
89
//- Is this object owned by the registry
90
bool
ownedByRegistry_;
91
92
//- List of modification watch indices
93
mutable
labelList
watchIndices_;
94
95
//- eventNo of last update
96
label
eventNo_;
97
98
//- Istream for reading
99
autoPtr<ISstream>
isPtr_;
100
101
102
// Private Member Functions
103
104
//- Return Istream
105
Istream
& readStream(
const
bool
valid =
true
);
106
107
//- Dissallow assignment
108
void
operator=(
const
regIOobject
&);
109
110
111
public
:
112
113
//- Declare friendship with any classes that need access to
114
// masterOnlyReading
115
friend
class
functionEntries::codeStream
;
116
friend
class
fileOperations::uncollatedFileOperation
;
117
friend
class
fileOperations::masterUncollatedFileOperation
;
118
119
120
// Static data
121
122
//- Runtime type information
123
TypeName
(
"regIOobject"
);
124
125
static
float
fileModificationSkew;
126
127
128
// Constructors
129
130
//- Construct from IOobject. Optional flag for if IOobject is the
131
// top level regIOobject.
132
regIOobject
(
const
IOobject
&,
const
bool
isTime =
false
);
133
134
//- Construct as copy
135
regIOobject
(
const
regIOobject
&);
136
137
//- Construct as copy, transferring registry registration to copy
138
// if registerCopy is true
139
regIOobject
(
const
regIOobject
&,
bool
registerCopy);
140
141
//- Construct as copy with new name, transferring registry registration
142
// to copy as specified
143
regIOobject
(
const
word
& newName,
const
regIOobject
&,
bool
registerCopy);
144
145
//- Construct as copy with new IO parameters
146
regIOobject
(
const
IOobject
&,
const
regIOobject
&);
147
148
149
//- Destructor
150
virtual
~
regIOobject
();
151
152
153
// Member functions
154
155
// Registration
156
157
//- Add object to registry
158
bool
checkIn();
159
160
//- Remove object from registry
161
bool
checkOut();
162
163
//- Add file watch on object (if registered and READ_IF_MODIFIED)
164
virtual
void
addWatch();
165
166
//- Is this object owned by the registry?
167
inline
bool
ownedByRegistry()
const
;
168
169
//- Transfer ownership of this object to its registry
170
inline
void
store();
171
172
//- Transfer ownership of the given object pointer to its registry
173
// and return reference to object.
174
template
<
class
Type>
175
inline
static
Type& store(Type*);
176
177
//- Transfer ownership of the given object pointer to its registry
178
// and return reference to object.
179
template
<
class
Type>
180
inline
static
Type& store(
autoPtr<Type>
&);
181
182
//- Release ownership of this object from its registry
183
inline
void
release();
184
185
186
// Dependency checking
187
188
//- Event number at last update.
189
inline
label
eventNo()
const
;
190
191
//- Event number at last update.
192
inline
label
& eventNo();
193
194
//- Return true if up-to-date with respect to given object
195
// otherwise false
196
bool
upToDate(
const
regIOobject
&)
const
;
197
198
//- Return true if up-to-date with respect to given objects
199
// otherwise false
200
bool
upToDate
201
(
202
const
regIOobject
&,
203
const
regIOobject
&
204
)
const
;
205
206
//- Return true if up-to-date with respect to given objects
207
// otherwise false
208
bool
upToDate
209
(
210
const
regIOobject
&,
211
const
regIOobject
&,
212
const
regIOobject
&
213
)
const
;
214
215
//- Return true if up-to-date with respect to given objects
216
// otherwise false
217
bool
upToDate
218
(
219
const
regIOobject
&,
220
const
regIOobject
&,
221
const
regIOobject
&,
222
const
regIOobject
&
223
)
const
;
224
225
//- Set up to date (obviously)
226
void
setUpToDate();
227
228
229
// Edit
230
231
//- Rename
232
virtual
void
rename(
const
word
& newName);
233
234
235
// Reading
236
237
//- Return complete path + object name if the file exists
238
// in the case directory otherwise null. Does not search
239
// up if parallel. Can be overridden to provide this functionality
240
// (e.g. IOdictionary)
241
virtual
fileName
filePath()
const
;
242
243
//- Read and check header info
244
bool
headerOk();
245
246
//- Return Istream and check object type against that given
247
Istream
& readStream(
const
word
&,
const
bool
valid =
true
);
248
249
//- Close Istream
250
void
close();
251
252
//- Virtual readData function.
253
// Must be defined in derived types for which
254
// re-reading is required
255
virtual
bool
readData(
Istream
&);
256
257
//- Read object
258
virtual
bool
read
();
259
260
//- Add file watch for fileName on object if not yet watched. Return
261
// index of watch
262
virtual
label
addWatch(
const
fileName
&);
263
264
//- Return file-monitoring handles
265
inline
const
labelList
& watchIndices()
const
;
266
267
//- Return file-monitoring handles
268
inline
labelList
& watchIndices();
269
270
//- Return true if the object's file (or files for objectRegistry)
271
// have been modified. (modified state is cached by Time)
272
virtual
bool
modified()
const
;
273
274
//- Read object if modified (as set by call to modified)
275
virtual
bool
readIfModified();
276
277
278
// Writing
279
280
//- Pure virtual writaData function.
281
// Must be defined in derived types
282
virtual
bool
writeData
(
Ostream
&)
const
= 0;
283
284
//- Write using given format, version and compression
285
virtual
bool
writeObject
286
(
287
IOstream::streamFormat
,
288
IOstream::versionNumber
,
289
IOstream::compressionType
,
290
const
bool
valid
291
)
const
;
292
293
//- Write using setting from DB
294
virtual
bool
write
(
const
bool
valid =
true
)
const
;
295
296
297
// Other
298
299
//- Is object global
300
virtual
bool
global()
const
301
{
302
return
false
;
303
}
304
305
306
// Member operators
307
308
void
operator=(
const
IOobject
&);
309
};
310
311
312
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313
314
}
// End namespace Foam
315
316
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317
318
#include "
regIOobjectI.H
"
319
320
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321
322
#endif
323
324
// ************************************************************************* //
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition:
label.H:59
Foam::fileName
A class for handling file names.
Definition:
fileName.H:69
Foam::List< label >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition:
Istream.H:57
Foam::fileOperations::uncollatedFileOperation
fileOperation that assumes file operations are local.
Definition:
uncollatedFileOperation.H:48
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::blockMeshTools::write
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
Definition:
blockMeshTools.C:92
Foam::read
bool read(const char *, int32_t &)
Definition:
int32IO.C:85
Foam::functionEntries::codeStream
Dictionary entry that contains C++ OpenFOAM code that is compiled to generate the entry itself...
Definition:
codeStream.H:112
Foam::word
A class for handling words, derived from string.
Definition:
word.H:59
NamedEnum.H
Foam::IOstream::streamFormat
streamFormat
Enumeration for the format of data in the stream.
Definition:
IOstream.H:86
TypeName
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition:
typeInfo.H:70
IOobject.H
Foam::IOstream::compressionType
compressionType
Enumeration for the format of data in the stream.
Definition:
IOstream.H:193
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition:
Ostream.H:53
writeData
const bool writeData(readBool(pdfDictionary.lookup("writeData")))
typeInfo.H
Foam::IOstream::versionNumber
Version number type.
Definition:
IOstream.H:96
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:65
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition:
PtrList.H:52
Foam::fileOperations::masterUncollatedFileOperation
Definition:
masterUncollatedFileOperation.H:81
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition:
IOobject.H:92
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:30
regIOobjectI.H
Generated by
1.8.13