initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / containers / HashTables / HashPtrTable / HashPtrTable.H
blob78cb735e17066245c211c932bbd20ac486777b3b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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>
55 Istream& operator>>(Istream&, HashPtrTable<T, Key, Hash>&);
57 template<class T, class Key, class Hash>
58 Ostream& operator<<(Ostream&, const HashPtrTable<T, Key, Hash>&);
61 /*---------------------------------------------------------------------------*\
62                         Class HashPtrTable Declaration
63 \*---------------------------------------------------------------------------*/
65 template<class T, class Key=word, class Hash=string::hash>
66 class HashPtrTable
68     public HashTable<T*, Key, Hash>
70     // Private member functions
72         //- Read from Istream using given Istream constructor class
73         template<class INew>
74         void read(Istream&, const INew& inewt);
77 public:
79     typedef typename HashTable<T*, Key, Hash>::iterator iterator;
80     typedef typename HashTable<T*, Key, Hash>::const_iterator const_iterator;
83     // Constructors
85         //- Construct given initial table size
86         HashPtrTable(const label size = 128);
88         //- Construct from Istream using given Istream constructor class
89         template<class INew>
90         HashPtrTable(Istream&, const INew&);
92         //- Construct from Istream using default Istream constructor class
93         HashPtrTable(Istream&);
95         //- Construct as copy
96         HashPtrTable(const HashPtrTable<T, Key, Hash>&);
99     // Destructor
101         ~HashPtrTable();
104     // Member Functions
106         // Edit
108             //- Remove and return the pointer specified by given iterator
109             T* remove(iterator&);
111             //- Erase an hashedEntry specified by given iterator
112             bool erase(iterator&);
114             //- Clear all entries from table
115             void clear();
118     // Member Operators
120         void operator=(const HashPtrTable<T, Key, Hash>&);
123     // IOstream Operators
125         friend Istream& operator>> <T, Key, Hash>
126         (
127             Istream&,
128             HashPtrTable<T, Key, Hash>&
129         );
131         friend Ostream& operator<< <T, Key, Hash>
132         (
133             Ostream&,
134             const HashPtrTable<T, Key, Hash>&
135         );
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 } // End namespace Foam
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 #ifdef NoRepository
146 #   include "HashPtrTable.C"
147 #endif
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 #endif
153 // ************************************************************************* //