FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::regIOobject
00026 
00027 Description
00028     regIOobject is an abstract class derived from IOobject to handle
00029     automatic object registration with the objectRegistry.
00030 
00031 SourceFiles
00032     regIOobject.C
00033     regIOobjectRead.C
00034     regIOobjectWrite.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef regIOobject_H
00039 #define regIOobject_H
00040 
00041 #include <OpenFOAM/IOobject.H>
00042 #include <OpenFOAM/typeInfo.H>
00043 #include <OpenFOAM/OSspecific.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 
00048 namespace Foam
00049 {
00050 
00051 /*---------------------------------------------------------------------------*\
00052                          Class regIOobject Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 class regIOobject
00056 :
00057     public IOobject
00058 {
00059 
00060 private:
00061 
00062     // Private data
00063 
00064         //- Is this object registered with the registry
00065         bool registered_;
00066 
00067         //- Is this object owned by the registry
00068         bool ownedByRegistry_;
00069 
00070         //- Time of last modification
00071         mutable time_t lastModified_;
00072 
00073         //- eventNo of last update
00074         label eventNo_;
00075 
00076         //- Istream for reading
00077         Istream* isPtr_;
00078 
00079 
00080     // Private member functions
00081 
00082         //- Return Istream
00083         Istream& readStream();
00084 
00085         //- Dissallow assignment
00086         void operator=(const regIOobject&);
00087 
00088 
00089 public:
00090 
00091     // Static data
00092 
00093         //- Runtime type information
00094         TypeName("regIOobject");
00095 
00096         static int fileModificationSkew;
00097 
00098 
00099     // Constructors
00100 
00101         //- Construct from IOobject. Optional flag for if IOobject is the
00102         //  top level regIOobject.
00103         regIOobject(const IOobject&, const bool isTime = false);
00104 
00105         //- Construct as copy
00106         regIOobject(const regIOobject&);
00107 
00108         //- Construct as copy, and transferring registry registration to copy
00109         //  if registerCopy is true
00110         regIOobject(const regIOobject&, bool registerCopy);
00111 
00112 
00113     // Destructor
00114 
00115         virtual ~regIOobject();
00116 
00117 
00118     // Member functions
00119 
00120         // Registration
00121 
00122             //- Add object to registry
00123             bool checkIn();
00124 
00125             //- Remove object from registry
00126             bool checkOut();
00127 
00128             //- Is this object owned by the registry?
00129             inline bool ownedByRegistry() const;
00130 
00131             //- Transfer ownership of this object to its registry
00132             inline void store();
00133 
00134             //- Transfer ownership of the given object pointer to its registry
00135             //  and return reference to object.
00136             template<class Type>
00137             inline static Type& store(Type*);
00138 
00139             //- Transfer ownership of the given object pointer to its registry
00140             //  and return reference to object.
00141             template<class Type>
00142             inline static Type& store(autoPtr<Type>&);
00143 
00144             //- Release ownership of this object from its registry
00145             inline void release();
00146 
00147 
00148         // Dependency checking
00149 
00150             //- Event number at last update.
00151             inline label eventNo() const;
00152 
00153             //- Event number at last update.
00154             inline label& eventNo();
00155 
00156             //- Am I uptodate with respect to other regIOobjects
00157             bool upToDate(const word&) const;
00158             bool upToDate(const word&, const word&) const;
00159             bool upToDate(const word&, const word&, const word&) const;
00160             bool upToDate
00161             (
00162                 const word&,
00163                 const word&,
00164                 const word&,
00165                 const word&
00166             ) const;
00167 
00168             //- Flag me as up to date
00169             void setUpToDate();
00170 
00171 
00172         // Edit
00173 
00174             //- Rename
00175             virtual void rename(const word& newName);
00176 
00177 
00178         // Reading
00179 
00180             //- Return Istream and check object type against that given
00181             Istream& readStream(const word&);
00182 
00183             //- Close Istream
00184             void close();
00185 
00186             //- Virtual readData function.
00187             //  Must be defined in derived types for which
00188             //  re-reading is required
00189             virtual bool readData(Istream&);
00190 
00191             //- Read object
00192             virtual bool read();
00193 
00194             //- Return true if the object's file has been modified
00195             virtual bool modified() const;
00196 
00197             //- Read object if modified
00198             virtual bool readIfModified();
00199 
00200 
00201         // Writing
00202 
00203             //- Pure virtual writaData function.
00204             //  Must be defined in derived types
00205             virtual bool writeData(Ostream&) const = 0;
00206 
00207             //- Write using given format, version and compression
00208             virtual bool writeObject
00209             (
00210                 IOstream::streamFormat,
00211                 IOstream::versionNumber,
00212                 IOstream::compressionType
00213             ) const;
00214 
00215             //- Write using setting from DB
00216             virtual bool write() const;
00217 
00218 
00219     // Member operators
00220 
00221         void operator=(const IOobject&);
00222 };
00223 
00224 
00225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00226 
00227 } // End namespace Foam
00228 
00229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00230 
00231 #include <OpenFOAM/regIOobjectI.H>
00232 
00233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00234 
00235 #endif
00236 
00237 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines