diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h index 9f9554564acc317e2632cd2fa7a389d957342bd0..5aea541604912424fcec62ed5319ed33976d0162 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h @@ -47,10 +47,9 @@ public: void AddParameter(Parameter::Pointer p); - /** Method to add or substitute a parameter in a group. If there is already - * a parameter with the given key, the parameter is replaced. + /** Method to substitute a parameter in a group. * The function returns true on success, false on failure */ - bool SetParameter(Parameter::Pointer p, std::string &key); + bool ReplaceParameter(std::string &key, Parameter::Pointer p); /** Add a new choice value to an existing choice parameter */ void AddChoice(std::string paramKey, std::string paramName); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx index bf27e4908e13f0118b3e7c749950907805b45e43..2330510e5b3eb95465da96a76c2be01b932d4fc8 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx @@ -672,7 +672,7 @@ ParameterGroup::AddParameter(Parameter::Pointer p) } bool -ParameterGroup::SetParameter(Parameter::Pointer p, std::string &key) +ParameterGroup::ReplaceParameter(std::string &key, Parameter::Pointer p) { bool ret = true; ParameterKey pName(key); @@ -686,7 +686,7 @@ ParameterGroup::SetParameter(Parameter::Pointer p, std::string &key) parentGroup = dynamic_cast<ParameterGroup*>(parentParam); if (parentGroup) { - ret = parentGroup->SetParameter(p,lastkey); + ret = parentGroup->ReplaceParameter(lastkey, p); } else { @@ -708,15 +708,15 @@ ParameterGroup::SetParameter(Parameter::Pointer p, std::string &key) } if (oldParam.IsNull()) { - // parameter to replace not found : simply add the new one - AddParameter(p); + // parameter to replace not found : return false + ret = false; } else { // parameter already exists : replace it *vit = p; + p->SetKey(lastkey); } - p->SetKey(lastkey); } if (ret) {