[core] Simplify wheelchair functions by using ftraits

Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com>
This commit is contained in:
David Martinez 2024-02-25 16:58:41 +01:00 committed by Viktor Govako
parent 9cfbc272cb
commit 0dd0741943
5 changed files with 18 additions and 28 deletions

View file

@ -456,18 +456,25 @@ string GetLocalizedFeeType(TypesHolder const & types)
string GetReadableWheelchairType(TypesHolder const & types)
{
auto const & isWheelchairType = ftypes::IsWheelchairTypeChecker::Instance();
auto readableTypes = GetReadableTypes(isWheelchairType, types);
ASSERT_LESS_OR_EQUAL ( readableTypes.size(), 1, () );
if (readableTypes.empty())
return "";
return readableTypes[0];
auto const value = ftraits::Wheelchair::GetValue(types);
if (!value.has_value())
return "";
switch (*value)
{
case ftraits::WheelchairAvailability::No:
return "wheelchair-no";
case ftraits::WheelchairAvailability::Yes:
return "wheelchair-yes";
case ftraits::WheelchairAvailability::Limited:
return "wheelchair-limited";
}
UNREACHABLE();
}
ftraits::WheelchairAvailability GetWheelchairType(TypesHolder const & types)
std::optional<ftraits::WheelchairAvailability> GetWheelchairType(TypesHolder const & types)
{
auto const opt = ftraits::Wheelchair::GetValue(types);
return opt ? *opt : ftraits::WheelchairAvailability::Unknown;
return ftraits::Wheelchair::GetValue(types);
}
bool HasAtm(TypesHolder const & types)

View file

@ -155,7 +155,7 @@ namespace feature
std::string GetReadableWheelchairType(TypesHolder const & types);
/// @returns wheelchair availability.
ftraits::WheelchairAvailability GetWheelchairType(TypesHolder const & types);
std::optional<ftraits::WheelchairAvailability> GetWheelchairType(TypesHolder const & types);
/// Returns true if feature has ATM type.
bool HasAtm(TypesHolder const & types);

View file

@ -74,7 +74,6 @@ enum class WheelchairAvailability
No,
Yes,
Limited,
Unknown
};
inline std::string DebugPrint(WheelchairAvailability wheelchair)
@ -84,7 +83,6 @@ inline std::string DebugPrint(WheelchairAvailability wheelchair)
case WheelchairAvailability::No: return "No";
case WheelchairAvailability::Yes: return "Yes";
case WheelchairAvailability::Limited: return "Limited";
case WheelchairAvailability::Unknown: return "Unknown";
}
UNREACHABLE();
}
@ -99,8 +97,7 @@ class Wheelchair : public TraitsBase<Wheelchair, WheelchairAvailability>
{
m_matcher.Append<TypesInitializer>({{"wheelchair", "no"}}, WheelchairAvailability::No);
m_matcher.Append<TypesInitializer>({{"wheelchair", "yes"}}, WheelchairAvailability::Yes);
m_matcher.Append<TypesInitializer>({{"wheelchair", "limited"}},
WheelchairAvailability::Limited);
m_matcher.Append<TypesInitializer>({{"wheelchair", "limited"}}, WheelchairAvailability::Limited);
}
};

View file

@ -765,12 +765,6 @@ IsFeeTypeChecker::IsFeeTypeChecker() : BaseChecker(1 /* level */)
m_types.push_back(c.GetTypeByPath({"fee"}));
}
IsWheelchairTypeChecker::IsWheelchairTypeChecker() : BaseChecker(1 /* level */)
{
Classificator const & c = classif();
m_types.push_back(c.GetTypeByPath({"wheelchair"}));
}
IsToiletsChecker::IsToiletsChecker() : BaseChecker(2 /* level */)
{
Classificator const & c = classif();

View file

@ -476,14 +476,6 @@ public:
DECLARE_CHECKER_INSTANCE(IsFeeTypeChecker);
};
class IsWheelchairTypeChecker : public BaseChecker
{
IsWheelchairTypeChecker();
public:
DECLARE_CHECKER_INSTANCE(IsWheelchairTypeChecker);
};
class IsToiletsChecker : public BaseChecker
{
IsToiletsChecker();