OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

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