OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-2007 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     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 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         //- Istream for reading
00074         Istream* isPtr_;
00075 
00076 
00077     // Private member functions
00078 
00079         //- Return Istream
00080         Istream& readStream();
00081 
00082         //- Dissallow assignment
00083         void operator=(const regIOobject&);
00084 
00085 
00086 public:
00087 
00088     // Static data
00089 
00090         //- Runtime type information
00091         TypeName("regIOobject");
00092 
00093         static int fileModificationSkew;
00094 
00095 
00096     // Constructors
00097 
00098         //- Construct from IOobject
00099         regIOobject(const IOobject&);
00100 
00101         //- Construct as copy
00102         regIOobject(const regIOobject&);
00103 
00104         //- Construct as copy, and transfering registry registration to copy
00105         //  if registerCopy is true
00106         regIOobject(const regIOobject&, bool registerCopy);
00107 
00108 
00109     // Destructor
00110 
00111         virtual ~regIOobject();
00112 
00113 
00114     // Member functions
00115 
00116         // Registration
00117 
00118             //- Register object with registry
00119             void checkIn();
00120 
00121             //- Check-out object from registry
00122             void checkOut();
00123 
00124             //- Is this object owned by the registry
00125             inline bool ownedByRegistry() const;
00126 
00127             //- Transfer ownership of this object to it's registry
00128             inline void store();
00129 
00130             //- Transfer ownership of the given object pointer to it's registry
00131             //  and return reference to object.
00132             template<class Type>
00133             inline static Type& store(Type* tPtr);
00134 
00135             //- Transfer ownership of the given object pointer to it's registry
00136             //  and return reference to object.
00137             template<class Type>
00138             inline static Type& store(autoPtr<Type>& atPtr);
00139 
00140             //- Release ownership of this object from it's registry
00141             inline void release();
00142 
00143 
00144         // Edit
00145 
00146             //- Rename
00147             virtual void rename(const word& newName);
00148 
00149 
00150         // Reading
00151 
00152             //- Return Istream and check object type against that given
00153             Istream& readStream(const word&);
00154 
00155             //- Close Istream
00156             void close();
00157 
00158             //- Virtual readData function.
00159             //  Must be defined in derived types for which
00160             //  re-reading is required
00161             virtual bool readData(Istream&);
00162 
00163             //- Read object
00164             virtual bool read();
00165 
00166             //- Return true if the object's file has been modified
00167             virtual bool modified() const;
00168 
00169             //- Read object if modified
00170             virtual bool readIfModified();
00171 
00172 
00173         // Writing
00174 
00175             //- Pure virtual writaData function.
00176             //  Must be defined in derived types
00177             virtual bool writeData(Ostream&) const = 0;
00178 
00179             //- Write using given format, version and compression
00180             virtual bool writeObject
00181             (
00182                 IOstream::streamFormat fmt,
00183                 IOstream::versionNumber ver,
00184                 IOstream::compressionType cmp
00185             ) const;
00186 
00187             //- Write using setting from DB
00188             virtual bool write() const;
00189 
00190 
00191     // Member operators
00192 
00193         void operator=(const IOobject&);
00194 };
00195 
00196 
00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00198 
00199 } // End namespace Foam
00200 
00201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00202 
00203 #   include "regIOobjectI.H"
00204 
00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00206 
00207 #endif
00208 
00209 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd