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(const fileName&);
00157
00158
00159
00160 Istream* objectStream();
00161
00162
00163 void setBad(const string&);
00164
00165
00166 public:
00167
00168
00169 TypeName("IOobject");
00170
00171
00172
00173
00174
00175 IOobject
00176 (
00177 const word& name,
00178 const fileName& instance,
00179 const objectRegistry& registry,
00180 readOption r=NO_READ,
00181 writeOption w=NO_WRITE,
00182 bool registerObject=true
00183 );
00184
00185
00186 IOobject
00187 (
00188 const word& name,
00189 const fileName& instance,
00190 const fileName& local,
00191 const objectRegistry& registry,
00192 readOption r=NO_READ,
00193 writeOption w=NO_WRITE,
00194 bool registerObject=true
00195 );
00196
00197
00198 autoPtr<IOobject> clone() const
00199 {
00200 return autoPtr<IOobject>(new IOobject(*this));
00201 }
00202
00203
00204
00205
00206 virtual ~IOobject()
00207 {}
00208
00209
00210
00211
00212
00213
00214
00215 const Time& time() const;
00216
00217
00218 const objectRegistry& db() const;
00219
00220
00221 const word& name() const
00222 {
00223 return name_;
00224 }
00225
00226
00227 const word& headerClassName() const
00228 {
00229 return headerClassName_;
00230 }
00231
00232
00233 string& note()
00234 {
00235 return note_;
00236 }
00237
00238
00239 const string& note() const
00240 {
00241 return note_;
00242 }
00243
00244
00245 virtual void rename(const word& newName)
00246 {
00247 name_ = newName;
00248 }
00249
00250
00251 bool registerObject() const
00252 {
00253 return registerObject_;
00254 }
00255
00256
00257
00258
00259 readOption readOpt() const
00260 {
00261 return rOpt_;
00262 }
00263
00264 readOption& readOpt()
00265 {
00266 return rOpt_;
00267 }
00268
00269 writeOption writeOpt() const
00270 {
00271 return wOpt_;
00272 }
00273
00274 writeOption& writeOpt()
00275 {
00276 return wOpt_;
00277 }
00278
00279
00280
00281
00282 const fileName& rootPath() const;
00283
00284 const fileName& caseName() const;
00285
00286 const fileName& instance() const
00287 {
00288 return instance_;
00289 }
00290
00291 fileName& instance()
00292 {
00293 return instance_;
00294 }
00295
00296 const fileName& local() const
00297 {
00298 return local_;
00299 }
00300
00301
00302 fileName path() const;
00303
00304
00305 fileName path
00306 (
00307 const word& instance,
00308 const fileName& local = ""
00309 ) const;
00310
00311
00312 fileName objectPath() const
00313 {
00314 return path()/name();
00315 }
00316
00317
00318
00319
00320
00321 bool readHeader(Istream&);
00322
00323
00324 bool headerOk();
00325
00326
00327
00328
00329
00330 bool writeHeader(Ostream&) const;
00331
00332
00333
00334
00335 bool good() const
00336 {
00337 return objState_ == GOOD;
00338 }
00339
00340 bool bad() const
00341 {
00342 return objState_ == BAD;
00343 }
00344
00345
00346
00347
00348
00349
00350 InfoProxy<IOobject> info() const
00351 {
00352 return *this;
00353 }
00354
00355
00356
00357
00358 void operator=(const IOobject&);
00359 };
00360
00361
00362
00363
00364 }
00365
00366
00367
00368 #endif
00369
00370