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 #ifndef IOobject_H
00066 #define IOobject_H
00067
00068 #include "fileName.H"
00069 #include "typeInfo.H"
00070 #include "autoPtr.H"
00071 #include "InfoProxy.H"
00072
00073
00074
00075 namespace Foam
00076 {
00077
00078 class Time;
00079 class objectRegistry;
00080
00081
00082
00083
00084
00085 class IOobject
00086 {
00087
00088 public:
00089
00090
00091
00092
00093 enum objectState
00094 {
00095 GOOD,
00096 BAD
00097 };
00098
00099
00100 enum readOption
00101 {
00102 MUST_READ,
00103 READ_IF_PRESENT,
00104 NO_READ
00105 };
00106
00107
00108 enum writeOption
00109 {
00110 AUTO_WRITE = 0,
00111 NO_WRITE = 1
00112 };
00113
00114
00115 private:
00116
00117
00118
00119
00120 word name_;
00121
00122
00123 word headerClassName_;
00124
00125
00126 string note_;
00127
00128
00129 fileName instance_;
00130
00131
00132 fileName local_;
00133
00134
00135 const objectRegistry& db_;
00136
00137
00138 readOption rOpt_;
00139
00140
00141 writeOption wOpt_;
00142
00143
00144 bool registerObject_;
00145
00146
00147 objectState objState_;
00148
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 IOobject
00172 (
00173 const word& name,
00174 const fileName& instance,
00175 const objectRegistry& registry,
00176 readOption r=NO_READ,
00177 writeOption w=NO_WRITE,
00178 bool registerObject=true
00179 );
00180
00181
00182 IOobject
00183 (
00184 const word& name,
00185 const fileName& instance,
00186 const fileName& local,
00187 const objectRegistry& registry,
00188 readOption r=NO_READ,
00189 writeOption w=NO_WRITE,
00190 bool registerObject=true
00191 );
00192
00193
00194 autoPtr<IOobject> clone() const
00195 {
00196 return autoPtr<IOobject>(new IOobject(*this));
00197 }
00198
00199
00200
00201
00202 virtual ~IOobject()
00203 {}
00204
00205
00206
00207
00208
00209
00210
00211 const Time& time() const;
00212
00213
00214 const objectRegistry& db() const;
00215
00216
00217 const word& name() const
00218 {
00219 return name_;
00220 }
00221
00222
00223 const word& headerClassName() const
00224 {
00225 return headerClassName_;
00226 }
00227
00228
00229 string& note()
00230 {
00231 return note_;
00232 }
00233
00234
00235 const string& note() const
00236 {
00237 return note_;
00238 }
00239
00240
00241 virtual void rename(const word& newName)
00242 {
00243 name_ = newName;
00244 }
00245
00246
00247 bool registerObject() const
00248 {
00249 return registerObject_;
00250 }
00251
00252
00253
00254
00255 readOption readOpt() const
00256 {
00257 return rOpt_;
00258 }
00259
00260 readOption& readOpt()
00261 {
00262 return rOpt_;
00263 }
00264
00265 writeOption writeOpt() const
00266 {
00267 return wOpt_;
00268 }
00269
00270 writeOption& writeOpt()
00271 {
00272 return wOpt_;
00273 }
00274
00275
00276
00277
00278 const fileName& rootPath() const;
00279
00280 const fileName& caseName() const;
00281
00282 const fileName& instance() const
00283 {
00284 return instance_;
00285 }
00286
00287 fileName& instance()
00288 {
00289 return instance_;
00290 }
00291
00292 const fileName& local() const
00293 {
00294 return local_;
00295 }
00296
00297
00298 fileName path() const;
00299
00300
00301 fileName path
00302 (
00303 const word& instance,
00304 const fileName& local = ""
00305 ) const;
00306
00307
00308 fileName objectPath() const
00309 {
00310 return path()/name();
00311 }
00312
00313
00314
00315 fileName filePath() const;
00316
00317
00318
00319
00320
00321 bool readHeader(Istream&);
00322
00323
00324 bool headerOk();
00325
00326
00327
00328
00329
00330 template<class Stream>
00331 static inline void writeBanner(Stream& os);
00332
00333
00334 template<class Stream>
00335 static inline void writeLogBanner(Stream& os);
00336
00337
00338 template<class Stream>
00339 static inline void writeDivider(Stream& os);
00340
00341
00342 bool writeHeader(Ostream&) const;
00343
00344
00345
00346
00347 bool good() const
00348 {
00349 return objState_ == GOOD;
00350 }
00351
00352 bool bad() const
00353 {
00354 return objState_ == BAD;
00355 }
00356
00357
00358
00359
00360
00361
00362 InfoProxy<IOobject> info() const
00363 {
00364 return *this;
00365 }
00366
00367
00368
00369
00370 void operator=(const IOobject&);
00371 };
00372
00373
00374
00375
00376 }
00377
00378
00379
00380 # include "IOobjectI.H"
00381
00382
00383
00384 #endif
00385
00386
Copyright © 2000-2007 OpenCFD Ltd