OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

regIOobject.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::regIOobject
00027 
00028 Description
00029     regIOobject is an abstract class derived from IOobject to handle
00030     automatic object registration with the objectRegistry.
00031 
00032 SourceFiles
00033     regIOobject.C
00034     regIOobjectRead.C
00035     regIOobjectWrite.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef regIOobject_H
00040 #define regIOobject_H
00041 
00042 #include "IOobject.H"
00043 #include "typeInfo.H"
00044 #include "OSspecific.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 
00049 namespace Foam
00050 {
00051 
00052 /*---------------------------------------------------------------------------*\
00053                          Class regIOobject Declaration
00054 \*---------------------------------------------------------------------------*/
00055 
00056 class regIOobject
00057 :
00058     public IOobject
00059 {
00060 
00061 private:
00062 
00063     // Private data
00064 
00065         //- Is this object registered with the registry
00066         bool registered_;
00067 
00068         //- Is this object owned by the registry
00069         bool ownedByRegistry_;
00070 
00071         //- Time of last modification
00072         mutable time_t lastModified_;
00073 
00074         //- eventNo of last update
00075         label eventNo_;
00076 
00077         //- Istream for reading
00078         Istream* isPtr_;
00079 
00080 
00081     // Private member functions
00082 
00083         //- Return Istream
00084         Istream& readStream();
00085 
00086         //- Dissallow assignment
00087         void operator=(const regIOobject&);
00088 
00089 
00090 public:
00091 
00092     // Static data
00093 
00094         //- Runtime type information
00095         TypeName("regIOobject");
00096 
00097         static int fileModificationSkew;
00098 
00099 
00100     // Constructors
00101 
00102         //- Construct from IOobject. Optional flag for if IOobject is the
00103         //  top level regIOobject.
00104         regIOobject(const IOobject&, const bool isTime = false);
00105 
00106         //- Construct as copy
00107         regIOobject(const regIOobject&);
00108 
00109         //- Construct as copy, and transferring registry registration to copy
00110         //  if registerCopy is true
00111         regIOobject(const regIOobject&, bool registerCopy);
00112 
00113 
00114     // Destructor
00115 
00116         virtual ~regIOobject();
00117 
00118 
00119     // Member functions
00120 
00121         // Registration
00122 
00123             //- Add object to registry
00124             bool checkIn();
00125 
00126             //- Remove object from registry
00127             bool checkOut();
00128 
00129             //- Is this object owned by the registry?
00130             inline bool ownedByRegistry() const;
00131 
00132             //- Transfer ownership of this object to its registry
00133             inline void store();
00134 
00135             //- Transfer ownership of the given object pointer to its registry
00136             //  and return reference to object.
00137             template<class Type>
00138             inline static Type& store(Type*);
00139 
00140             //- Transfer ownership of the given object pointer to its registry
00141             //  and return reference to object.
00142             template<class Type>
00143             inline static Type& store(autoPtr<Type>&);
00144 
00145             //- Release ownership of this object from its registry
00146             inline void release();
00147 
00148 
00149         // Dependency checking
00150 
00151             //- Event number at last update.
00152             inline label eventNo() const;
00153 
00154             //- Event number at last update.
00155             inline label& eventNo();
00156 
00157             //- Am I uptodate with respect to other regIOobjects
00158             bool upToDate(const word&) const;
00159             bool upToDate(const word&, const word&) const;
00160             bool upToDate(const word&, const word&, const word&) const;
00161             bool upToDate
00162             (
00163                 const word&,
00164                 const word&,
00165                 const word&,
00166                 const word&
00167             ) const;
00168 
00169             //- Flag me as up to date
00170             void setUpToDate();
00171 
00172 
00173         // Edit
00174 
00175             //- Rename
00176             virtual void rename(const word& newName);
00177 
00178 
00179         // Reading
00180 
00181             //- Return Istream and check object type against that given
00182             Istream& readStream(const word&);
00183 
00184             //- Close Istream
00185             void close();
00186 
00187             //- Virtual readData function.
00188             //  Must be defined in derived types for which
00189             //  re-reading is required
00190             virtual bool readData(Istream&);
00191 
00192             //- Read object
00193             virtual bool read();
00194 
00195             //- Return true if the object's file has been modified
00196             virtual bool modified() const;
00197 
00198             //- Read object if modified
00199             virtual bool readIfModified();
00200 
00201 
00202         // Writing
00203 
00204             //- Pure virtual writaData function.
00205             //  Must be defined in derived types
00206             virtual bool writeData(Ostream&) const = 0;
00207 
00208             //- Write using given format, version and compression
00209             virtual bool writeObject
00210             (
00211                 IOstream::streamFormat,
00212                 IOstream::versionNumber,
00213                 IOstream::compressionType
00214             ) const;
00215 
00216             //- Write using setting from DB
00217             virtual bool write() const;
00218 
00219 
00220     // Member operators
00221 
00222         void operator=(const IOobject&);
00223 };
00224 
00225 
00226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00227 
00228 } // End namespace Foam
00229 
00230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00231 
00232 #include "regIOobjectI.H"
00233 
00234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00235 
00236 #endif
00237 
00238 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd