1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 regIOobject is an abstract class derived from IOobject to handle
29 automatic object registration with the objectRegistry.
36 \*---------------------------------------------------------------------------*/
43 #include "OSspecific.H"
44 #include "NamedEnum.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 /*---------------------------------------------------------------------------*\
53 Class regIOobject Declaration
54 \*---------------------------------------------------------------------------*/
63 //- Types of communications
72 static const NamedEnum<fileCheckTypes, 4> fileCheckTypesNames;
79 //- Is this object registered with the registry
82 //- Is this object owned by the registry
83 bool ownedByRegistry_;
85 //- Modification watch index
86 mutable label watchIndex_;
88 //- eventNo of last update
91 //- Istream for reading
95 // Private Member Functions
98 Istream& readStream();
100 //- Dissallow assignment
101 void operator=(const regIOobject&);
108 //- Runtime type information
109 TypeName("regIOobject");
111 static int fileModificationSkew;
113 static fileCheckTypes fileModificationChecking;
118 //- Construct from IOobject. Optional flag for if IOobject is the
119 // top level regIOobject.
120 regIOobject(const IOobject&, const bool isTime = false);
122 //- Construct as copy
123 regIOobject(const regIOobject&);
125 //- Construct as copy, and transferring registry registration to copy
126 // if registerCopy is true
127 regIOobject(const regIOobject&, bool registerCopy);
131 virtual ~regIOobject();
138 //- Add object to registry
141 //- Remove object from registry
144 //- Is this object owned by the registry?
145 inline bool ownedByRegistry() const;
147 //- Transfer ownership of this object to its registry
150 //- Transfer ownership of the given object pointer to its registry
151 // and return reference to object.
153 inline static Type& store(Type*);
155 //- Transfer ownership of the given object pointer to its registry
156 // and return reference to object.
158 inline static Type& store(autoPtr<Type>&);
160 //- Release ownership of this object from its registry
161 inline void release();
164 // Dependency checking
166 //- Event number at last update.
167 inline label eventNo() const;
169 //- Event number at last update.
170 inline label& eventNo();
172 //- Return true if up-to-date with respect to given object
174 bool upToDate(const regIOobject&) const;
176 //- Return true if up-to-date with respect to given objects
184 //- Return true if up-to-date with respect to given objects
193 //- Return true if up-to-date with respect to given objects
203 //- Set up to date (obviously)
210 virtual void rename(const word& newName);
215 //- Return Istream and check object type against that given
216 Istream& readStream(const word&);
221 //- Virtual readData function.
222 // Must be defined in derived types for which
223 // re-reading is required
224 virtual bool readData(Istream&);
229 //- Return file-monitoring handle
230 inline label watchIndex() const;
232 //- Return file-monitoring handle
233 inline label& watchIndex();
235 //- Return true if the object's file (or files for objectRegistry)
236 // have been modified. (modified state is cached by Time)
237 virtual bool modified() const;
239 //- Read object if modified (as set by call to modified)
240 virtual bool readIfModified();
245 //- Pure virtual writaData function.
246 // Must be defined in derived types
247 virtual bool writeData(Ostream&) const = 0;
249 //- Write using given format, version and compression
250 virtual bool writeObject
252 IOstream::streamFormat,
253 IOstream::versionNumber,
254 IOstream::compressionType
257 //- Write using setting from DB
258 virtual bool write() const;
263 void operator=(const IOobject&);
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 } // End namespace Foam
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 #include "regIOobjectI.H"
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 // ************************************************************************* //