![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 objectRegistry 00027 00028 Description 00029 Registry of regIOobjects. 00030 00031 SourceFiles 00032 objectRegistry.C 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef objectRegistry_H 00037 #define objectRegistry_H 00038 00039 #include "HashTable.H" 00040 #include "regIOobject.H" 00041 00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00043 00044 namespace Foam 00045 { 00046 00047 typedef HashTable<regIOobject*> regIOobjectTable; 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class objectRegistry Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class objectRegistry 00054 : 00055 public regIOobject, 00056 public regIOobjectTable 00057 { 00058 // Private Data 00059 00060 //- Master time objectRegistry 00061 const Time& time_; 00062 00063 //- Parent objectRegistry 00064 const objectRegistry& parent_; 00065 00066 //- Local directory path of this objectRegistry relative to time 00067 fileName dbDir_; 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 = 100 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 = 100 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 00135 wordList names(const word& className) const; 00136 00137 //- Lookup and return a const sub-objectRegistry 00138 const objectRegistry& subRegistry(const word& name) const; 00139 00140 //- Lookup and return all the object of the given Type 00141 template<class Type> 00142 HashTable<const Type*> lookupClass() const; 00143 00144 //- Is the named Type 00145 template<class Type> 00146 bool foundObject(const word& name) const; 00147 00148 //- Lookup and return the object of the given Type 00149 template<class Type> 00150 const Type& lookupObject(const word& name) const; 00151 00152 00153 // Edit 00154 00155 //- Add an regIOobject to registry 00156 bool checkIn(regIOobject&) const; 00157 00158 //- Remove an regIOobject from registry 00159 bool checkOut(regIOobject&) const; 00160 00161 00162 // Reading 00163 00164 //- Read the objects that have been modified 00165 void readModifiedObjects(); 00166 00167 //- Read object if modified 00168 virtual bool readIfModified(); 00169 00170 00171 // Writing 00172 00173 //- writeData function required by regIOobject but not used 00174 // for this class, write is used instead 00175 virtual bool writeData(Ostream&) const 00176 { 00177 notImplemented 00178 ( 00179 "void objectRegistry::writeData(Ostream&) const: " 00180 "use write() instead" 00181 ); 00182 00183 return false; 00184 } 00185 00186 //- Write the objects 00187 virtual bool write 00188 ( 00189 IOstream::streamFormat fmt, 00190 IOstream::versionNumber ver, 00191 IOstream::compressionType cmp 00192 ) const; 00193 00194 //- Write using setting from DB 00195 bool write() const 00196 { 00197 return regIOobject::write(); 00198 } 00199 }; 00200 00201 00202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00203 00204 } // End namespace Foam 00205 00206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00207 00208 #ifdef NoRepository 00209 # include "objectRegistryTemplates.C" 00210 #endif 00211 00212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00213 00214 #endif 00215 00216 // ************************************************************************* //