IOobjectI.H
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) 2017-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
29
30template<class StringType>
32(
33 StringType base,
34 const word& group
35)
36{
37 if (group.empty())
38 {
39 return base;
40 }
41
42 return base + ('.' + group);
43}
44
45
47(
48 const std::string& scope,
49 const word& name
50)
51{
52 if (scope.empty())
53 {
54 return name;
55 }
56
57 return scope + (IOobject::scopeSeparator + name);
58}
59
60
61// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62
63// General access
64
66{
67 return name_;
68}
69
70
72{
73 return name_.ext();
74}
75
76
78{
79 return name_.lessExt();
80}
81
82
84{
85 return headerClassName_;
86}
87
88
90{
91 return headerClassName_;
92}
93
94
96{
97 return note_;
98}
99
100
102{
103 return note_;
104}
105
106
108{
109 return registerObject_;
110}
111
112
113inline bool Foam::IOobject::registerObject(bool on) noexcept
114{
115 bool old(registerObject_);
116 registerObject_ = on;
117 return old;
118}
119
120
122{
123 return globalObject_;
124}
125
126
127inline bool Foam::IOobject::globalObject(bool on) noexcept
128{
129 bool old(globalObject_);
130 globalObject_ = on;
131 return old;
132}
133
134
136{
137 return static_cast<unsigned>(sizeofLabel_);
138}
139
140
142{
143 return static_cast<unsigned>(sizeofScalar_);
144}
145
146
147// Checks
148
150{
151 return !headerClassName_.empty();
152}
153
154
155template<class Type>
157{
158 return (Type::typeName == headerClassName_);
159}
160
161
162// Read/write options
163
165{
166 return rOpt_;
167}
168
169
172{
173 readOption old(rOpt_);
174 rOpt_ = opt;
175 return old;
176}
177
178
180{
181 return wOpt_;
182}
183
184
187{
188 writeOption old(wOpt_);
189 wOpt_ = opt;
190 return old;
191}
192
193
194// Path components
195
197{
198 return instance_;
199}
200
201
203{
204 return instance_;
205}
206
207
209{
210 return local_;
211}
212
213
215{
216 return path()/name();
217}
218
219
220// Error Handling
221
223{
224 return objState_ == objectState::GOOD;
225}
226
227
228inline bool Foam::IOobject::bad() const noexcept
229{
230 return objState_ == objectState::BAD;
231}
232
233
234// ************************************************************************* //
bool isHeaderClass() const
Check if headerClassName() equals Type::typeName.
Definition: IOobjectI.H:156
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:83
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
bool globalObject() const noexcept
Is object same for all processors?
Definition: IOobjectI.H:121
unsigned scalarByteSize() const noexcept
The sizeof (scalar) in bytes, possibly read from the header.
Definition: IOobjectI.H:141
bool good() const noexcept
Did last readHeader() succeed?
Definition: IOobjectI.H:222
bool bad() const noexcept
Did last readHeader() fail?
Definition: IOobjectI.H:228
bool registerObject() const noexcept
Should object created with this IOobject be registered?
Definition: IOobjectI.H:107
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition: IOobjectI.H:47
static char scopeSeparator
Character for scoping object names (':' or '_')
Definition: IOobject.H:300
bool hasHeaderClass() const noexcept
True if headerClassName() is non-empty (after reading)
Definition: IOobjectI.H:149
const fileName & local() const noexcept
Read access to local path component.
Definition: IOobjectI.H:208
word group() const
Return group (extension part of name)
Definition: IOobjectI.H:71
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:196
writeOption
Enumeration defining the write options.
Definition: IOobject.H:186
unsigned labelByteSize() const noexcept
The sizeof (label) in bytes, possibly read from the header.
Definition: IOobjectI.H:135
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
word member() const
Return member (name without the extension)
Definition: IOobjectI.H:77
const string & note() const noexcept
Return the optional note.
Definition: IOobjectI.H:95
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:214
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
readOption
Enumeration defining the read options.
Definition: IOobject.H:177
A class for handling file names.
Definition: fileName.H:76
A class for handling character strings derived from std::string.
Definition: string.H:79
A class for handling words, derived from Foam::string.
Definition: word.H:68
word ext() const
Return file name extension (part after last .)
Definition: word.C:126
word lessExt() const
Return word without extension (part before last .)
Definition: word.C:113
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
const direction noexcept
Definition: Scalar.H:223
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59