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-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
30 template<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 
65 inline const Foam::word& Foam::IOobject::name() const noexcept
66 {
67  return name_;
68 }
69 
70 
72 {
73  return name_.ext();
74 }
75 
76 
78 {
79  return name_.lessExt();
80 }
81 
82 
83 inline const Foam::word& Foam::IOobject::headerClassName() const noexcept
84 {
85  return headerClassName_;
86 }
87 
88 
90 {
91  return headerClassName_;
92 }
93 
94 
95 inline const Foam::string& Foam::IOobject::note() const noexcept
96 {
97  return note_;
98 }
99 
100 
102 {
103  return note_;
104 }
105 
106 
107 inline bool Foam::IOobject::registerObject() const noexcept
108 {
109  return registerObject_;
110 }
111 
112 
113 inline bool Foam::IOobject::registerObject(bool on) noexcept
114 {
115  bool old(registerObject_);
116  registerObject_ = on;
117  return old;
118 }
119 
120 
121 inline bool Foam::IOobject::globalObject() const noexcept
122 {
123  return globalObject_;
124 }
125 
126 
127 inline bool Foam::IOobject::globalObject(bool on) noexcept
128 {
129  bool old(globalObject_);
130  globalObject_ = on;
131  return old;
132 }
133 
134 
135 inline unsigned Foam::IOobject::labelByteSize() const noexcept
136 {
137  return static_cast<unsigned>(sizeofLabel_);
138 }
139 
140 
141 inline unsigned Foam::IOobject::scalarByteSize() const noexcept
142 {
143  return static_cast<unsigned>(sizeofScalar_);
144 }
145 
146 
147 // Checks
148 
149 inline bool Foam::IOobject::isHeaderClassName(const word& clsName) const
150 {
151  return (clsName == headerClassName_);
152 }
153 
154 
155 template<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 
196 inline const Foam::fileName& Foam::IOobject::instance() const noexcept
197 {
198  return instance_;
199 }
200 
201 
203 {
204  return instance_;
205 }
206 
207 
208 inline const Foam::fileName& Foam::IOobject::local() const noexcept
209 {
210  return local_;
211 }
212 
213 
215 {
216  return path()/name();
217 }
218 
219 
220 // Error Handling
221 
222 inline bool Foam::IOobject::good() const noexcept
223 {
224  return objState_ == GOOD;
225 }
226 
227 
228 inline bool Foam::IOobject::bad() const noexcept
229 {
230  return objState_ == BAD;
231 }
232 
233 
234 // ************************************************************************* //
Foam::word::lessExt
word lessExt() const
Return word without extension (part before last .)
Definition: word.C:113
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::IOobject::registerObject
bool registerObject() const noexcept
Should object created with this IOobject be registered?
Definition: IOobjectI.H:107
Foam::constant::atomic::group
constexpr const char *const group
Group name for atomic constants.
Definition: atomicConstants.H:52
Foam::IOobject::instance
const fileName & instance() const noexcept
Definition: IOobjectI.H:196
Foam::IOobject::labelByteSize
unsigned labelByteSize() const noexcept
The sizeof (label) in bytes, possibly read from the header.
Definition: IOobjectI.H:135
Foam::IOobject::isHeaderClassName
bool isHeaderClassName() const
Test if headerClassName() equals Type::typeName.
Definition: IOobjectI.H:156
Foam::IOobject::headerClassName
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:83
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:76
Foam::word::ext
word ext() const
Return file name extension (part after last .)
Definition: word.C:126
Foam::IOobject::writeOpt
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
Foam::IOobject::writeOption
writeOption
Enumeration defining the write options.
Definition: IOobject.H:192
Foam::IOobject::local
const fileName & local() const noexcept
Definition: IOobjectI.H:208
Foam::IOobject::globalObject
bool globalObject() const noexcept
Is object same for all processors?
Definition: IOobjectI.H:121
Foam::IOobject::scalarByteSize
unsigned scalarByteSize() const noexcept
The sizeof (scalar) in bytes, possibly read from the header.
Definition: IOobjectI.H:141
Foam::IOobject::readOpt
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
Foam::IOobject::name
const word & name() const noexcept
Return name.
Definition: IOobjectI.H:65
Foam::IOobject::note
const string & note() const noexcept
Return the optional note.
Definition: IOobjectI.H:95
Foam::IOobject::member
word member() const
Return member (name without the extension)
Definition: IOobjectI.H:77
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Foam::IOobject::group
word group() const
Return group (extension part of name)
Definition: IOobjectI.H:71
Foam::IOobject::bad
bool bad() const noexcept
Definition: IOobjectI.H:228
Foam::IOobject::good
bool good() const noexcept
Definition: IOobjectI.H:222
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::IOobject::readOption
readOption
Enumeration defining the read options.
Definition: IOobject.H:183
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Foam::IOobject::scopedName
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition: IOobjectI.H:47
Foam::IOobject::objectPath
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:214