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