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
NamedEnum
NamedEnum.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::NamedEnum
26
27
Description
28
Initialise the NamedEnum HashTable from the static list of names.
29
30
SourceFiles
31
NamedEnum.C
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef NamedEnum_H
36
#define NamedEnum_H
37
38
#include <
OpenFOAM/HashTable.H
>
39
#include <
OpenFOAM/StaticAssert.H
>
40
41
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43
namespace
Foam
44
{
45
46
/*---------------------------------------------------------------------------*\
47
Class NamedEnum Declaration
48
\*---------------------------------------------------------------------------*/
49
50
template
<
class
Enum,
int
nEnum>
51
class
NamedEnum
52
:
53
public
HashTable
<int>
54
{
55
//- nEnum must be positive (non-zero)
56
StaticAssert(nEnum > 0);
57
58
// Private Member Functions
59
60
//- Disallow default bitwise copy construct
61
NamedEnum
(
const
NamedEnum
&);
62
63
//- Disallow default bitwise assignment
64
void
operator=(
const
NamedEnum
&);
65
66
67
public
:
68
69
// Static data members
70
71
//- The set of names corresponding to the enumeration Enum
72
static
const
char
*
names
[nEnum];
73
74
75
// Constructors
76
77
//- Construct from names
78
NamedEnum
();
79
80
81
// Member Functions
82
83
//- Read a word from Istream and return the corresponding
84
// enumeration element
85
Enum
read
(
Istream
&)
const
;
86
87
//- Write the name representation of the enumeration to an Ostream
88
void
write
(
const
Enum
e
,
Ostream
&)
const
;
89
90
91
// Member Operators
92
93
//- Return the enumeration element corresponding to the given name
94
const
Enum
operator[]
(
const
char
*
name
)
const
95
{
96
return
Enum(
HashTable<int>::operator
[](name));
97
}
98
99
//- Return the enumeration element corresponding to the given name
100
const
Enum
operator[]
(
const
word
&
name
)
const
101
{
102
return
Enum(
HashTable<int>::operator
[](name));
103
}
104
105
//- Return the name of the given enumeration element
106
const
char
*
operator[]
(
const
Enum
e
)
const
107
{
108
return
names
[
e
];
109
}
110
};
111
112
113
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114
115
}
// End namespace Foam
116
117
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118
119
#ifdef NoRepository
120
# include "
NamedEnum.C
"
121
#endif
122
123
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124
125
#endif
126
127
// ************************ vim: set sw=4 sts=4 et: ************************ //