IOobject.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #ifndef IOobject_H
00067 #define IOobject_H
00068
00069 #include "fileName.H"
00070 #include "typeInfo.H"
00071 #include "autoPtr.H"
00072 #include "InfoProxy.H"
00073
00074
00075
00076 namespace Foam
00077 {
00078
00079 class Time;
00080 class objectRegistry;
00081
00082
00083
00084
00085
00086 class IOobject
00087 {
00088
00089 public:
00090
00091
00092
00093
00094 enum objectState
00095 {
00096 GOOD,
00097 BAD
00098 };
00099
00100
00101 enum readOption
00102 {
00103 MUST_READ,
00104 READ_IF_PRESENT,
00105 NO_READ
00106 };
00107
00108
00109 enum writeOption
00110 {
00111 AUTO_WRITE = 0,
00112 NO_WRITE = 1
00113 };
00114
00115
00116 private:
00117
00118
00119
00120
00121 word name_;
00122
00123
00124 word headerClassName_;
00125
00126
00127 string note_;
00128
00129
00130 fileName instance_;
00131
00132
00133 fileName local_;
00134
00135
00136 const objectRegistry& db_;
00137
00138
00139 readOption rOpt_;
00140
00141
00142 writeOption wOpt_;
00143
00144
00145 bool registerObject_;
00146
00147
00148 objectState objState_;
00149
00150 protected:
00151
00152
00153
00154
00155
00156 Istream* objectStream();
00157
00158
00159 void setBad(const string&);
00160
00161
00162 public:
00163
00164
00165 TypeName("IOobject");
00166
00167
00168
00169
00170
00171 static bool fileNameComponents
00172 (
00173 const fileName& path,
00174 fileName& instance,
00175 fileName& local,
00176 word& name
00177 );
00178
00179
00180
00181
00182
00183 IOobject
00184 (
00185 const word& name,
00186 const fileName& instance,
00187 const objectRegistry& registry,
00188 readOption r=NO_READ,
00189 writeOption w=NO_WRITE,
00190 bool registerObject=true
00191 );
00192
00193
00194 IOobject
00195 (
00196 const word& name,
00197 const fileName& instance,
00198 const fileName& local,
00199 const objectRegistry& registry,
00200 readOption r=NO_READ,
00201 writeOption w=NO_WRITE,
00202 bool registerObject=true
00203 );
00204
00205
00206
00207 IOobject
00208 (
00209 const fileName& path,
00210 const objectRegistry& registry,
00211 readOption r=NO_READ,
00212 writeOption w=NO_WRITE,
00213 bool registerObject=true
00214 );
00215
00216
00217 Foam::autoPtr<IOobject> clone() const
00218 {
00219 return autoPtr<IOobject>(new IOobject(*this));
00220 }
00221
00222
00223
00224
00225 virtual ~IOobject();
00226
00227
00228
00229
00230
00231
00232
00233 const Time& time() const;
00234
00235
00236 const objectRegistry& db() const;
00237
00238
00239 const word& name() const
00240 {
00241 return name_;
00242 }
00243
00244
00245 const word& headerClassName() const
00246 {
00247 return headerClassName_;
00248 }
00249
00250
00251 string& note()
00252 {
00253 return note_;
00254 }
00255
00256
00257 const string& note() const
00258 {
00259 return note_;
00260 }
00261
00262
00263 virtual void rename(const word& newName)
00264 {
00265 name_ = newName;
00266 }
00267
00268
00269 bool registerObject() const
00270 {
00271 return registerObject_;
00272 }
00273
00274
00275
00276
00277 readOption readOpt() const
00278 {
00279 return rOpt_;
00280 }
00281
00282 readOption& readOpt()
00283 {
00284 return rOpt_;
00285 }
00286
00287 writeOption writeOpt() const
00288 {
00289 return wOpt_;
00290 }
00291
00292 writeOption& writeOpt()
00293 {
00294 return wOpt_;
00295 }
00296
00297
00298
00299
00300 const fileName& rootPath() const;
00301
00302 const fileName& caseName() const;
00303
00304 const fileName& instance() const
00305 {
00306 return instance_;
00307 }
00308
00309 fileName& instance()
00310 {
00311 return instance_;
00312 }
00313
00314 const fileName& local() const
00315 {
00316 return local_;
00317 }
00318
00319
00320 fileName path() const;
00321
00322
00323 fileName path
00324 (
00325 const word& instance,
00326 const fileName& local = ""
00327 ) const;
00328
00329
00330 fileName objectPath() const
00331 {
00332 return path()/name();
00333 }
00334
00335
00336
00337 fileName filePath() const;
00338
00339
00340
00341
00342
00343 bool readHeader(Istream&);
00344
00345
00346 bool headerOk();
00347
00348
00349
00350
00351
00352
00353 template<class Stream>
00354 static inline Stream& writeBanner(Stream& os, bool noHint=false);
00355
00356
00357 template<class Stream>
00358 static inline Stream& writeDivider(Stream& os);
00359
00360
00361 template<class Stream>
00362 static inline Stream& writeEndDivider(Stream& os);
00363
00364
00365 bool writeHeader(Ostream&) const;
00366
00367
00368
00369
00370 bool good() const
00371 {
00372 return objState_ == GOOD;
00373 }
00374
00375 bool bad() const
00376 {
00377 return objState_ == BAD;
00378 }
00379
00380
00381
00382
00383
00384
00385 InfoProxy<IOobject> info() const
00386 {
00387 return *this;
00388 }
00389
00390
00391
00392
00393 void operator=(const IOobject&);
00394 };
00395
00396
00397 #if defined (__GNUC__)
00398 template<>
00399 #endif
00400 Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
00401
00402
00403
00404
00405 }
00406
00407
00408
00409 # include "IOobjectI.H"
00410
00411
00412
00413 #endif
00414
00415
Copyright © 2000-2009 OpenCFD Ltd