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::objectRegistry 00026 00027 Description 00028 Registry of regIOobjects 00029 00030 SourceFiles 00031 objectRegistry.C 00032 00033 \*---------------------------------------------------------------------------*/ 00034 00035 #ifndef objectRegistry_H 00036 #define objectRegistry_H 00037 00038 #include <OpenFOAM/HashTable.H> 00039 #include <OpenFOAM/regIOobject.H> 00040 00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00042 00043 namespace Foam 00044 { 00045 00046 /*---------------------------------------------------------------------------*\ 00047 Class objectRegistry Declaration 00048 \*---------------------------------------------------------------------------*/ 00049 00050 class objectRegistry 00051 : 00052 public regIOobject, 00053 public HashTable<regIOobject*> 00054 { 00055 // Private Data 00056 00057 //- Master time objectRegistry 00058 const Time& time_; 00059 00060 //- Parent objectRegistry 00061 const objectRegistry& parent_; 00062 00063 //- Local directory path of this objectRegistry relative to time 00064 fileName dbDir_; 00065 00066 //- Current event 00067 mutable label event_; 00068 00069 00070 // Private Member Functions 00071 00072 //- Disallow Copy constructor 00073 objectRegistry(const objectRegistry&); 00074 00075 //- Disallow default bitwise copy construct and assignment 00076 void operator=(const objectRegistry&); 00077 00078 00079 public: 00080 00081 //- Declare type name for this IOobject 00082 TypeName("objectRegistry"); 00083 00084 00085 // Constructors 00086 00087 //- Construct the time objectRegistry given an initial estimate 00088 // for the number of entries 00089 explicit objectRegistry 00090 ( 00091 const Time& db, 00092 const label nIoObjects = 128 00093 ); 00094 00095 //- Construct a sub-registry given an IObject to describe the registry 00096 // and an initial estimate for the number of entries 00097 explicit objectRegistry 00098 ( 00099 const IOobject& io, 00100 const label nIoObjects = 128 00101 ); 00102 00103 00104 // Destructor 00105 00106 virtual ~objectRegistry(); 00107 00108 00109 // Member functions 00110 00111 // Access 00112 00113 //- Return time 00114 const Time& time() const 00115 { 00116 return time_; 00117 } 00118 00119 //- Return the parent objectRegistry 00120 const objectRegistry& parent() const 00121 { 00122 return parent_; 00123 } 00124 00125 //- Local directory path of this objectRegistry relative to the time 00126 virtual const fileName& dbDir() const 00127 { 00128 return dbDir_; 00129 } 00130 00131 //- Return the list of names of the IOobjects 00132 wordList names() const; 00133 00134 //- Return the list of names of the IOobjects of given class name 00135 wordList names(const word& className) const; 00136 00137 //- Return the list of names of the IOobjects of given type 00138 template<class Type> 00139 wordList names() const; 00140 00141 //- Lookup and return a const sub-objectRegistry 00142 const objectRegistry& subRegistry(const word& name) const; 00143 00144 //- Lookup and return all the object of the given Type 00145 template<class Type> 00146 HashTable<const Type*> lookupClass() const; 00147 00148 //- Is the named Type 00149 template<class Type> 00150 bool foundObject(const word& name) const; 00151 00152 //- Lookup and return the object of the given Type 00153 template<class Type> 00154 const Type& lookupObject(const word& name) const; 00155 00156 //- Return new event number. 00157 label getEvent() const; 00158 00159 00160 // Edit 00161 00162 //- Rename 00163 virtual void rename(const word& newName); 00164 00165 //- Add an regIOobject to registry 00166 bool checkIn(regIOobject&) const; 00167 00168 //- Remove an regIOobject from registry 00169 bool checkOut(regIOobject&) const; 00170 00171 00172 // Reading 00173 00174 //- Return true if any of the object's files have been modified 00175 virtual bool modified() const; 00176 00177 //- Read the objects that have been modified 00178 void readModifiedObjects(); 00179 00180 //- Read object if modified 00181 virtual bool readIfModified(); 00182 00183 00184 // Writing 00185 00186 //- writeData function required by regIOobject but not used 00187 // for this class, write is used instead 00188 virtual bool writeData(Ostream&) const 00189 { 00190 notImplemented 00191 ( 00192 "void objectRegistry::writeData(Ostream&) const: " 00193 "use write() instead" 00194 ); 00195 00196 return false; 00197 } 00198 00199 //- Write the objects 00200 virtual bool writeObject 00201 ( 00202 IOstream::streamFormat fmt, 00203 IOstream::versionNumber ver, 00204 IOstream::compressionType cmp 00205 ) const; 00206 }; 00207 00208 00209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00210 00211 } // End namespace Foam 00212 00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00214 00215 #ifdef NoRepository 00216 # include <OpenFOAM/objectRegistryTemplates.C> 00217 #endif 00218 00219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00220 00221 #endif 00222 00223 // ************************ vim: set sw=4 sts=4 et: ************************ //