diff --git a/Code/Core/otbWrapperApplication.cxx b/Code/Core/otbWrapperApplication.cxx index 26b7b1c39210ba26ced92e410ab1a3e28513a8f2..bdd9348ff1e3d684b9b96b59b75a27c7ccc8bf45 100644 --- a/Code/Core/otbWrapperApplication.cxx +++ b/Code/Core/otbWrapperApplication.cxx @@ -48,6 +48,13 @@ Application::~Application() { } + +std::list<std::string> +Application::GetParametersKeys() +{ + return GetParameterList()->GetParametersKeys(); +} + ParameterGroup* Application::GetParameterList() { if (!m_ParameterList) diff --git a/Code/Core/otbWrapperApplication.h b/Code/Core/otbWrapperApplication.h index 69173239912e6e5a2b26abd4dd3be66ea846f847..6e469079dfd7865abb8aecf26c15d25df48c2aa1 100644 --- a/Code/Core/otbWrapperApplication.h +++ b/Code/Core/otbWrapperApplication.h @@ -225,13 +225,14 @@ public: /* GetParameterInt * * Can be called for types : - * \li ParameterType_Int - * \li ParameterType_Float - * \li ParameterType_Radius - * \li ParameterType_Choice + * \li ParameterType_InputVectorData */ VectorDataType* GetParameterVectorData(std::string parameter); + /* Get the list of all parameters + */ + std::list<std::string> GetParametersKeys(); + protected: /** Constructor */ Application(); diff --git a/Code/Core/otbWrapperChoiceParameter.cxx b/Code/Core/otbWrapperChoiceParameter.cxx index ad9c269ede34e49f0b3fcd25e97fbf6141205186..46b66977b13ccd4db192321800e06cf15fc6f357 100644 --- a/Code/Core/otbWrapperChoiceParameter.cxx +++ b/Code/Core/otbWrapperChoiceParameter.cxx @@ -42,12 +42,6 @@ ChoiceParameter::AddChoice( std::string choicekey, std::string choiceName ) m_ChoiceList.push_back(choice); } -void -ChoiceParameter::AddParameterToChoice( std::string choicekey, std::string choiceName, Parameter* param ) -{ - -} - std::string ChoiceParameter::GetChoiceKey( int i ) { @@ -149,6 +143,33 @@ ChoiceParameter::GetAnyValue() } +/** Return any value */ +std::list<std::string> +ChoiceParameter::GetParametersKeys() +{ + std::cout << "ChoiceParameter::GetParametersKeys()" << std::endl; + std::list<std::string> parameters; + + ChoiceList::iterator cit = m_ChoiceList.begin(); + + for (cit = m_ChoiceList.begin(); cit != m_ChoiceList.end(); ++cit) + { + std::cout << "Choice " << cit->m_Key << std::endl; + if (cit->m_AssociatedParameter) + { + std::list<std::string> subparams = cit->m_AssociatedParameter->GetParametersKeys(); + for (std::list<std::string>::const_iterator it = subparams.begin(); + it != subparams.end(); ++it) + { + std::cout << "ParameterGroup push_back " << cit->m_Key + "." + *it << std::endl; + + parameters.push_back( cit->m_Key + "." + *it ); + } + } + } + return parameters; +} + } } diff --git a/Code/Core/otbWrapperChoiceParameter.h b/Code/Core/otbWrapperChoiceParameter.h index 09daa299109d9a57a0cdcc69b88c42cb222f04c4..53e3b69b7fe617474f7a4bbbf5c2a58a633a6e2c 100644 --- a/Code/Core/otbWrapperChoiceParameter.h +++ b/Code/Core/otbWrapperChoiceParameter.h @@ -51,9 +51,6 @@ public: /** Add a value to the choice */ void AddChoice( std::string choicekey, std::string choiceName ); - /** Add parameter to choice */ - void AddParameterToChoice( std::string choicekey, std::string choiceName , Parameter* param ); - /** Get the key of a specific choice value */ std::string GetChoiceKey( int i ); @@ -66,6 +63,8 @@ public: /** Get the ParameterGroup associated to a choice value */ ParameterGroup::Pointer GetChoiceParameterGroupByKey( std::string choiceKey ); + std::list<std::string> GetParametersKeys(); + /** Get the number of available choice */ unsigned int GetNbChoices( void ); diff --git a/Code/Core/otbWrapperParameterGroup.cxx b/Code/Core/otbWrapperParameterGroup.cxx index 856cb3fb592d5f54b26362d97e751109b4f3d4d0..fc92a5e3272291c8dfa1ef9b77a356d30d75819d 100644 --- a/Code/Core/otbWrapperParameterGroup.cxx +++ b/Code/Core/otbWrapperParameterGroup.cxx @@ -43,6 +43,46 @@ ParameterGroup::~ParameterGroup() { } +std::list<std::string> +ParameterGroup::GetParametersKeys() +{ + std::list<std::string> parameters; + + ParameterListType::iterator pit; + for (pit = m_ParameterList.begin(); pit != m_ParameterList.end(); ++pit) + { + Parameter* param = *pit; + if (dynamic_cast<ParameterGroup*>(param)) + { + ParameterGroup* paramAsGroup = dynamic_cast<ParameterGroup*>(param); + std::list<std::string> subparams = paramAsGroup->GetParametersKeys(); + for (std::list<std::string>::const_iterator it = subparams.begin(); + it != subparams.end(); ++it) + { + parameters.push_back( std::string(paramAsGroup->GetKey()) + "." + *it ); + } + } + else if (dynamic_cast<ChoiceParameter*>(param)) + { + ChoiceParameter* paramAsChoice = dynamic_cast<ChoiceParameter*>(param); + parameters.push_back( param->GetKey() ); + + std::list<std::string> subparams = paramAsChoice->GetParametersKeys(); + for (std::list<std::string>::const_iterator it = subparams.begin(); + it != subparams.end(); ++it) + { + parameters.push_back( std::string(paramAsChoice->GetKey()) + "." + *it ); + } + } + else + { + parameters.push_back( param->GetKey() ); + } + } + return parameters; +} + + /** Add a new choice value to the parameter group */ void ParameterGroup::AddChoice(std::string paramKey, std::string paramName) diff --git a/Code/Core/otbWrapperParameterGroup.h b/Code/Core/otbWrapperParameterGroup.h index 73dbd976acd82c9246eb844b5160ad40403b427a..9a58ac149b655ff747dcc58abcaff6f52854d2e7 100644 --- a/Code/Core/otbWrapperParameterGroup.h +++ b/Code/Core/otbWrapperParameterGroup.h @@ -59,6 +59,8 @@ public: unsigned int GetNumberOfParameters(); + std::list<std::string> GetParametersKeys(); + protected: ParameterGroup(); virtual ~ParameterGroup();