1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
29 Base dictionary class templated on both the form of doubly-linked list
30 it uses as well as the type it holds.
32 The double templating allows for the instantiation of forms with or
33 without storage management.
36 The IDLListType parameter should itself be a template but this confused
37 gcc 2.95.2 so it has to be instantiated for T when an instantiation of
38 DictionaryBase is requested
41 Dictionary and UDictionary
47 \*---------------------------------------------------------------------------*/
49 #ifndef DictionaryBase_H
50 #define DictionaryBase_H
52 #include "HashTable.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 // Forward declaration of friend functions and operators
62 template<class IDLListType, class T>
65 template<class IDLListType, class T>
66 Ostream& operator<<(Ostream&, const DictionaryBase<IDLListType, T>&);
69 /*---------------------------------------------------------------------------*\
70 Class DictionaryBase Declaration
71 \*---------------------------------------------------------------------------*/
73 template<class IDLListType, class T>
80 //- HashTable of the entries held on the IDLListType for quick lookup
81 HashTable<T*> hashedTs_;
84 // Private Member functions
86 // Add the IDLListType entries into the HashTable
98 DictionaryBase(const DictionaryBase&);
100 //- Construct from Istream using given Istream constructor class
102 DictionaryBase(Istream&, const INew&);
104 //- Construct from Istream using default Istream constructor class
105 DictionaryBase(Istream&);
112 //- Search DictionaryBase for given keyword
113 bool found(const word&) const;
115 //- Find and return an entry if present, otherwise return NULL
116 const T* lookupPtr(const word&) const;
118 //- Find and return an entry if present, otherwise return NULL
119 T* lookupPtr(const word&);
121 //- Find and return entry
122 const T* lookup(const word&) const;
124 //- Find and return entry
125 T* lookup(const word&);
127 //- Return the table of contents
128 wordList toc() const;
133 //- Add at head of dictionary
134 void insert(const word&, T*);
136 //- Add at tail of dictionary
137 void append(const word&, T*);
139 //- Remove and return entry specified by keyword.
140 // Return NULL if the keyword was not found.
141 T* remove(const word&);
143 //- Clear the dictionary
146 //- Transfer the contents of the argument into this DictionaryBase
147 // and annull the argument.
148 void transfer(DictionaryBase<IDLListType, T>&);
152 void operator=(const DictionaryBase&);
154 //- Find and return entry
155 const T* operator[](const word& key) const
160 //- Find and return entry
161 T* operator[](const word& key)
169 friend Ostream& operator<< <IDLListType, T>
172 const DictionaryBase<IDLListType, T>&
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 # include "DictionaryBase.C"
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 // ************************************************************************* //