FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

HashPtrTable.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-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::HashPtrTable
00026 
00027 Description
00028     A HashTable specialization for hashing pointers.
00029 
00030 SourceFiles
00031     HashPtrTable.C
00032     HashPtrTableIO.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef HashPtrTable_H
00037 #define HashPtrTable_H
00038 
00039 #include <OpenFOAM/HashTable.H>
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 class Istream;
00047 class Ostream;
00048 
00049 // Forward declaration of friend functions and operators
00050 
00051 template<class T, class Key, class Hash> class HashPtrTable;
00052 
00053 template<class T, class Key, class Hash>
00054 Istream& operator>>(Istream&, HashPtrTable<T, Key, Hash>&);
00055 
00056 template<class T, class Key, class Hash>
00057 Ostream& operator<<(Ostream&, const HashPtrTable<T, Key, Hash>&);
00058 
00059 
00060 /*---------------------------------------------------------------------------*\
00061                         Class HashPtrTable Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 template<class T, class Key=word, class Hash=string::hash>
00065 class HashPtrTable
00066 :
00067     public HashTable<T*, Key, Hash>
00068 {
00069     // Private member functions
00070 
00071         //- Read from Istream using given Istream constructor class
00072         template<class INew>
00073         void read(Istream&, const INew& inewt);
00074 
00075 
00076 public:
00077 
00078     typedef typename HashTable<T*, Key, Hash>::iterator iterator;
00079     typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
00080 
00081 
00082     // Constructors
00083 
00084         //- Construct given initial table size
00085         HashPtrTable(const label size = 128);
00086 
00087         //- Construct from Istream using given Istream constructor class
00088         template<class INew>
00089         HashPtrTable(Istream&, const INew&);
00090 
00091         //- Construct from Istream using default Istream constructor class
00092         HashPtrTable(Istream&);
00093 
00094         //- Construct as copy
00095         HashPtrTable(const HashPtrTable<T, Key, Hash>&);
00096 
00097 
00098     // Destructor
00099 
00100         ~HashPtrTable();
00101 
00102 
00103     // Member Functions
00104 
00105         // Edit
00106 
00107             //- Remove and return the pointer specified by given iterator
00108             T* remove(iterator&);
00109 
00110             //- Erase an hashedEntry specified by given iterator
00111             bool erase(iterator&);
00112 
00113             //- Clear all entries from table
00114             void clear();
00115 
00116 
00117     // Member Operators
00118 
00119         void operator=(const HashPtrTable<T, Key, Hash>&);
00120 
00121 
00122     // IOstream Operators
00123 
00124         friend Istream& operator>> <T, Key, Hash>
00125         (
00126             Istream&,
00127             HashPtrTable<T, Key, Hash>&
00128         );
00129 
00130         friend Ostream& operator<< <T, Key, Hash>
00131         (
00132             Ostream&,
00133             const HashPtrTable<T, Key, Hash>&
00134         );
00135 };
00136 
00137 
00138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00139 
00140 } // End namespace Foam
00141 
00142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00143 
00144 #ifdef NoRepository
00145 #   include <OpenFOAM/HashPtrTable.C>
00146 #endif
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 #endif
00151 
00152 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines