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