35template<
class EnumType,
int nEnum>
40 for (
int enumi=0; enumi < nEnum; ++enumi)
42 if (names[enumi] && names[enumi][0])
44 lookup_.insert(names[enumi], enumi);
49 List<string> goodNames(enumi);
51 for (
int i = 0; i < enumi; ++i)
53 goodNames[i] =
names[i];
57 <<
"Illegal enumeration name at position " << enumi <<
nl
58 <<
"after entries " << goodNames <<
nl
59 <<
"Possibly your NamedEnum<EnumType, nEnum>::names array"
60 <<
" is not of size " << nEnum <<
endl
69template<
class EnumType,
int nEnum>
72 List<word> lst(nEnum);
75 for (
int enumi=0; enumi < nEnum; ++enumi)
77 if (names[enumi] && names[enumi][0])
88template<
class EnumType,
int nEnum>
94 for (
int enumi=0; enumi < nEnum; ++enumi)
96 if (names[enumi] && names[enumi][0])
98 auto iter = lookup_.cfind(names[enumi]);
102 lst[
count++] = iter.val();
112template<
class EnumType,
int nEnum>
115 const int enumValue(
e);
119 if (iter.val() == enumValue)
128template<
class EnumType,
int nEnum>
132 const dictionary&
dict
135 const word enumName(
dict.lookup(key));
136 auto iter = lookup_.cfind(enumName);
141 << enumName <<
" is not in enumeration: "
142 << lookup_.sortedToc() <<
nl
143 <<
exit(FatalIOError);
146 return EnumType(iter.val());
150template<
class EnumType,
int nEnum>
154 const dictionary&
dict,
160 return lookup(key,
dict);
167template<
class EnumType,
int nEnum>
170 const word enumName(is);
171 auto iter = lookup_.cfind(enumName);
176 << enumName <<
" is not in enumeration: "
177 << lookup_.sortedToc() <<
nl
178 <<
exit(FatalIOError);
181 return EnumType(iter.val());
185template<
class EnumType,
int nEnum>
192 const int idx = int(
e);
193 if (idx >= 0 && idx < nEnum)
202template<
class EnumType,
int nEnum>
206 const NamedEnum<EnumType, nEnum>& wrapped
209 return wrapped.lookup_.writeKeys(
os, 10);
void setSize(const label n)
Alias for resize()
A NamedEnum is a wrapper around a list of names that represent particular enumeration values.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool read()
Re-read model coefficients if they have changed.
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
virtual bool write()
Write the output fields.
Lookup type of boundary radiation properties.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
const UList< T > & values