Commit b52c66bb authored by Julien Cabieces's avatar Julien Cabieces

add const to GetTypeFilter

parent fc18b8b4
......@@ -590,7 +590,7 @@ public:
* \param[in] key The parameter key (must be a FieldParameter)
* \return List of allowed types
*/
const FieldParameter::TypeFilterType& GetTypeFilter(std::string const& key );
const FieldParameter::TypeFilterType& GetTypeFilter(std::string const& key ) const;
/**
* Set raster data name from which we choose the bands for a BandParameter
......
......@@ -476,6 +476,17 @@ T* downcast_check(Parameter* param)
return down;
}
template <typename T>
const T* const_downcast_check(const Parameter* param)
{
const T* down = dynamic_cast<const T*>(param);
if (down == nullptr)
{
param->TypeError(ParameterTypeToString(T::New()->GetType()));
}
return down;
}
void Application::LoadParametersFromXML(const std::string& filename)
{
otb::Wrapper::XML::Read(filename, this);
......@@ -1373,9 +1384,9 @@ void Application::SetTypeFilter(std::string const& key, FieldParameter::TypeFilt
param->SetTypeFilter(typeFilter);
}
const FieldParameter::TypeFilterType& Application::GetTypeFilter(std::string const& key )
const FieldParameter::TypeFilterType& Application::GetTypeFilter(std::string const& key ) const
{
auto param = downcast_check<FieldParameter>(GetParameterByKey(key));
auto param = const_downcast_check<FieldParameter>(GetParameterByKey(key));
return param->GetTypeFilter();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment