From 761d27f49931b4a6a882fe48feab6e2153713ba1 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Wed, 16 Nov 2016 15:36:49 +0100 Subject: [PATCH] ENH: change to ReplaceParameter, doing only replacement --- .../include/otbWrapperParameterGroup.h | 5 ++--- .../ApplicationEngine/src/otbWrapperParameterGroup.cxx | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h index 9f9554564a..5aea541604 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 bf27e4908e..2330510e5b 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) { -- GitLab