Skip to content
Snippets Groups Projects
Commit 784fa971 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: add function ReplaceParameter()

parent 3bf53808
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,11 @@ public:
void AddParameter(Parameter::Pointer p);
/** Method to substitute a parameter in a group. The new parameter
* should match the key of the replaced parameter.
* The function returns true on success, false on failure */
bool ReplaceParameter(Parameter::Pointer p);
/** Add a new choice value to an existing choice parameter */
void AddChoice(std::string paramKey, std::string paramName);
......
......@@ -36,6 +36,7 @@
#include "otbWrapperInputProcessXMLParameter.h"
#include "otbWrapperParameterKey.h"
#include "otbWrapperRAMParameter.h"
#include "otbWrapperProxyParameter.h"
#include "otb_boost_string_header.h"
......@@ -666,6 +667,31 @@ ParameterGroup::AddParameter(Parameter::Pointer p)
m_ParameterList.push_back(p);
}
bool
ParameterGroup::ReplaceParameter(Parameter::Pointer p)
{
// find current parameter in the current group
Parameter::Pointer parentParam;
ParameterListType::iterator vit;
std::string inputKey(p->GetKey());
for (vit = m_ParameterList.begin(); vit != m_ParameterList.end(); ++vit)
{
if (inputKey.compare((*vit)->GetKey()) == 0)
{
parentParam = *vit;
break;
}
}
if (parentParam.IsNull())
{
return false;
}
// don't check type compatibility here, we may want to handle special cases
// at higher level
*vit = p;
return true;
}
Parameter::Pointer
ParameterGroup::GetParameterByIndex(unsigned int i)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment