Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
b9e0ca1d
Commit
b9e0ca1d
authored
5 years ago
by
Mark OLESEN
Committed by
Andrew Heather
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add Enum single-parameter operator() to resemble a unary function
parent
c5ed28d0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OpenFOAM/primitives/enums/Enum.H
+9
-4
9 additions, 4 deletions
src/OpenFOAM/primitives/enums/Enum.H
src/OpenFOAM/primitives/enums/EnumI.H
+13
-3
13 additions, 3 deletions
src/OpenFOAM/primitives/enums/EnumI.H
with
22 additions
and
7 deletions
src/OpenFOAM/primitives/enums/Enum.H
+
9
−
4
View file @
b9e0ca1d
...
...
@@ -211,13 +211,18 @@ public:
// Identical to single parameter get()
inline
EnumType
operator
[](
const
word
&
enumName
)
const
;
//- Return the first name corresponding to the given enumeration
.
//
Returns
an empty word on failure.
//- Return the first name corresponding to the given enumeration
,
//
- or
an empty word on failure.
// Identical to single parameter get()
inline
const
word
&
operator
[](
const
EnumType
e
)
const
;
//- Return the enumeration corresponding to the given name or
//- deflt if the name is not found.
//- Return the first name corresponding to the given enumeration,
//- or an empty word on failure.
// Identical to single parameter get()
inline
const
word
&
operator
()(
const
EnumType
e
)
const
;
//- Return the enumeration corresponding to the given name,
//- or deflt if the name is not found.
inline
EnumType
operator
()
(
const
word
&
enumName
,
...
...
This diff is collapsed.
Click to expand it.
src/OpenFOAM/primitives/enums/EnumI.H
+
13
−
3
View file @
b9e0ca1d
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017-201
8
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-201
9
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -140,11 +140,21 @@ inline const Foam::word& Foam::Enum<EnumType>::operator[]
}
template
<
class
EnumType
>
inline
const
Foam
::
word
&
Foam
::
Enum
<
EnumType
>::
operator
()
(
const
EnumType
e
)
const
{
return
get
(
e
);
}
template
<
class
EnumType
>
inline
EnumType
Foam
::
Enum
<
EnumType
>::
operator
()
(
const
word
&
enumName
,
const
EnumType
def
aultValue
const
EnumType
def
lt
)
const
{
const
label
idx
=
find
(
enumName
);
...
...
@@ -154,7 +164,7 @@ inline EnumType Foam::Enum<EnumType>::operator()
return
EnumType
(
vals_
[
idx
]);
}
return
def
aultValue
;
return
def
lt
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment