initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / containers / HashTables / HashPtrTable / HashPtrTable.H
blobd8dca506098d5b801ad19ee45395c883b3a636b7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::HashPtrTable
28 Description
29     A HashTable specialization for hashing pointers.
31 SourceFiles
32     HashPtrTable.C
33     HashPtrTableIO.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef HashPtrTable_H
38 #define HashPtrTable_H
40 #include "HashTable.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 class Istream;
48 class Ostream;
50 // Forward declaration of friend functions and operators
52 template<class T, class Key, class Hash> class HashPtrTable;
54 template<class T, class Key, class Hash> Istream& operator>>
56     Istream&,
57     HashPtrTable<T, Key, Hash>&
60 template<class T, class Key, class Hash> Ostream& operator<<
62     Ostream&,
63     const HashPtrTable<T, Key, Hash>&
67 /*---------------------------------------------------------------------------*\
68                            Class HashPtrTable Declaration
69 \*---------------------------------------------------------------------------*/
71 template<class T, class Key=word, class Hash=string::hash>
72 class HashPtrTable
74     public HashTable<T*, Key, Hash>
76     // Private member functions
78         //- Read from Istream using given Istream constructor class
79         template<class INew>
80         void read(Istream&, const INew& inewt);
83 public:
85     typedef typename HashTable<T*, Key, Hash>::iterator iterator;
86     typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
89     // Constructors
91         //- Construct given initial table size
92         HashPtrTable(label size = 100);
94         //- Construct from Istream using given Istream constructor class
95         template<class INew>
96         HashPtrTable(Istream&, const INew&);
98         //- Construct from Istream using default Istream constructor class
99         HashPtrTable(Istream&);
101         //- Construct as copy
102         HashPtrTable(const HashPtrTable<T, Key, Hash>&);
105     // Destructor
107         ~HashPtrTable();
110     // Member Functions
112         // Edit
114             //- Remove and return the pointer specified by given iterator
115             T* remove(iterator&);
117             //- Erase an hashedEntry specified by given iterator
118             bool erase(iterator&);
120             //- Clear all entries from table
121             void clear();
124     // Member Operators
126         void operator=(const HashPtrTable<T, Key, Hash>&);
129     // IOstream Operators
131         friend Istream& operator>>
132         #ifndef __CINT__
133         <T, Key, Hash>
134         #endif
135         (
136             Istream&,
137             HashPtrTable<T, Key, Hash>&
138         );
140         friend Ostream& operator<<
141         #ifndef __CINT__
142         <T, Key, Hash>
143         #endif
144         (
145             Ostream&,
146             const HashPtrTable<T, Key, Hash>&
147         );
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 } // End namespace Foam
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 #ifdef NoRepository
158 #   include "HashPtrTable.C"
159 #endif
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 #endif
165 // ************************************************************************* //