Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
containers
Dictionaries
DictionaryBase
DictionaryBase.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
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
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
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.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::DictionaryBase
26
27
Description
28
Base dictionary class templated on both the form of doubly-linked list
29
it uses as well as the type it holds.
30
31
The double templating allows for the instantiation of forms with or
32
without storage management.
33
34
Note
35
The IDLListType parameter should itself be a template but this confused
36
gcc 2.95.2 so it has to be instantiated for T when an instantiation of
37
DictionaryBase is requested
38
39
See Also
40
Dictionary and UDictionary
41
42
SourceFiles
43
DictionaryBase.C
44
DictionaryBaseIO.C
45
46
\*---------------------------------------------------------------------------*/
47
48
#ifndef DictionaryBase_H
49
#define DictionaryBase_H
50
51
#include <
OpenFOAM/HashTable.H
>
52
#include <
OpenFOAM/wordList.H
>
53
54
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55
56
namespace
Foam
57
{
58
59
// Forward declaration of friend functions and operators
60
61
template
<
class
IDLListType,
class
T>
62
class
DictionaryBase;
63
64
template
<
class
IDLListType,
class
T>
65
Ostream& operator<<(Ostream&, const DictionaryBase<IDLListType, T>&);
66
67
68
/*---------------------------------------------------------------------------*\
69
Class DictionaryBase Declaration
70
\*---------------------------------------------------------------------------*/
71
72
template
<
class
IDLListType,
class
T>
73
class
DictionaryBase
74
:
75
public
IDLListType
76
{
77
// Private data
78
79
//- HashTable of the entries held on the IDLListType for quick lookup
80
HashTable<T*>
hashedTs_;
81
82
83
// Private Member functions
84
85
// Add the IDLListType entries into the HashTable
86
void
addEntries();
87
88
89
public
:
90
91
// Constructors
92
93
//- Null constructor
94
DictionaryBase
();
95
96
//- Copy construct
97
DictionaryBase
(
const
DictionaryBase
&);
98
99
//- Construct from Istream using given Istream constructor class
100
template
<
class
INew>
101
DictionaryBase
(
Istream
&,
const
INew
&);
102
103
//- Construct from Istream using default Istream constructor class
104
DictionaryBase
(
Istream
&);
105
106
107
// Member functions
108
109
// Search and lookup
110
111
//- Search DictionaryBase for given keyword
112
bool
found
(
const
word
&)
const
;
113
114
//- Find and return an entry if present, otherwise return NULL
115
const
T
*
lookupPtr
(
const
word
&)
const
;
116
117
//- Find and return an entry if present, otherwise return NULL
118
T
*
lookupPtr
(
const
word
&);
119
120
//- Find and return entry
121
const
T
*
lookup
(
const
word
&)
const
;
122
123
//- Find and return entry
124
T
*
lookup
(
const
word
&);
125
126
//- Return the table of contents
127
wordList
toc
()
const
;
128
129
130
// Editing
131
132
//- Add at head of dictionary
133
void
insert
(
const
word
&,
T
*);
134
135
//- Add at tail of dictionary
136
void
append
(
const
word
&,
T
*);
137
138
//- Remove and return entry specified by keyword.
139
// Return NULL if the keyword was not found.
140
T
*
remove
(
const
word
&);
141
142
//- Clear the dictionary
143
void
clear
();
144
145
//- Transfer the contents of the argument into this DictionaryBase
146
// and annull the argument.
147
void
transfer
(
DictionaryBase<IDLListType, T>
&);
148
149
// Member operators
150
151
void
operator=
(
const
DictionaryBase
&);
152
153
//- Find and return entry
154
const
T
*
operator[]
(
const
word
& key)
const
155
{
156
return
lookup
(key);
157
}
158
159
//- Find and return entry
160
T
*
operator[]
(
const
word
& key)
161
{
162
return
lookup
(key);
163
}
164
165
166
// Ostream operator
167
168
friend
Ostream
& operator<< <IDLListType, T>
169
(
170
Ostream
&,
171
const
DictionaryBase<IDLListType, T>
&
172
);
173
};
174
175
176
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178
}
// End namespace Foam
179
180
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181
182
#ifdef NoRepository
183
# include <
OpenFOAM/DictionaryBase.C
>
184
#endif
185
186
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188
#endif
189
190
// ************************ vim: set sw=4 sts=4 et: ************************ //