diff --git a/src/OpenFOAM/primitives/enums/Enum.H b/src/OpenFOAM/primitives/enums/Enum.H index 8d28977ba0..b59ce442ea 100644 --- a/src/OpenFOAM/primitives/enums/Enum.H +++ b/src/OpenFOAM/primitives/enums/Enum.H @@ -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, diff --git a/src/OpenFOAM/primitives/enums/EnumI.H b/src/OpenFOAM/primitives/enums/EnumI.H index 35937fa613..be7308849b 100644 --- a/src/OpenFOAM/primitives/enums/EnumI.H +++ b/src/OpenFOAM/primitives/enums/EnumI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -140,11 +140,21 @@ inline const Foam::word& Foam::Enum::operator[] } +template +inline const Foam::word& Foam::Enum::operator() +( + const EnumType e +) const +{ + return get(e); +} + + template inline EnumType Foam::Enum::operator() ( const word& enumName, - const EnumType defaultValue + const EnumType deflt ) const { const label idx = find(enumName); @@ -154,7 +164,7 @@ inline EnumType Foam::Enum::operator() return EnumType(vals_[idx]); } - return defaultValue; + return deflt; }