diff --git a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx index 6d1c7798048eab69f371825637319a371b185b9e..2804718d78036f2a3c21a8c1661a948b2538b8a4 100644 --- a/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx +++ b/Modules/Applications/AppClassification/app/otbDSFuzzyModelEstimation.cxx @@ -160,7 +160,6 @@ private: AddParameter(ParameterType_StringList, "desclist","Descriptor list"); SetParameterDescription("desclist","List of the descriptors to be used in the model (must be specified to perform an automatic initialization)"); MandatoryOff("desclist"); - SetParameterString("desclist",""); AddParameter(ParameterType_Int,"maxnbit","Maximum number of iterations"); MandatoryOff("maxnbit"); diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index 15d8bd65ed0a52f5dc3f506d37bcd74acbd04a10..c16e0cca8ef023c56226ffcd8f95ab0fffd13c5c 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -126,7 +126,7 @@ private: SetParameterDescription("strategy.smote.neighbors", "Number of nearest neighbors to be used in the " "SMOTE algorithm"); - SetDefaultParameterFloat("strategy.smote.neighbors", 5); + SetDefaultParameterInt("strategy.smote.neighbors", 5); AddRANDParameter("seed"); MandatoryOff("seed"); diff --git a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx index 792403cd4b8250638b9bfe92149666b8902b811b..77b43d10a6d1ae982f8e15f5d55bc2428afdddd7 100644 --- a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx +++ b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx @@ -141,7 +141,6 @@ private: SetDefaultParameterFloat("khir", 0.); SetDefaultParameterInt("emissionh", 0); SetDefaultParameterInt("emissionv", 0); - SetDefaultParameterFloat("mode", 0); // Doc example parameter settings SetDocExampleParameterValue("in", "sar.tif"); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h index 86718972f60aa5ca426ceb903928b5be4fe4ce1a..5a02df703407f5d45d6c244cc00978b1fb5faf91 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperBoolParameter.h @@ -58,13 +58,19 @@ public: } bool GetValue() const; - std::string GetValueAsString() const; void SetValue(bool state); - void SetValue(const std::string & str); + ParameterType GetType() const override; + + int ToInt() const override; + std::string ToString() const override; + + void FromString(const std::string& value) override; + void FromInt(int value) override;; + protected: /** Constructor */ BoolParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h index 79494903d7e01343a6bd2488f6f4a50491705d68..89b70d2de0441120615b2fc4209e70d08c16af25 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h @@ -57,7 +57,7 @@ public: void AddChoice( std::string choicekey, std::string choiceName ); /** Get the key of a specific choice value */ - std::string GetChoiceKey( int i ); + std::string GetChoiceKey(int i) const; /** Get the list of the different choice keys */ std::vector<std::string> GetChoiceKeys(); @@ -87,19 +87,18 @@ public: virtual void SetValue(std::string choiceKey); /** Return any value */ - virtual unsigned int GetValue(); + virtual unsigned int GetValue() const; - bool HasValue() const override - { - return !m_ChoiceList.empty(); - } + bool HasValue() const override; + void ClearValue() override; - void ClearValue() override - { - // Same as constructor init value - // Note that this may be invalid if HasValue() == false - m_CurrentChoice = 0; - } + ParameterType GetType() const override; + + int ToInt() const override; + void FromInt(int value) override; + + std::string ToString() const override; + void FromString(const std::string& value) override; protected: /** Constructor */ diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h index 6056d3c31f5faf38e282adb11dd218c8fca228d5..397877772549d9dbdf1d6ef2fde9b02fee00115b 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h @@ -106,9 +106,11 @@ the macro otbGetParameterImageMacro of otbWrapperApplication.h */ TOutputImage* CastImage(); bool HasValue() const override; - void ClearValue() override; + ParameterType GetType() const override; + std::string ToString() const override; + void FromString(const std::string& value) override; protected: /** Constructor */ diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h index e58208d583540fd1b94c586f12d2747350f0a82f..60eedca007490112505c39ecfa98c8cbb6c78fbe 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h @@ -102,6 +102,10 @@ public: void InitializeWriters(); + ParameterType GetType() const override; + std::string ToString() const override; + void FromString(const std::string& value) override; + protected: /** Constructor */ ComplexOutputImageParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h index 554f4ff34d00b77f21b775ad5694e95fe6358215..1202f334a0b1c42119e42cbf67b56c24357f3973 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperDirectoryParameter.h @@ -59,7 +59,7 @@ public: // Set/Get Value otbSetObjectMemberMacro(StringParam, Value , std::string); - otbGetObjectMemberMacro(StringParam, Value , std::string); + otbGetObjectMemberConstMacro(StringParam, Value, std::string); // Clear Value void ClearValue() override @@ -77,6 +77,21 @@ public: // GetActive method otbGetObjectMemberConstMacro(StringParam, Active, bool); + virtual ParameterType GetType() const override + { + return ParameterType_Directory; + } + + std::string ToString() const override + { + return GetValue(); + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + protected: /** Constructor */ DirectoryParameter() diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h index f7d337d772096c1d389ea3128b289247afa1e6ff..6307781651250ebce91947f81f7d37dc44d5aeda 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameListParameter.h @@ -71,9 +71,11 @@ public: /** */ const std::string & GetFilenameFilter() const override; + ParameterType GetType() const override; -// -// Protected methods. + + // + // Protected methods. protected: /** Constructor */ InputFilenameListParameter(); @@ -81,15 +83,6 @@ protected: /** Destructor */ ~InputFilenameListParameter() override; - /** */ - const std::string & ToString( const ParameterType::Pointer & ) const override; - - /** */ - using Superclass::FromString; - const ParameterType::Pointer & - FromString( const ParameterType::Pointer &, - const std::string & ) const override; - // // Private methods. private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h index c1e3d682a31d959e02300a963064129c754217a9..4262069bdc2897ea53fbfc43f8aa77da856b6ddd 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputFilenameParameter.h @@ -57,7 +57,7 @@ public: } // Get Value - otbGetObjectMemberMacro(StringParam, Value , std::string); + otbGetObjectMemberConstMacro(StringParam, Value, std::string); // Set Value virtual void SetValue(const std::string value) @@ -74,6 +74,21 @@ public: m_StringParam->ClearValue(); } + virtual ParameterType GetType() const override + { + return ParameterType_InputFilename; + } + + std::string ToString() const override + { + return GetValue(); + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + protected: /** Constructor */ InputFilenameParameter() @@ -90,8 +105,7 @@ protected: private: InputFilenameParameter(const InputFilenameParameter &) = delete; - void operator =(const InputFilenameParameter&); //purposely not - //implemented + void operator=(const InputFilenameParameter&) = delete; StringParameter::Pointer m_StringParam; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h index 1868042e104dd8da251ba4ae3466da7c55c8cdde..9a57e38dfbbe727abc241728c495deb976b6161c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h @@ -84,6 +84,11 @@ public: using StringListInterface::GetFilenameFilter; const std::string & GetFilenameFilter() const override; + virtual ParameterType GetType() const override + { + return ParameterType_InputImageList; + } + protected: /** Constructor */ InputImageListParameter(); @@ -91,19 +96,6 @@ protected: /** Destructor */ ~InputImageListParameter() override; -// -// Protected methods. -protected: - - /** */ - const std::string & ToString( const ParameterType::Pointer & ) const override; - - /** */ - using Superclass::FromString; - const ParameterType::Pointer & - FromString( const ParameterType::Pointer &, - const std::string & ) const override; - // // Private methods. private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h index 75cd4ae3dbc00336dc6ae991752ef92b738eb481..aed1ab8b4ecf4ead661c860dbfc026f05e38fec0 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h @@ -107,9 +107,12 @@ public: TOutputImage* CastImage(); bool HasValue() const override; - void ClearValue() override; + ParameterType GetType() const override; + std::string ToString() const override; + void FromString(const std::string& value) override; + protected: /** Constructor */ InputImageParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h index 7731ed6dbc2772a542bb4062090e63daf13a7ba5..d4db58283c9294ef3b7dc1de2d841134f539823a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputProcessXMLParameter.h @@ -61,6 +61,21 @@ public: return true; } + virtual ParameterType GetType() const override + { + return ParameterType_InputProcessXML; + } + + std::string ToString() const override + { + return GetFileName(); + } + + void FromString(const std::string& value) override + { + SetFileName(value); + } + // Get Value //TODO otbGetObjectMemberMacro(StringParam, Value , std::string); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h index f7ade317d9f859a1b4e2a8e0435221eb9e69c78f..21988905d7be6bbfad22b8c10f55be0c86cb330a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataListParameter.h @@ -81,6 +81,10 @@ public: using StringListInterface::GetFilenameFilter; const std::string & GetFilenameFilter() const override; + virtual ParameterType GetType() const override + { + return ParameterType_InputVectorDataList; + } protected: /** Constructor */ @@ -89,15 +93,6 @@ protected: /** Destructor */ ~InputVectorDataListParameter() override; - /** */ - const std::string & ToString( const ParameterType::Pointer & ) const override; - - /** */ - using Superclass::FromString; - const ParameterType::Pointer & - FromString( const ParameterType::Pointer &, - const std::string & ) const override; - private: InputVectorDataListParameter( const Parameter & ) = delete; void operator = ( const Parameter & ) = delete; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h index aa9c537416e5ee1b5e821409a014c2b733e82bdb..a55b86c14e421f581f75558391ce357ed4c09cc3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperInputVectorDataParameter.h @@ -67,6 +67,21 @@ public: void ClearValue() override; + virtual ParameterType GetType() const override + { + return ParameterType_InputVectorData; + } + + std::string ToString() const override + { + return GetFileName(); + } + + void FromString(const std::string& value) override + { + SetFromFileName(value); + } + protected: /** Constructor */ InputVectorDataParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h index 52e985e958cde2786846d62c88770629504624e2..d7a6c06afc090c4507ed2a84d9986c0c975e5f14 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperListViewParameter.h @@ -62,7 +62,7 @@ public: void AddChoice( std::string choicekey, std::string choiceName ); /** Get the key of a specific choice value */ - std::string GetChoiceKey( int i ); + std::string GetChoiceKey(int i) const; /** Get the list of the different choice keys */ std::vector<std::string> GetChoiceKeys(); @@ -83,7 +83,7 @@ public: virtual void SetValue(std::string choiceKey); /** Return any value */ - virtual unsigned int GetValue(); + virtual unsigned int GetValue() const; bool HasValue() const override { @@ -105,9 +105,9 @@ public: void SetSelectedNames(std::vector<std::string> selectedNames); - std::vector<std::string> GetSelectedNames() - { - return m_SelectedNames; + std::vector<std::string> GetSelectedNames() const + { + return m_SelectedNames; } @@ -151,6 +151,38 @@ public: } } + virtual ParameterType GetType() const override + { + return ParameterType_ListView; + } + + std::string ToString() const override + { + std::string choiceKey = GetChoiceKey(GetValue()); + size_t lastPointPos = choiceKey.find_last_of('.'); + + if (lastPointPos != std::string::npos) + { + return choiceKey.substr(lastPointPos); + } + return choiceKey; + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + + std::vector<std::string> ToStringList() const override + { + return GetSelectedNames(); + } + + void FromStringList(const std::vector<std::string>& values) override + { + SetSelectedNames(values); + } + protected: /** Constructor */ ListViewParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h index 26f9dbf6d28a4724f1f9daf3c38618d276d178fa..f9f952789c19b7249613f4c1cd299625ea398063 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperNumericalParameter.h @@ -23,7 +23,7 @@ #include "otbWrapperParameter.h" #include "itkNumericTraits.h" -#include <boost/any.hpp> +#include <boost/optional.hpp> namespace otb { @@ -44,12 +44,6 @@ public: typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; - /** Defining ::New() static method */ - itkNewMacro(Self); - - /** RTTI support */ - itkTypeMacro(NumericalParameter, Parameter); - /** Typedef of the scalar type */ typedef T ScalarType; @@ -78,24 +72,23 @@ public: SetValue(value); } - /** Get the value */ ScalarType GetValue() const { if (!HasValue()) - { + { itkGenericExceptionMacro(<< "Parameter " << this->GetKey() << " has no value yet."); - } - return boost::any_cast<ScalarType>(m_Value); + } + return static_cast<ScalarType>(m_Value.value()); } bool HasValue() const override { - return !m_Value.empty(); + return m_Value != boost::none; } void ClearValue() override { - m_Value = boost::any(); + m_Value.reset(); } /** Set the default value */ @@ -116,6 +109,42 @@ public: /** Get the maximum value */ itkGetMacro(MaximumValue, ScalarType); + // TODO move to hxx + int ToInt() const override + { + if (!HasValue()) + { + itkExceptionMacro("Cannot convert parameter " << GetKey() << " to int (no value)."); + } + return static_cast<int>(m_Value.value()); + } + + float ToFloat() const override + { + if (!HasValue()) + { + itkExceptionMacro("Cannot convert parameter " << GetKey() << " to float (no value)."); + } + return static_cast<float>(m_Value.value()); + } + + void FromInt(int value) override + { + SetValue(value); + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + + std::string ToString() const override + { + std::ostringstream oss; + oss << this->GetValue(); + return oss.str(); + } + protected: /** Constructor */ NumericalParameter() @@ -129,7 +158,7 @@ protected: {} /** Value */ - boost::any m_Value; + boost::optional<T> m_Value; /** Default value (when appliable) */ ScalarType m_DefaultValue; @@ -146,11 +175,105 @@ private: }; // End class Numerical Parameter -// Helper typedef for float -typedef NumericalParameter<float> FloatParameter; +class OTBApplicationEngine_EXPORT FloatParameter : public NumericalParameter<float> +{ +public: + /** Standard class typedef */ + typedef FloatParameter Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + itkNewMacro(Self); + itkTypeMacro(NumericalParameter, Parameter); -// Helper typedef for int -typedef NumericalParameter<int> IntParameter; + virtual ParameterType GetType() const override + { + return ParameterType_Float; + } + + void FromFloat(float value) override + { + SetValue(value); + } +}; + +class OTBApplicationEngine_EXPORT IntParameter : public NumericalParameter<int> +{ +public: + /** Standard class typedef */ + typedef IntParameter Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + itkNewMacro(Self); + itkTypeMacro(NumericalParameter, Parameter); + + virtual ParameterType GetType() const override + { + return ParameterType_Int; + } +}; + +class OTBApplicationEngine_EXPORT RAMParameter : public NumericalParameter<unsigned int> +{ +public: + /** Standard class typedef */ + typedef RAMParameter Self; + typedef Parameter Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Defining ::New() static method */ + itkNewMacro(Self); + + /** RTTI support */ + itkTypeMacro(RAMParameter, Parameter); + + virtual ParameterType GetType() const override + { + return ParameterType_RAM; + } + + /** Constructor */ + RAMParameter() : NumericalParameter<unsigned int>() + { + this->SetName("RAM"); + this->SetDescription("Set the maximum of available memory for the pipeline execution in mega bytes (optional, 256 by default)."); + this->SetKey("ram"); + + // 0 RAM is not allowed, make the minimum to 1 by default + this->SetMinimumValue(1); + } +}; + +class OTBApplicationEngine_EXPORT RadiusParameter : public IntParameter +{ +public: + typedef RadiusParameter Self; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + itkNewMacro(Self); + itkTypeMacro(RadiusParameter, Parameter); + + bool HasValue() const override + { + return true; + } + + virtual ParameterType GetType() const override + { + return ParameterType_Radius; + } + +protected: + RadiusParameter() + { + this->SetName("Radius"); + this->SetKey("r"); + this->SetDescription("Radius in pixels"); + } +}; } // End namespace Wrapper } // End namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h index e1c439e227700fcc79452958b9e5b59f830fb3ea..1009c753e899ca8073ab6be023950519def82fea 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputFilenameParameter.h @@ -57,7 +57,7 @@ public: } // Get Value - otbGetObjectMemberMacro(StringParam, Value , std::string); + otbGetObjectMemberConstMacro(StringParam, Value, std::string); // Set Value virtual void SetValue(const std::string value) @@ -74,6 +74,21 @@ public: m_StringParam->ClearValue(); } + virtual ParameterType GetType() const override + { + return ParameterType_OutputFilename; + } + + std::string ToString() const override + { + return GetValue(); + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + protected: /** Constructor */ OutputFilenameParameter() diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h index b1a7b405c5b8c2a56ca9eee0024d3995500e4126..c62dc9fb69a4baea32c0a2581b499aa058317173 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h @@ -105,6 +105,21 @@ public: std::string CheckFileName(bool fixMissingExtension = false); + virtual ParameterType GetType() const override + { + return ParameterType_OutputImage; + } + + std::string ToString() const override + { + return GetFileName(); + } + + void FromString(const std::string& value) override + { + SetFileName(value); + } + protected: /** Constructor */ OutputImageParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h index 42f504b88b61de07e902c35d3e6ebd5a5063ac42..5b19add53105b36ef412e459231f76179d7c4396 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h @@ -80,6 +80,21 @@ public: m_FileName = ""; } + virtual ParameterType GetType() const override + { + return ParameterType_OutputProcessXML; + } + + std::string ToString() const override + { + return GetFileName(); + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + TiXmlElement* AddChildNodeTo(TiXmlElement* parent, std::string name, std::string value=""); std::string pixelTypeToString(ImagePixelType pixType); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h index 5d91479cead9760dffa7534100c64b94b0a39e7d..deb76b22e35e703801333890bbba9e5c9c71f4fd 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputVectorDataParameter.h @@ -77,6 +77,21 @@ public: itk::ProcessObject* GetWriter(); void InitializeWriters(); + virtual ParameterType GetType() const override + { + return ParameterType_OutputVectorData; + } + + std::string ToString() const override + { + return GetFileName(); + } + + void FromString(const std::string& value) override + { + SetFileName(value); + } + protected: /** Constructor */ OutputVectorDataParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index c1fc0fc6a019b8a6986e41639a06e65a97a91511..5fcd6cc258782a00d55a7552f70cf13fe278ae05 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -132,6 +132,38 @@ public: */ virtual std::vector<Parameter::Pointer > GetChildrenList(); + virtual ParameterType GetType() const = 0; + + virtual int ToInt() const; + virtual float ToFloat() const; + virtual std::string ToString() const; + virtual std::vector<std::string> ToStringList() const; + + /* + virtual std::vector<std::string> ToStringList() const; + virtual ImageBaseType* OutputImage() const; + virtual ImageBaseType* ToComplexOutputImage() const; + virtual FloatVectorImageType* ToImage() const; + virtual FloatVectorImageListType* ToImageList() const; + virtual ComplexFloatVectorImageType* ToComplexImage() const; + virtual VectorDataType* ToVectorData() const; + virtual VectorDataListType* ToVectorDataList() const; + */ + + virtual void FromInt(int); + virtual void FromFloat(float); + virtual void FromString(const std::string&); + virtual void FromStringList(const std::vector<std::string>&); + + /* + virtual void FromStringList(const std::vector<std::string>&); + virtual void FromOutputImage(const FloatVectorImageType*); + virtual void FromComplexOutputImage(const ComplexFloatVectorImageType*); + virtual void FromOutputVectorData(const VectorDataType*); + virtual void FromInputImage(const ImageBaseType*); + virtual void FromComplexInputImage(const ImageBaseType*); + */ + protected: /** Constructor */ Parameter(); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h index 0c9f417d73195bd600d9009d49c5f7b2b2cddd54..ef0d703249f489b14d16d76d21abcfc4a6aaa616 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterGroup.h @@ -89,7 +89,7 @@ public: std::string GetParameterTypeAsString(ParameterType paramType); /* Get the parameter type from its string version of ParameterType enum */ - ParameterType GetParameterTypeFromString(std::string paramType); + ParameterType GetParameterTypeFromString(const std::string& paramType); unsigned int GetNumberOfParameters(); @@ -105,6 +105,11 @@ public: * a non-proxy parameter. It will detect cycles and report an error */ static Parameter* ResolveParameter(Parameter *param); + virtual ParameterType GetType() const override + { + return ParameterType_Group; + } + protected: ParameterGroup(); ~ParameterGroup() override; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h index e0c28aa4d248bea07becb4e07a702b92faa693ef..7b8ea6beae5b846fc7545ffdca82ebfec9ab0db2 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.h @@ -53,7 +53,6 @@ public: typedef itk::SmartPointer< const Self > ConstPointer; /** Custom types */ - typedef T ParameterType; typedef std::vector< typename T::Pointer > ParameterVector; // @@ -99,8 +98,8 @@ public: /** Get the stored image filename list */ StringVector GetFileNameList() const override; - /** Get one specific stored image filename. */ - const std::string & GetNthFileName( std::size_t ) const override; + /** Get one specific stored image filename. */ + std::string GetNthFileName(std::size_t) const override; /** */ const std::string & GetToolTip( std::size_t ) const override; @@ -118,8 +117,32 @@ public: /** */ void Swap( std::size_t, std::size_t ) override; -// -// Protected methods. + std::vector<std::string> ToStringList() const override + { + return GetFileNameList(); + } + + void FromStringList(const std::vector<std::string>& value) + { + SetStrings(value); + } + + std::string ToString() const override + { + std::ostringstream oss; + oss << std::setprecision(10); + auto strList = GetFileNameList(); + for (size_t i = 0; i < strList.size(); i++) + { + if (i != 0) + { + oss << " "; + } + oss << strList[i]; + } + return oss.str(); + } + protected: /** Constructor */ ParameterList(); @@ -127,13 +150,6 @@ protected: /** Destructor */ ~ParameterList() override; -// -// Private methods. -private: - // ParameterList( const Parameter & ) = delete; - // void operator = ( const Parameter & ) = delete; - -// // Protected methods. protected: /** Utility method to factorize some code */ @@ -170,22 +186,6 @@ protected: Set, const std::string & description = std::string() ); - /** ParameterType::ValueType -> std::string protocol */ - virtual - const std::string & - ToString( const typename ParameterType::Pointer & ) const = 0; - - /** std::string -> ParameterType::ValueType protocol */ - virtual - const typename ParameterType::Pointer & - FromString( const typename ParameterType::Pointer &, - const std::string & ) const = 0; - - /** Utility method to use std::string -> conversion in lambdas. */ - virtual - typename ParameterType::Pointer - FromString( const std::string & ) const; - // // Protected attributes. protected: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx index 5c94a347b48643ebfdf5fbf3e2f2e8fa2afb4e15..0440806b248e5c5c030949e050ae54a4577de853 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameterList.hxx @@ -138,7 +138,7 @@ ParameterList< T > typename T::Pointer p( T::New() ); - FromString( p, filename ); + p->FromString(filename); m_Parameters.push_back( p ); @@ -157,7 +157,7 @@ ParameterList< T > { typename T::Pointer p( T::New() ); - FromString( p, filename ); + p->FromString(filename); m_Parameters.insert( m_Parameters.begin() + index, p ); @@ -178,8 +178,7 @@ ParameterList< T > assert( i<m_Parameters.size() ); assert( !m_Parameters[ i ].IsNull() ); - // Should throw exception when failed. - FromString( m_Parameters[ i ], filename ); + m_Parameters[i]->FromString(filename); SetActive( true ); @@ -203,7 +202,9 @@ ParameterList< T > std::back_inserter( m_Parameters ), [ this ]( auto s ) -> auto { - return this->FromString( s ); + typename T::Pointer parameter(T::New()); + parameter->FromString(s); + return parameter; } ); @@ -225,7 +226,7 @@ ParameterList< T > std::back_inserter( strings ), [ this ]( auto p ) -> auto { - return this->ToString( p ); + return p->ToString(); } ); @@ -247,13 +248,13 @@ ParameterList< T > /*****************************************************************************/ template< typename T > -const std::string & +std::string ParameterList< T > ::GetNthFileName( std::size_t i ) const { assert( i<m_Parameters.size() ); - return ToString( m_Parameters[ i ] ); + return m_Parameters[i]->ToString(); } /*****************************************************************************/ @@ -467,17 +468,6 @@ ParameterList< T > return parameter; } -/*****************************************************************************/ -template< typename T > -typename T::Pointer -ParameterList< T > -::FromString( const std::string & s ) const -{ - typename T::Pointer parameter( T::New() ); - - return FromString( parameter, s ); -} - } // End namespace Wrapper diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h index 512508db8ede11b15c664b4a4268a4061169f259..bb26691d12e2ddd0954e6d165a7b99154271cbbd 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperProxyParameter.h @@ -75,9 +75,18 @@ public: return m_Target.first.IsNotNull(); } -protected: - ProxyParameter() {} - ~ProxyParameter() override {} + virtual ParameterType GetType() const override + { + return m_Target.first->GetType(); + } + + + protected: + ProxyParameter() + { + } + ~ProxyParameter() override + {} private: ProxyParameter(const Self &) = delete; diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h deleted file mode 100644 index 1b4554186aac27704d915a172aecedbb69021ecc..0000000000000000000000000000000000000000 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRAMParameter.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef otbWrapperRAMParameter_h -#define otbWrapperRAMParameter_h - -#include "otbWrapperNumericalParameter.h" - -namespace otb -{ -namespace Wrapper -{ - -/** \class RAMParameter - * \brief This class represent a RAM parameter for the wrapper framework - * - * \ingroup OTBApplicationEngine - */ -class OTBApplicationEngine_EXPORT RAMParameter : public Parameter -{ -public: - /** Standard class typedef */ - typedef RAMParameter Self; - typedef Parameter Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Defining ::New() static method */ - itkNewMacro(Self); - - /** RTTI support */ - itkTypeMacro(RAMParameter, Parameter); - - /** typedef */ - typedef NumericalParameter<unsigned int> UnsignedIntParameter; - typedef UnsignedIntParameter::ScalarType ScalarType; - - bool HasValue() const override - { - return m_UnsignedIntParam->HasValue(); - } - - // Set/Get Value - otbSetObjectMemberMacro(UnsignedIntParam, Value , ScalarType); - otbSetObjectMemberMacro(UnsignedIntParam, Value , std::string); - otbGetObjectMemberMacro(UnsignedIntParam, Value , ScalarType); - - // Set/Get extremums - otbSetObjectMemberMacro(UnsignedIntParam, DefaultValue, ScalarType); - otbGetObjectMemberMacro(UnsignedIntParam, DefaultValue, ScalarType); - otbSetObjectMemberMacro(UnsignedIntParam, MinimumValue, ScalarType); - otbGetObjectMemberMacro(UnsignedIntParam, MinimumValue, ScalarType); - otbSetObjectMemberMacro(UnsignedIntParam, MaximumValue, ScalarType); - otbGetObjectMemberMacro(UnsignedIntParam, MaximumValue, ScalarType); - - // Clear Value - void ClearValue() override - { - m_UnsignedIntParam->ClearValue(); - } - - // Reset - void Reset() override - { - m_UnsignedIntParam->Reset(); - } - - // Reimplement the SetActive method - void SetActive( bool value ) override - { - Superclass::SetActive( value ); - m_UnsignedIntParam->SetActive( value ); - } - - otbGetObjectMemberConstMacro(UnsignedIntParam, Active, bool); - -protected: - /** Constructor */ - RAMParameter() - { - this->SetName("RAM"); - this->SetDescription("Set the maximum of available memory for the pipeline execution in mega bytes (optional, 256 by default)."); - this->SetKey("ram"); - - // Initialize the unsigned int NumericalParam - m_UnsignedIntParam = UnsignedIntParameter::New(); - - // 0 RAM is not allowed, make the minimum to 1 by default - this->SetMinimumValue(1); - } - - /** Destructor */ - ~RAMParameter() override - {} - -private: - RAMParameter(const RAMParameter &) = delete; - void operator =(const RAMParameter&) = delete; - - UnsignedIntParameter::Pointer m_UnsignedIntParam; -}; - -} // End namespace Wrapper -} // End namespace otb - -#endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h deleted file mode 100644 index e9eaf44958dce5c75383663c1ccade59c2235ee5..0000000000000000000000000000000000000000 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperRadiusParameter.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef otbWrapperRadiusParameter_h -#define otbWrapperRadiusParameter_h - -#include "otbWrapperNumericalParameter.h" - -namespace otb -{ -namespace Wrapper -{ - -/** \class StringParameter - * \brief This class represent a radius parameter for the wrapper framework - * - * \ingroup OTBApplicationEngine - */ -class OTBApplicationEngine_EXPORT RadiusParameter - : public IntParameter -{ -public: - /** Standard class typedef */ - typedef RadiusParameter Self; - typedef Parameter Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Defining ::New() static method */ - itkNewMacro(Self); - - /** RTTI support */ - itkTypeMacro(RadiusParameter, Parameter); - - bool HasValue() const override - { - return true; - } - -protected: - /** Constructor */ - RadiusParameter() - { - this->SetName("Radius"); - this->SetKey("r"); - this->SetDescription("Radius in pixels"); - } - - /** Destructor */ - ~RadiusParameter() override - {} - -private: - RadiusParameter(const RadiusParameter &) = delete; - void operator =(const RadiusParameter&) = delete; - -}; - -} // End namespace Wrapper -} // End namespace otb - -#endif diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h index 63d7fe5eb44e5a8b7705e91237225bbdfe087a51..e26ef8d55d63c946f25f1f0de57c9e51b458d96a 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListInterface.h @@ -75,7 +75,7 @@ public: virtual StringVector GetFileNameList() const = 0; /** Get one specific stored filename. */ - virtual const std::string & GetNthFileName( std::size_t i ) const = 0; + virtual std::string GetNthFileName(std::size_t i) const = 0; /** Erase one element of the list. */ virtual void Erase( std::size_t id ); diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h index 2b28db83c09bf0000ee14d5d84c2207e45d0ea83..bc11f96dd5f6215b95b87349623b3d6e2662026c 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringListParameter.h @@ -68,7 +68,7 @@ public: StringListInterface::StringVector GetValue() const; /** Get the value */ - const std::string & GetNthElement( std::size_t ) const; + std::string GetNthElement(std::size_t) const; /** Get the value */ void SetNthElement( std::size_t, const std::string & ); @@ -80,8 +80,13 @@ public: /** */ bool IsFilename() const override; -// -// Protected methods. + virtual ParameterType GetType() const override + { + return ParameterType_StringList; + } + + // + // Protected methods. protected: /** Constructor */ StringListParameter(); @@ -89,15 +94,6 @@ protected: /** Destructor */ ~StringListParameter() override; - /** */ - const std::string & ToString( const ParameterType::Pointer & ) const override; - - /** */ - using Superclass::FromString; - const ParameterType::Pointer & - FromString( const ParameterType::Pointer &, - const std::string & ) const override; - // // Private methods. private: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h index 216030b588d3167f28ebc88155858bdaab48631d..98d27c353394ba760f6d6a25efef16dbd5a78369 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperStringParameter.h @@ -73,6 +73,21 @@ public: m_Value = ""; } + virtual ParameterType GetType() const override + { + return ParameterType_String; + } + + std::string ToString() const override + { + return m_Value; + } + + void FromString(const std::string& value) override + { + SetValue(value); + } + protected: /** Constructor */ StringParameter() diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h index 4357b61f104e2f6374f498e3458c0ecfa93ddfcc..17d792915da52f500dda1c3737097f824d250e34 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h @@ -61,6 +61,39 @@ typedef enum ParameterType_Bool } ParameterType; +namespace +{ +const std::vector<std::pair<ParameterType, std::string>> parameterTypesStrings = { + {ParameterType_Int, "Int"}, + {ParameterType_Float, "Float"}, + {ParameterType_String, "String"}, + {ParameterType_StringList, "StringList"}, + {ParameterType_InputFilename, "InputFilename"}, + {ParameterType_InputFilenameList, "InputFilenameList"}, + {ParameterType_OutputFilename, "OutputFilename"}, + {ParameterType_Directory, "Directory"}, + {ParameterType_Choice, "Choice"}, + {ParameterType_InputImage, "InputImage"}, + {ParameterType_InputImageList, "InputImageList"}, + {ParameterType_InputVectorData, "InputVectorData"}, + {ParameterType_InputVectorDataList, "InputVectorDataList"}, + {ParameterType_OutputImage, "OutputImage"}, + {ParameterType_OutputVectorData, "OutputVectorData"}, + {ParameterType_Radius, "Radius"}, + {ParameterType_Group, "Group"}, + {ParameterType_ListView, "ListView"}, + {ParameterType_ComplexInputImage, "ComplexInputImage"}, + {ParameterType_ComplexOutputImage, "ComplexOutputImage"}, + {ParameterType_RAM, "RAM"}, + {ParameterType_OutputProcessXML, "OutputProcessXML"}, + {ParameterType_InputProcessXML, "InputProcessXML"}, + {ParameterType_Bool, "Bool"}}; +} + +// Free functions to convert from and to std::string +std::string ParameterTypeToString(ParameterType type); +ParameterType ParameterStringToType(const std::string& str); + typedef enum { UserLevel_Basic, diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 078d71de576cc174f504db2707eb2e1d50a44881..a25d98d3fff3028ad2f5973330860be736d31168 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -60,6 +60,7 @@ set( OTBApplicationEngine_SRC otbWrapperBoolParameter.cxx otbWrapperMetaDataHelper.cxx otbWrapperParameter.cxx + otbWrapperTypes.cxx ) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index 96dfc2e71c62606d84b61b60f575a038a652b2f1..dc3d5c3cb031a71b56108cf0218eb5c28e762703 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -29,11 +29,10 @@ #include "otbWrapperInputVectorDataParameter.h" #include "otbWrapperInputVectorDataListParameter.h" #include "otbWrapperOutputVectorDataParameter.h" -#include "otbWrapperRadiusParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperStringListParameter.h" #include "otbWrapperInputImageListParameter.h" #include "otbWrapperInputProcessXMLParameter.h" -#include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" #include "otbWrapperParameterKey.h" #include "otbWrapperBoolParameter.h" @@ -348,195 +347,28 @@ Parameter* Application::GetParameterByKey(std::string name, bool follow) return GetParameterList()->GetParameterByKey(name, follow); } -void Application::SetParameterInt(std::string parameter, int value, bool hasUserValueFlag) +void Application::SetParameterInt(std::string key, int value, bool hasUserValueFlag) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramInt = dynamic_cast<IntParameter*>(param); - paramInt->SetValue(value); - } - else if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetValue(static_cast<float>(value)); - } - else if (dynamic_cast<RadiusParameter*>(param)) - { - RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); - paramRadius->SetValue(static_cast<unsigned int>(value)); - } - else if (dynamic_cast<ChoiceParameter*>(param)) - { - ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); - paramChoice->SetValue(value); - } - else if (dynamic_cast<BoolParameter*>(param)) - { - BoolParameter* paramBool = dynamic_cast<BoolParameter*>(param); - paramBool->SetValue(static_cast<bool>(value)); - } - else - { - otbAppLogWARNING(<< "SetParameterInt on parameter " + parameter); - } - - this->SetParameterUserValue(parameter, hasUserValueFlag); + GetParameterByKey(key)->FromInt(value); + this->SetParameterUserValue(key, hasUserValueFlag); } -void Application::SetParameterFloat(std::string parameter, float value, bool hasUserValueFlag) -{ - Parameter* param = GetParameterByKey(parameter); - if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetValue(value); - } - - this->SetParameterUserValue(parameter, hasUserValueFlag); +void Application::SetParameterFloat(std::string key, float value, bool hasUserValueFlag) +{ + GetParameterByKey(key)->FromFloat(value); + this->SetParameterUserValue(key, hasUserValueFlag); } void Application::SetParameterString(std::string parameter, std::string value, bool hasUserValueFlag) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ChoiceParameter*>(param)) - { - ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<ListViewParameter*>(param)) - { - ListViewParameter* paramDown = dynamic_cast<ListViewParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<StringParameter*>(param)) - { - StringParameter* paramDown = dynamic_cast<StringParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<InputFilenameParameter*>(param)) - { - InputFilenameParameter* paramDown = dynamic_cast<InputFilenameParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<OutputFilenameParameter*>(param)) - { - OutputFilenameParameter* paramDown = dynamic_cast<OutputFilenameParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<DirectoryParameter*>(param)) - { - DirectoryParameter* paramDown = dynamic_cast<DirectoryParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramDown = dynamic_cast<FloatParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<RadiusParameter*>(param)) - { - RadiusParameter* paramDown = dynamic_cast<RadiusParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramDown = dynamic_cast<IntParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<InputImageParameter*>(param)) - { - InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); - paramDown->SetFromFileName(value); - } - else if (dynamic_cast<ComplexInputImageParameter*>(param)) - { - ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); - paramDown->SetFromFileName(value); - } - else if (dynamic_cast<InputVectorDataParameter*>(param)) - { - InputVectorDataParameter* paramDown = dynamic_cast<InputVectorDataParameter*>(param); - if ( !paramDown->SetFromFileName(value) ) - otbAppLogCRITICAL( <<"Invalid vector data filename " << value <<"."); - } - else if (dynamic_cast<OutputImageParameter*>(param)) - { - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - paramDown->SetFileName(value); - } - else if (dynamic_cast<ComplexOutputImageParameter*>(param)) - { - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); - paramDown->SetFileName(value); - } - else if (dynamic_cast<OutputVectorDataParameter*>(param)) - { - OutputVectorDataParameter* paramDown = dynamic_cast<OutputVectorDataParameter*>(param); - paramDown->SetFileName(value); - } - else if (dynamic_cast<RAMParameter*>(param)) - { - RAMParameter* paramDown = dynamic_cast<RAMParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<OutputProcessXMLParameter*>(param)) - { - OutputProcessXMLParameter* paramDown = dynamic_cast<OutputProcessXMLParameter*>(param); - paramDown->SetValue(value); - } - else if (dynamic_cast<InputProcessXMLParameter*>(param)) - { - InputProcessXMLParameter* paramDown = dynamic_cast<InputProcessXMLParameter*>(param); - if ( !paramDown->SetFileName(value) ) - otbAppLogCRITICAL( <<"Invalid XML parameter filename " << value <<"."); - } - else if (dynamic_cast<BoolParameter*>(param)) - { - BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); - paramDown->SetValue(value); - } - else - { - otbAppLogWARNING( <<"This parameter can't be set using SetParameterString()."); - } - + GetParameterByKey(parameter)->FromString(value); this->SetParameterUserValue(parameter, hasUserValueFlag); } -void Application::SetParameterStringList(std::string parameter, std::vector<std::string> values, bool hasUserValueFlag) +void Application::SetParameterStringList(std::string key, std::vector<std::string> values, bool hasUserValueFlag) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<InputImageListParameter*>(param)) - { - InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); - paramDown->SetListFromFileName( values ); - } - else if (dynamic_cast<InputVectorDataListParameter*>(param)) - { - InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*>(param); - paramDown->SetListFromFileName( values ); - } - else if (dynamic_cast<InputFilenameListParameter*>(param)) - { - InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*>(param); - paramDown->SetListFromFileName( values ); - } - else if (dynamic_cast<StringListParameter*>(param)) - { - StringListParameter* paramDown = dynamic_cast<StringListParameter*>(param); - paramDown->SetValue(values); - } - else if(dynamic_cast<ListViewParameter *>(param)) - { - ListViewParameter * paramDown = dynamic_cast<ListViewParameter *>(param); - paramDown->SetSelectedNames(values); - } - - this->SetParameterUserValue(parameter, hasUserValueFlag); + GetParameterByKey(key)->FromStringList(values); + this->SetParameterUserValue(key, hasUserValueFlag); } void Application::SetParameterUserValue(std::string paramKey, bool value) @@ -584,6 +416,18 @@ void Application::Init() } } +template <typename T> +T* downcast_check(Parameter* param) +{ + T* down = dynamic_cast<T*>(param); + if (down == nullptr) + { + itkGenericExceptionMacro(<< "Cannot convert parameter '" << param->GetKey() << "'" + << " of type " << ParameterTypeToString(param->GetType()) << " to type " << ParameterTypeToString(T::New()->GetType())); + } + return down; +} + void Application::UpdateParameters() { //read application from xml only once m_IsInXMLParsed is in charge of it. @@ -1088,114 +932,9 @@ void Application::SetParameterRole(std::string paramKey, Role role) } /* Get the parameter type from its name */ -ParameterType Application::GetParameterType(std::string paramKey) const +ParameterType Application::GetParameterType(std::string key) const { - const Parameter* param = GetParameterByKey(paramKey); - - ParameterType type; - - if (dynamic_cast<const ChoiceParameter*>(param)) - { - type = ParameterType_Choice; - } - else if (dynamic_cast<const ListViewParameter*>(param)) - { - type = ParameterType_ListView; - } - else if (dynamic_cast<const RadiusParameter*>(param)) - { - type = ParameterType_Radius; - } - else if (dynamic_cast<const IntParameter*>(param)) - { - type = ParameterType_Int; - } - else if (dynamic_cast<const FloatParameter*>(param)) - { - type = ParameterType_Float; - } - else if (dynamic_cast<const InputFilenameParameter*>(param)) - { - type = ParameterType_InputFilename; - } - else if (dynamic_cast<const InputFilenameListParameter*>(param)) - { - type = ParameterType_InputFilenameList; - } - else if (dynamic_cast<const OutputFilenameParameter*>(param)) - { - type = ParameterType_OutputFilename; - } - else if (dynamic_cast<const DirectoryParameter*>(param)) - { - type = ParameterType_Directory; - } - else if (dynamic_cast<const InputImageParameter*>(param)) - { - type = ParameterType_InputImage; - } - else if (dynamic_cast<const InputImageListParameter*>(param)) - { - type = ParameterType_InputImageList; - } - else if (dynamic_cast<const ComplexInputImageParameter*>(param)) - { - type = ParameterType_ComplexInputImage; - } - else if (dynamic_cast<const InputVectorDataParameter*>(param)) - { - type = ParameterType_InputVectorData; - } - else if (dynamic_cast<const InputVectorDataListParameter*>(param)) - { - type = ParameterType_InputVectorDataList; - } - else if (dynamic_cast<const OutputImageParameter*>(param)) - { - type = ParameterType_OutputImage; - } - else if (dynamic_cast<const ComplexOutputImageParameter*>(param)) - { - type = ParameterType_ComplexOutputImage; - } - else if (dynamic_cast<const OutputVectorDataParameter*>(param)) - { - type = ParameterType_OutputVectorData; - } - else if (dynamic_cast<const StringParameter*>(param)) - { - type = ParameterType_String; - } - else if (dynamic_cast<const StringListParameter*>(param)) - { - type = ParameterType_StringList; - } - else if (dynamic_cast<const RAMParameter*>(param)) - { - type = ParameterType_RAM; - } - else if (dynamic_cast<const ParameterGroup*>(param)) - { - type = ParameterType_Group; - } - else if (dynamic_cast<const OutputProcessXMLParameter*>(param)) - { - type = ParameterType_OutputProcessXML; - } - else if (dynamic_cast<const InputProcessXMLParameter*>(param)) - { - type = ParameterType_InputProcessXML; - } - else if (dynamic_cast<const BoolParameter*>(param)) - { - type = ParameterType_Bool; - } - else - { - itkExceptionMacro(<< "Unknown parameter : " << paramKey); - } - - return type; + return GetParameterByKey(key)->GetType(); } std::vector<std::string> Application::GetChoiceKeys(std::string name) @@ -1293,191 +1032,101 @@ int Application::GetDefaultParameterInt(std::string parameter) return ret; } -void Application::SetDefaultParameterFloat(std::string parameter, float value) +void Application::SetDefaultParameterFloat(std::string key, float value) { - Parameter* param = GetParameterByKey(parameter); + auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); + param->SetDefaultValue(value); - if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetDefaultValue(value); - if (!param->HasUserValue()) paramFloat->SetValue(value); - } + if (!param->HasUserValue()) + { + param->SetValue(value); + } } -float Application::GetDefaultParameterFloat(std::string parameter) +float Application::GetDefaultParameterFloat(std::string key) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - return paramFloat->GetDefaultValue(); - } - return 0; + auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); + return param->GetDefaultValue(); } -void Application::SetDefaultOutputPixelType(std::string parameter, ImagePixelType type) +void Application::SetDefaultOutputPixelType(std::string key, ImagePixelType type) { - Parameter* param = GetParameterByKey(parameter); - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - if (paramDown) - { - paramDown->SetDefaultPixelType(type); - paramDown->SetPixelType(type); - } + auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); + param->SetDefaultPixelType(type); + param->SetPixelType(type); } -void -Application::SetDefaultOutputComplexPixelType(std::string parameter, ComplexImagePixelType type) +void Application::SetDefaultOutputComplexPixelType(std::string key, ComplexImagePixelType type) { - Parameter* param = GetParameterByKey(parameter); - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); - if (paramDown) - { - paramDown->SetDefaultComplexPixelType(type); - paramDown->SetComplexPixelType(type); - } + auto param = downcast_check<ComplexOutputImageParameter>(GetParameterByKey(key)); + param->SetDefaultComplexPixelType(type); + param->SetComplexPixelType(type); } -void Application::SetMinimumParameterIntValue(std::string parameter, int value) +void Application::SetMinimumParameterIntValue(std::string key, int value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramInt = dynamic_cast<IntParameter*>(param); - paramInt->SetMinimumValue(value); - } - else - itkExceptionMacro(<<parameter << " parameter can't be casted to int"); + auto param = downcast_check<IntParameter>(GetParameterByKey(key)); + param->SetMinimumValue(value); } -void Application::SetMaximumParameterIntValue(std::string parameter, int value) +void Application::SetMaximumParameterIntValue(std::string key, int value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramInt = dynamic_cast<IntParameter*>(param); - paramInt->SetMaximumValue(value); - } - else - itkExceptionMacro(<<parameter << " parameter can't be casted to int"); - + auto param = downcast_check<IntParameter>(GetParameterByKey(key)); + param->SetMaximumValue(value); } -void Application::SetMinimumParameterFloatValue(std::string parameter, float value) +void Application::SetMinimumParameterFloatValue(std::string key, float value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetMinimumValue(value); - } - else - itkExceptionMacro(<<parameter << " parameter can't be casted to float"); + auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); + param->SetMinimumValue(value); } -void Application::SetMaximumParameterFloatValue(std::string parameter, float value) +void Application::SetMaximumParameterFloatValue(std::string key, float value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - paramFloat->SetMaximumValue(value); - } - else - itkExceptionMacro(<<parameter << " parameter can't be casted to float"); - + auto param = downcast_check<FloatParameter>(GetParameterByKey(key)); + param->SetMaximumValue(value); } -void Application::SetListViewSingleSelectionMode(std::string parameter, bool status) +void Application::SetListViewSingleSelectionMode(std::string key, bool status) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ListViewParameter*>(param)) - { - ListViewParameter* paramListView = dynamic_cast<ListViewParameter*>(param); - paramListView->SetSingleSelection(status); - } - else - itkExceptionMacro(<<parameter << " parameter can't be casted to ListView"); - + auto param = downcast_check<ListViewParameter>(GetParameterByKey(key)); + param->SetSingleSelection(status); } -bool Application::GetListViewSingleSelectionMode(const std::string& parameter) +bool Application::GetListViewSingleSelectionMode(const std::string& key) { - Parameter* param = GetParameterByKey(parameter); - - ListViewParameter* paramListView = dynamic_cast<ListViewParameter*>(param); - if (paramListView) - { - return paramListView->GetSingleSelection(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to ListView"); - } + auto param = downcast_check<ListViewParameter>(GetParameterByKey(key)); + return param->GetSingleSelection(); } - -void Application::SetParameterOutputImage(std::string parameter, FloatVectorImageType* value) +void Application::SetParameterOutputImage(std::string key, FloatVectorImageType* value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<OutputImageParameter*>(param)) - { - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - paramDown->SetValue(value); - } + auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); + param->SetValue(value); } -void Application::SetParameterComplexOutputImage(std::string parameter, ComplexFloatVectorImageType* value) +void Application::SetParameterComplexOutputImage(std::string key, ComplexFloatVectorImageType* value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ComplexOutputImageParameter*>(param)) - { - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); - paramDown->SetValue(value); - } + auto param = downcast_check<ComplexOutputImageParameter>(GetParameterByKey(key)); + param->SetValue(value); } -void Application::SetParameterOutputImagePixelType(std::string parameter, ImagePixelType pixelType) +void Application::SetParameterOutputImagePixelType(std::string key, ImagePixelType pixelType) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<OutputImageParameter*>(param)) - { - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - paramDown->SetPixelType(pixelType); - } + auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); + param->SetPixelType(pixelType); } -void Application::SetParameterComplexOutputImagePixelType(std::string parameter, - ComplexImagePixelType cpixelType) +void Application::SetParameterComplexOutputImagePixelType(std::string key, ComplexImagePixelType cpixelType) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ComplexOutputImageParameter*>(param)) - { - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); - paramDown->SetComplexPixelType(cpixelType); - } + auto param = downcast_check<ComplexOutputImageParameter>(GetParameterByKey(key)); + param->SetComplexPixelType(cpixelType); } -void Application::SetParameterOutputVectorData(std::string parameter, VectorDataType* value) +void Application::SetParameterOutputVectorData(std::string key, VectorDataType* value) { - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<OutputVectorDataParameter*>(param)) - { - OutputVectorDataParameter* paramDown = dynamic_cast<OutputVectorDataParameter*>(param); - paramDown->SetValue(value); - } + auto param = downcast_check<OutputVectorDataParameter>(GetParameterByKey(key)); + param->SetValue(value); } std::string Application::GetParameterName(std::string parameter) @@ -1501,386 +1150,84 @@ void Application::SetParameterDescription(std::string parameter, std::string des param->SetDescription(desc); } -int Application::GetParameterInt(std::string parameter) +int Application::GetParameterInt(std::string key) { - int ret = 0; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<IntParameter*>(param)) - { - IntParameter* paramInt = dynamic_cast<IntParameter*>(param); - ret = paramInt->GetValue(); - } - else if (dynamic_cast<FloatParameter*>(param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); - ret = static_cast<int>(paramFloat->GetValue()); - } - else if (dynamic_cast<RadiusParameter*>(param)) - { - RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); - ret = paramRadius->GetValue(); - } - else if (dynamic_cast<RAMParameter*>(param)) - { - RAMParameter* paramRAM = dynamic_cast<RAMParameter*>(param); - ret = paramRAM->GetValue(); - } - else if (dynamic_cast<ChoiceParameter*>(param)) - { - ChoiceParameter* paramChoice = dynamic_cast<ChoiceParameter*>(param); - ret = paramChoice->GetValue(); - } - else if (dynamic_cast<BoolParameter*>(param)) - { - BoolParameter* paramBool = dynamic_cast<BoolParameter*>(param); - ret = static_cast<int>(paramBool->GetValue()); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to int"); - } - - return ret; + return GetParameterByKey(key)->ToInt(); } -float Application::GetParameterFloat(std::string parameter) +float Application::GetParameterFloat(std::string key) { - float ret = 0.0; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<FloatParameter*> (param)) - { - FloatParameter* paramFloat = dynamic_cast<FloatParameter*> (param); - ret = paramFloat->GetValue(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to float"); - } - - return ret; + return GetParameterByKey(key)->ToFloat(); } -std::string Application::GetParameterString(std::string parameter) +std::string Application::GetParameterString(std::string key) { - std::string ret=""; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ChoiceParameter*>(param)) - { - ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param); - if (paramDown->HasValue()) - { - std::string choiceKey = paramDown->GetChoiceKey( paramDown->GetValue() ); - size_t lastPointPos = choiceKey.find_last_of('.'); - if(lastPointPos != std::string::npos) - { - ret = choiceKey.substr(lastPointPos); - } - else - { - ret = choiceKey; - } - } - else - { - ret = ""; - } - } - else if (dynamic_cast<ListViewParameter*>(param)) - { - ListViewParameter* paramDown = dynamic_cast<ListViewParameter*>(param); - std::string choiceKey = paramDown->GetChoiceKey( paramDown->GetValue() ); - size_t lastPointPos = choiceKey.find_last_of('.'); - if(lastPointPos != std::string::npos) - { - ret = choiceKey.substr(lastPointPos); - } - else - { - ret = choiceKey; - } - } - else if (dynamic_cast<StringParameter*>(param)) - { - StringParameter* paramDown = dynamic_cast<StringParameter*>(param); - ret = paramDown->GetValue(); - } - else if (dynamic_cast<InputFilenameParameter*>(param)) - { - InputFilenameParameter* paramDown = dynamic_cast<InputFilenameParameter*>(param); - ret = paramDown->GetValue(); - } - else if (dynamic_cast<OutputFilenameParameter*>(param)) - { - OutputFilenameParameter* paramDown = dynamic_cast<OutputFilenameParameter*>(param); - ret = paramDown->GetValue(); - } - else if (dynamic_cast<DirectoryParameter*>(param)) - { - DirectoryParameter* paramDown = dynamic_cast<DirectoryParameter*>(param); - ret = paramDown->GetValue(); - } - else if (dynamic_cast<InputImageParameter*>(param)) - { - InputImageParameter* paramDown = dynamic_cast<InputImageParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<ComplexInputImageParameter*>(param)) - { - ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<InputVectorDataParameter*>(param)) - { - InputVectorDataParameter* paramDown = dynamic_cast<InputVectorDataParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<OutputImageParameter*>(param)) - { - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<OutputVectorDataParameter*>(param)) - { - OutputVectorDataParameter* paramDown = dynamic_cast<OutputVectorDataParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<OutputProcessXMLParameter*>(param)) - { - OutputProcessXMLParameter* paramDown = dynamic_cast<OutputProcessXMLParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<InputProcessXMLParameter*>(param)) - { - InputProcessXMLParameter* paramDown = dynamic_cast<InputProcessXMLParameter*>(param); - ret = paramDown->GetFileName(); - } - else if (dynamic_cast<BoolParameter*>(param)) - { - BoolParameter* paramDown = dynamic_cast<BoolParameter*>(param); - ret = paramDown->GetValueAsString(); - } - else - { - itkExceptionMacro(<<parameter << " : parameter can't be casted to string"); - } - - return ret; + return GetParameterByKey(key)->ToString(); } -std::vector< std::string > -Application -::GetParameterStringList( const std::string & parameter ) +std::vector<std::string> Application::GetParameterStringList(const std::string& key) { - std::vector<std::string> ret; - Parameter * param = GetParameterByKey(parameter); - - if (dynamic_cast<InputImageListParameter*> (param)) - { - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter*> (param); - ret = paramDown->GetFileNameList(); - } - else - if (dynamic_cast<InputVectorDataListParameter*> (param)) - { - InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*> (param); - ret = paramDown->GetFileNameList(); - } - else - if (dynamic_cast<InputFilenameListParameter*> (param)) - { - InputFilenameListParameter* paramDown = dynamic_cast<InputFilenameListParameter*> (param); - ret = paramDown->GetFileNameList(); - } - else - if (dynamic_cast<StringListParameter*> (param)) - { - StringListParameter* paramDown = dynamic_cast<StringListParameter*> (param); - ret = paramDown->GetValue(); - } - else - if (dynamic_cast<ListViewParameter*> (param)) - { - ListViewParameter* paramDown = dynamic_cast<ListViewParameter*> (param); - ret = paramDown->GetSelectedNames(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to StringList"); - } - - return ret; + return GetParameterByKey(key)->ToStringList(); } -void Application::SetParameterInputImage(std::string parameter, ImageBaseType * inputImage) +void Application::SetParameterInputImage(std::string key, ImageBaseType* inputImage) { - Parameter* param = GetParameterByKey(parameter); - - InputImageParameter* paramDown = dynamic_cast<InputImageParameter*> (param); - - if (paramDown) - { - paramDown->SetImage(inputImage); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageParameter"); - } + auto param = downcast_check<InputImageParameter>(GetParameterByKey(key)); + param->SetImage(inputImage); } -ImageBaseType * Application::GetParameterOutputImage(std::string parameter) +ImageBaseType* Application::GetParameterOutputImage(std::string key) { - Parameter* param = GetParameterByKey(parameter); - - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*> (param); - - if (paramDown) - { - return paramDown->GetValue(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to OutputImageParameter"); - } + auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); + return param->GetValue(); } - -void Application::SetParameterComplexInputImage(std::string parameter, ImageBaseType * inputImage) +void Application::SetParameterComplexInputImage(std::string key, ImageBaseType* inputImage) { - Parameter* param = GetParameterByKey(parameter); - - ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*> (param); - - if (paramDown) - { - paramDown->SetImage(inputImage); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to ComplexInputImageParameter"); - } + auto param = downcast_check<ComplexInputImageParameter>(GetParameterByKey(key)); + param->SetImage(inputImage); } -ImageBaseType * Application::GetParameterComplexOutputImage(std::string parameter) +ImageBaseType* Application::GetParameterComplexOutputImage(std::string key) { - Parameter* param = GetParameterByKey(parameter); - - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*> (param); - - if (paramDown) - { - return paramDown->GetValue(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to ComplexOutputImageParameter"); - } + auto param = downcast_check<ComplexOutputImageParameter>(GetParameterByKey(key)); + return param->GetValue(); } -void Application::AddImageToParameterInputImageList(std::string parameter, ImageBaseType * img) +void Application::AddImageToParameterInputImageList(std::string key, ImageBaseType* img) { - Parameter* param = GetParameterByKey(parameter); - - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - - if(paramDown) - { - paramDown->AddImage(img); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); - } - + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + param->AddImage(img); } -void Application::SetNthParameterInputImageList(std::string parameter, const unsigned int &id, ImageBaseType * img) +void Application::SetNthParameterInputImageList(std::string key, const unsigned int& id, ImageBaseType* img) { - Parameter* param = GetParameterByKey(parameter); - - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - - if(paramDown) - { - paramDown->SetNthImage(id,img); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); - } - + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + param->SetNthImage(id, img); } -void Application::AddParameterStringList(std::string parameter, const std::string & str) +void Application::AddParameterStringList(std::string key, const std::string& str) { - Parameter* param = GetParameterByKey(parameter); - - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - - if(paramDown) - { - paramDown->AddFromFileName(str); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); - } - + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + param->AddFromFileName(str); } -void Application::SetNthParameterStringList(std::string parameter, const unsigned int &id, const std::string & str) +void Application::SetNthParameterStringList(std::string key, const unsigned int& id, const std::string& str) { - Parameter* param = GetParameterByKey(parameter); - - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - - if(paramDown) - { - paramDown->SetNthFileName(id,str); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); - } - + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + param->SetNthFileName(id, str); } - - -void Application::ClearParameterInputImageList(std::string parameter) +void Application::ClearParameterInputImageList(std::string key) { - Parameter* param = GetParameterByKey(parameter); - - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - - if(paramDown) - { - paramDown->ClearValue(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); - } - + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + param->ClearValue(); } -unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::string parameter) +unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::string key) { - Parameter* param = GetParameterByKey(parameter); - - InputImageListParameter * paramDown = dynamic_cast<InputImageListParameter *>(param); - - if(paramDown) - { - return paramDown->Size(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); - } - + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + return param->Size(); } FloatVectorImageType* Application::GetParameterImage(std::string parameter) @@ -1888,165 +1235,45 @@ FloatVectorImageType* Application::GetParameterImage(std::string parameter) return this->GetParameterImage<FloatVectorImageType>(parameter); } -FloatVectorImageListType* Application::GetParameterImageList(std::string parameter) +FloatVectorImageListType* Application::GetParameterImageList(std::string key) { - FloatVectorImageListType::Pointer ret=nullptr; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<InputImageListParameter*>(param)) - { - InputImageListParameter* paramDown = dynamic_cast<InputImageListParameter*>(param); - ret = paramDown->GetImageList(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to ImageListType"); - } - - return ret; + auto param = downcast_check<InputImageListParameter>(GetParameterByKey(key)); + return param->GetImageList(); } -ComplexFloatVectorImageType* Application::GetParameterComplexImage(std::string parameter) +ComplexFloatVectorImageType* Application::GetParameterComplexImage(std::string key) { - ComplexFloatVectorImageType::Pointer ret=nullptr; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<ComplexInputImageParameter*>(param)) - { - ComplexInputImageParameter* paramDown = dynamic_cast<ComplexInputImageParameter*>(param); - ret = paramDown->GetImage(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to ComplexImageType"); - } - - return ret; + auto param = downcast_check<ComplexInputImageParameter>(GetParameterByKey(key)); + return param->GetImage(); } -VectorDataType* Application::GetParameterVectorData(std::string parameter) +VectorDataType* Application::GetParameterVectorData(std::string key) { - VectorDataType::Pointer ret=nullptr; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<InputVectorDataParameter*>(param)) - { - InputVectorDataParameter* paramDown = dynamic_cast<InputVectorDataParameter*>(param); - ret = paramDown->GetVectorData(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to Vector Data"); - } - return ret; + auto param = downcast_check<InputVectorDataParameter>(GetParameterByKey(key)); + return param->GetVectorData(); } -VectorDataListType* Application::GetParameterVectorDataList(std::string parameter) +VectorDataListType* Application::GetParameterVectorDataList(std::string key) { - VectorDataListType::Pointer ret=nullptr; - Parameter* param = GetParameterByKey(parameter); - - if (dynamic_cast<InputVectorDataListParameter*>(param)) - { - InputVectorDataListParameter* paramDown = dynamic_cast<InputVectorDataListParameter*>(param); - ret = paramDown->GetVectorDataList(); - } - else - { - itkExceptionMacro(<<parameter << " parameter can't be casted to Vector Data List"); - } - return ret; + auto param = downcast_check<InputVectorDataListParameter>(GetParameterByKey(key)); + return param->GetVectorDataList(); } - -std::string Application::GetParameterAsString(std::string paramKey) +std::string Application::GetParameterAsString(std::string key) { - std::string ret=""; - ParameterType type = this->GetParameterType( paramKey ); - - if( type == ParameterType_String || type == ParameterType_InputFilename || type == ParameterType_OutputFilename - || type == ParameterType_Directory || type == ParameterType_InputImage - || type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData - || type == ParameterType_OutputImage || type == ParameterType_OutputVectorData - || type == ParameterType_ListView || type == ParameterType_Choice - || type == ParameterType_OutputProcessXML || type == ParameterType_InputProcessXML - || type == ParameterType_Bool) - { - ret = this->GetParameterString( paramKey ); - } - else if ( type == ParameterType_Int || type == ParameterType_Radius - || type == ParameterType_RAM) - { - std::ostringstream oss; - oss << this->GetParameterInt( paramKey ); - ret = oss.str(); - } - else if( type == ParameterType_Float ) - { - std::ostringstream oss; - //oss << std::setprecision(10); - oss << this->GetParameterFloat( paramKey ); - ret = oss.str(); - } - else if( type == ParameterType_StringList || - type == ParameterType_InputImageList || - type == ParameterType_InputVectorDataList || - type == ParameterType_InputFilenameList) - { - std::ostringstream oss; - oss << std::setprecision(10); - const std::vector<std::string> strList = this->GetParameterStringList(paramKey); - for (size_t i = 0; i < strList.size(); i++) - { - if (i != 0) - { - oss << " "; - } - oss << strList[i]; - } - ret = oss.str(); - } - else - { - itkExceptionMacro(<<paramKey << " parameter can't be casted to string"); - } - return ret; + return GetParameterString(key); } -ImagePixelType Application::GetParameterOutputImagePixelType(std::string parameter) +ImagePixelType Application::GetParameterOutputImagePixelType(std::string key) { - Parameter* param = GetParameterByKey(parameter); - ImagePixelType ret=ImagePixelType_uint8; //by default to avoid warning - - if (dynamic_cast<OutputImageParameter*>(param)) - { - OutputImageParameter* paramDown = dynamic_cast<OutputImageParameter*>(param); - ret = paramDown->GetPixelType(); - } - else - { - itkExceptionMacro("Unable to find PixelType in parameter "<<parameter<<"."); - } - - return ret; + auto param = downcast_check<OutputImageParameter>(GetParameterByKey(key)); + return param->GetPixelType(); } -ComplexImagePixelType Application::GetParameterComplexOutputImagePixelType(std::string parameter) +ComplexImagePixelType Application::GetParameterComplexOutputImagePixelType(std::string key) { - Parameter* param = GetParameterByKey(parameter); - ComplexImagePixelType ret=ComplexImagePixelType_float; //by default to avoid warning - - if (dynamic_cast<ComplexOutputImageParameter*>(param)) - { - ComplexOutputImageParameter* paramDown = dynamic_cast<ComplexOutputImageParameter*>(param); - ret = paramDown->GetComplexPixelType(); - } - else - { - itkExceptionMacro("Unable to find PixelType in parameter "<<parameter<<"."); - } - - return ret; + auto param = downcast_check<ComplexOutputImageParameter>(GetParameterByKey(key)); + return param->GetComplexPixelType(); } void diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx index f26570474cd4ea47c1393289f954fec344acfb31..d5ad5a8e641c5214c1d07808f2df107ffcd013a0 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperBoolParameter.cxx @@ -77,5 +77,30 @@ BoolParameter::SetValue(const std::string & str) } } +ParameterType BoolParameter::GetType() const +{ + return ParameterType_Bool; +} + +int BoolParameter::ToInt() const +{ + return static_cast<int>(this->GetValue()); +} + +std::string BoolParameter::ToString() const +{ + return GetValueAsString(); +} + +void BoolParameter::FromString(const std::string& value) +{ + SetValue(value); +} + +void BoolParameter::FromInt(int value) +{ + SetValue(static_cast<bool>(value)); +} + } // end of namespace Wrapper } // end of namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx index dc69aaf989e437851b57ab3ca9329fb1eba3e7e4..d6e02a62e500dcf1812622fac37c48b0d41e4c8a 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperChoiceParameter.cxx @@ -58,8 +58,7 @@ ChoiceParameter::AddChoice( std::string choicekey, std::string choiceName ) this->AddChild(choice.m_AssociatedParameter.GetPointer()); } -std::string -ChoiceParameter::GetChoiceKey( int i ) +std::string ChoiceParameter::GetChoiceKey(int i) const { return m_ChoiceList[i].m_Key; } @@ -182,8 +181,7 @@ ChoiceParameter::SetValue(std::string choiceKey) << this->GetKey() << "'"); } -unsigned int -ChoiceParameter::GetValue() +unsigned int ChoiceParameter::GetValue() const { return m_CurrentChoice; } @@ -211,5 +209,57 @@ ChoiceParameter::GetParametersKeys() return parameters; } +bool ChoiceParameter::HasValue() const +{ + return !m_ChoiceList.empty(); +} + +void ChoiceParameter::ClearValue() +{ + // Same as constructor init value + // Note that this may be invalid if HasValue() == false + m_CurrentChoice = 0; +} + +ParameterType ChoiceParameter::GetType() const +{ + return ParameterType_Choice; +} + +int ChoiceParameter::ToInt() const +{ + return this->GetValue(); +} + +void ChoiceParameter::FromInt(int value) +{ + SetValue(value); +} + +std::string ChoiceParameter::ToString() const +{ + if (HasValue()) + { + std::string choiceKey = GetChoiceKey(GetValue()); + const size_t lastPointPos = choiceKey.find_last_of('.'); + if (lastPointPos != std::string::npos) + { + return choiceKey.substr(lastPointPos); + } + else + { + return choiceKey; + } + } + else + { + return ""; + } +} + +void ChoiceParameter::FromString(const std::string& value) +{ + SetValue(value); +} } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx index b55196c8b2001e00c30ffdf9d9db132a4c5e1783..e118b270b71b1e1ab2bf15d3152167e80211502e 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx @@ -146,6 +146,21 @@ ComplexInputImageParameter::ClearValue() m_UseFilename = true; } +ParameterType ComplexInputImageParameter::GetType() const +{ + return ParameterType_ComplexInputImage; +} + +std::string ComplexInputImageParameter::ToString() const +{ + return GetFileName(); +} + +void ComplexInputImageParameter::FromString(const std::string& value) +{ + SetFromFileName(value); +} + /* Support for ComplexInputImageParameter. This has been done to support the macro otbGetParameterImageMacro of otbWrapperApplication.h */ #define otbGetFalseImageMacro(image) \ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx index c87ce1036bb60b66be1dcc1240ecaae64032e805..35ea2a050a04a9c6ecfdfc7750392e3a7babc260 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx @@ -310,5 +310,19 @@ void ComplexOutputImageParameter::SetFileName (const std::string& filename) SetActive(true); } +ParameterType ComplexOutputImageParameter::GetType() const +{ + return ParameterType_ComplexOutputImage; +} + +std::string ComplexOutputImageParameter::ToString() const +{ + return GetFileName(); +} + +void ComplexOutputImageParameter::FromString(const std::string& value) +{ + SetFileName(value); +} } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx index 127b5263bbd79f2e0065725063be5eb2b3ea5f8e..f5db647d522940b65a6b38480e72f58b878fd773 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputFilenameListParameter.cxx @@ -99,30 +99,10 @@ InputFilenameListParameter return FILENAME_FILTER; } - -/*****************************************************************************/ -const std::string & -InputFilenameListParameter -::ToString( const ParameterType::Pointer & p ) const +ParameterType InputFilenameListParameter::GetType() const { - assert( !p.IsNull() ); - - return p->GetValue(); + return ParameterType_InputFilenameList; } - -/*****************************************************************************/ -const InputFilenameListParameter::ParameterType::Pointer & -InputFilenameListParameter -::FromString( const ParameterType::Pointer & p, - const std::string & s ) const -{ - assert( !p.IsNull() ); - - p->SetValue( s ); - - return p; -} - } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx index 9c2f0a13861b0e56d03f84abebcfd58d25456dee..fe6afc7d7cf690b8c25f14f97cf8ca328b0d0c3f 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageListParameter.cxx @@ -223,31 +223,6 @@ InputImageListParameter return IMAGES_FILTER; } - -/*****************************************************************************/ -const std::string & -InputImageListParameter -::ToString( const ParameterType::Pointer & p ) const -{ - assert( !p.IsNull() ); - - return p->GetFileName(); -} - -/*****************************************************************************/ -const InputImageListParameter::ParameterType::Pointer & -InputImageListParameter -::FromString( const ParameterType::Pointer & p, - const std::string & s ) const -{ - assert( !p.IsNull() ); - - p->SetFromFileName( s ); - - return p; -} - - } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx index 3b83bfcf286a52ea64c0d4311ca39acb73191901..65d6d6780585ceaa9bb696d18dbbc1da3b39f6dd 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx @@ -110,5 +110,19 @@ InputImageParameter m_UseFilename = true; } +ParameterType InputImageParameter::GetType() const +{ + return ParameterType_InputImage; +} + +std::string InputImageParameter::ToString() const +{ + return GetFileName(); +} + +void InputImageParameter::FromString(const std::string& value) +{ + SetFromFileName(value); +} } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx index 5225d1d0ae7b84d8b07aa8be5b716d51ddc524e7..cae44be16bbdc4c53bb0465c40bd2d18e3b50175 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputProcessXMLParameter.cxx @@ -29,14 +29,13 @@ #include "otbWrapperInputVectorDataParameter.h" #include "otbWrapperInputVectorDataListParameter.h" #include "otbWrapperOutputVectorDataParameter.h" -#include "otbWrapperRadiusParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperStringListParameter.h" #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageListParameter.h" #include "otbWrapperComplexInputImageParameter.h" #include "otbWrapperOutputImageParameter.h" #include "otbWrapperComplexOutputImageParameter.h" -#include "otbWrapperRAMParameter.h" #include "itksys/SystemTools.hxx" #include "otbMacro.h" diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx index dce54b20da426b4fb1fcefa9f4630ec7aae1c7aa..72b9927f1bcd32f74eea680ad7399f1d55b099cf 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperInputVectorDataListParameter.cxx @@ -190,30 +190,6 @@ InputVectorDataListParameter return VECTOR_DATA_FILTER; } -/*****************************************************************************/ -const std::string & -InputVectorDataListParameter -::ToString( const ParameterType::Pointer & p ) const -{ - assert( !p.IsNull() ); - - return p->GetFileName(); -} - -/*****************************************************************************/ -const InputVectorDataListParameter::ParameterType::Pointer & -InputVectorDataListParameter -::FromString( const ParameterType::Pointer & p, - const std::string & s ) const -{ - assert( !p.IsNull() ); - - p->SetFromFileName( s ); - - return p; -} - - } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx index ad4f82101f0108a462ada65e9e09d701ce964d4c..20493538be41291abf86bb552246e3a8804a4b45 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperListViewParameter.cxx @@ -49,8 +49,7 @@ ListViewParameter::AddChoice( std::string choicekey, std::string choiceName ) m_ChoiceList.push_back(choice); } -std::string -ListViewParameter::GetChoiceKey( int i ) +std::string ListViewParameter::GetChoiceKey(int i) const { if (m_ChoiceList.empty()) { @@ -141,8 +140,7 @@ ListViewParameter::SetValue(std::string choiceKey) itkExceptionMacro(<< "Cannot find " << choiceKey); } -unsigned int -ListViewParameter::GetValue() +unsigned int ListViewParameter::GetValue() const { return m_CurrentChoice; } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx index e9e206d0696b90a7f535a98266cc6737a8ae92eb..0cc21cebf0c450edce9050a29c34fe85d65e6c2b 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx @@ -29,14 +29,13 @@ #include "otbWrapperInputVectorDataParameter.h" #include "otbWrapperInputVectorDataListParameter.h" #include "otbWrapperOutputVectorDataParameter.h" -#include "otbWrapperRadiusParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperStringListParameter.h" #include "otbWrapperInputImageParameter.h" #include "otbWrapperInputImageListParameter.h" #include "otbWrapperComplexInputImageParameter.h" #include "otbWrapperOutputImageParameter.h" #include "otbWrapperComplexOutputImageParameter.h" -#include "otbWrapperRAMParameter.h" #include "itksys/SystemTools.hxx" namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx index 39c0199f07989ac49ac398da110e981ffdc5351d..c0a135253a68145d110f02588bf9a3bd7e8708b3 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx @@ -217,8 +217,47 @@ std::vector<Parameter::Pointer > Parameter::GetChildrenList() return m_ChildrenList; } +// Base implementation of To*/From* indicate that the parameter cannot be converted +// Derived classes override them if they can provide the conversion +int Parameter::ToInt() const +{ + itkExceptionMacro("Cannot convert parameter " << m_Key << " to int."); +} +float Parameter::ToFloat() const +{ + itkExceptionMacro("Cannot convert parameter " << m_Key << " to float."); +} +std::string Parameter::ToString() const +{ + itkExceptionMacro("Cannot convert parameter " << m_Key << " to std::string."); +} + +std::vector<std::string> Parameter::ToStringList() const +{ + itkExceptionMacro("Cannot convert parameter " << m_Key << " to std::vector<std::string>."); +} + +void Parameter::FromInt(int) +{ + itkExceptionMacro("Cannot set parameter " << m_Key << " from int."); +} + +void Parameter::FromFloat(float) +{ + itkExceptionMacro("Cannot set parameter " << m_Key << " from float."); +} + +void Parameter::FromString(const std::string&) +{ + itkExceptionMacro("Cannot set parameter " << m_Key << " from std:string."); +} + +void Parameter::FromStringList(const std::vector<std::string>&) +{ + itkExceptionMacro("Cannot set parameter " << m_Key << " from std:vector<std:string>."); +} } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx index ec1ad39286531617f4563250860bdfea1b066d84..353da7c4eba8fef1f2f1b8d69c921950358faf52 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameterGroup.cxx @@ -18,6 +18,7 @@ * limitations under the License. */ +#include "otbWrapperTypes.h" #include "otbWrapperChoiceParameter.h" #include "otbWrapperListViewParameter.h" #include "otbWrapperDirectoryParameter.h" @@ -31,13 +32,12 @@ #include "otbWrapperOutputImageParameter.h" #include "otbWrapperComplexOutputImageParameter.h" #include "otbWrapperOutputVectorDataParameter.h" -#include "otbWrapperRadiusParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperStringListParameter.h" #include "otbWrapperInputImageListParameter.h" #include "otbWrapperInputVectorDataListParameter.h" #include "otbWrapperInputProcessXMLParameter.h" #include "otbWrapperParameterKey.h" -#include "otbWrapperRAMParameter.h" #include "otbWrapperProxyParameter.h" #include "otbWrapperBoolParameter.h" @@ -234,244 +234,15 @@ ParameterGroup::GetSelectedItems(std::string paramKey) } /* Get the parameter type from its string version of ParameterType enum */ - ParameterType ParameterGroup::GetParameterTypeFromString(std::string type) - { - if (type == "Choice") - { - return ParameterType_Choice; - } - else if (type == "ListView") - { - return ParameterType_ListView; - } - else if (type == "Radius") - { - return ParameterType_Radius; - } - else if (type == "Int") - { - return ParameterType_Int; - } - else if (type == "Float") - { - return ParameterType_Float; - } - else if (type == "InputFilename") - { - return ParameterType_InputFilename; - } - else if (type == "InputFilenameList") - { - return ParameterType_InputFilenameList; - } - else if (type == "OutputFilename") - { - return ParameterType_OutputFilename; - } - else if (type == "Directory") - { - return ParameterType_Directory; - } - else if (type == "InputImage") - { - return ParameterType_InputImage; - } - else if (type == "InputImageList") - { - return ParameterType_InputImageList; - } - else if (type == "ComplexInputImage") - { - return ParameterType_ComplexInputImage; - } - else if (type == "InputVectorData") - { - return ParameterType_InputVectorData; - } - else if (type == "InputVectorDataList") - { - return ParameterType_InputVectorDataList; - } - else if (type == "OutputImage") - { - return ParameterType_OutputImage; - } - else if (type == "ComplexOutputImage") - { - return ParameterType_ComplexOutputImage; - } - else if (type == "OutputVectorData") - { - return ParameterType_OutputVectorData; - } - else if (type == "String") - { - return ParameterType_String; - } - else if (type == "StringList") - { - return ParameterType_StringList; - } - else if (type == "RAM") - { - return ParameterType_RAM; - } - else if (type == "Group") - { - return ParameterType_Group; - } - else if (type == "OutputProcessXML") - { - return ParameterType_OutputProcessXML; - } - else if (type == "InputProcessXML") - { - return ParameterType_InputProcessXML; - } - else if (type == "Bool") - { - return ParameterType_Bool; - } - else - { - otbLogMacro(Error, << "Cannot find parameter type code for type: " << type); - throw std::invalid_argument("Cannot find parameter type code for type: " + type); - } +ParameterType ParameterGroup::GetParameterTypeFromString(const std::string& str) +{ + return ParameterStringToType(str); } /* Get the parameter type as string from its ParameterType enum */ std::string ParameterGroup::GetParameterTypeAsString(ParameterType type) { - std::string paramType; - - switch (type) - { - case ParameterType_Int: - { - paramType = "Int"; - } - break; - case ParameterType_Float: - { - paramType = "Float"; - } - break; - case ParameterType_String: - { - paramType = "String"; - } - break; - case ParameterType_InputFilename: - { - paramType = "InputFilename"; - } - break; - case ParameterType_OutputFilename: - { - paramType = "OutputFilename"; - } - break; - case ParameterType_Directory: - { - paramType = "Directory"; - } - break; - case ParameterType_InputImage: - { - paramType = "InputImage"; - } - break; - case ParameterType_InputVectorData: - { - paramType = "InputVectorData"; - } - break; - case ParameterType_OutputImage: - { - paramType = "OutputImage"; - } - break; - case ParameterType_OutputVectorData: - { - paramType = "OutputVectorData"; - } - break; - case ParameterType_Radius: - { - paramType = "Radius"; - } - break; - case ParameterType_Choice: - { - paramType = "Choice"; - } - break; - case ParameterType_Group: - { - paramType = "Group"; - } - break; - case ParameterType_StringList: - { - paramType = "StringList"; - } - break; - case ParameterType_InputFilenameList: - { - paramType = "InputFilenameList"; - } - break; - case ParameterType_InputImageList: - { - paramType = "InputImageList"; - } - break; - case ParameterType_InputVectorDataList: - { - paramType = "InputVectorDataList"; - } - break; - case ParameterType_ListView: - { - paramType = "ListView"; - } - break; - case ParameterType_ComplexInputImage: - { - paramType = "ComplexInputImage"; - } - break; - case ParameterType_ComplexOutputImage: - { - paramType = "ComplexOutputImage"; - } - break; - case ParameterType_RAM: - { - paramType = "RAM"; - } - break; - case ParameterType_OutputProcessXML: - { - paramType = "OutputProcessXML"; - } - break; - case ParameterType_InputProcessXML: - { - paramType = "InputProcessXML"; - } - break; - case ParameterType_Bool: - { - paramType = "Bool"; - } - break; - default: - { - std::cerr << "Cannot find string version of parameter type" << std::endl; - } - } - return paramType; + return ParameterTypeToString(type); } /** Add a new parameter to the parameter group */ diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx index d1becbfed272dea0917d73122439a91a91362ccd..f153deb803b2b013b4abd6f5189ebfad6f3ca536 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperStringListParameter.cxx @@ -73,9 +73,7 @@ StringListParameter } /*****************************************************************************/ -const std::string & -StringListParameter -::GetNthElement( std::size_t i ) const +std::string StringListParameter::GetNthElement(std::size_t i) const { return GetNthFileName( i ); } @@ -104,30 +102,6 @@ StringListParameter return false; } -/*****************************************************************************/ -const std::string & -StringListParameter -::ToString( const ParameterType::Pointer & p ) const -{ - assert( !p.IsNull() ); - - return p->GetValue(); -} - -/*****************************************************************************/ -const StringListParameter::ParameterType::Pointer & -StringListParameter -::FromString( const ParameterType::Pointer & p, - const std::string & s ) const -{ - assert( !p.IsNull() ); - - p->SetValue( s ); - - return p; -} - - } } diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperTypes.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperTypes.cxx new file mode 100644 index 0000000000000000000000000000000000000000..52424deeb33c0e4dc333cfd9fc0f3bec8ff318d0 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperTypes.cxx @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "otbWrapperTypes.h" + +namespace otb +{ +namespace Wrapper +{ + +std::string ParameterTypeToString(ParameterType type) +{ + for (auto p : parameterTypesStrings) + { + if (p.first == type) + { + return p.second; + } + } + itkGenericExceptionMacro("Cannot convert parameter type to string."); +} + +ParameterType ParameterStringToType(const std::string& str) +{ + for (auto p : parameterTypesStrings) + { + if (p.second == str) + { + return p.first; + } + } + itkGenericExceptionMacro("Cannot convert string '" << str << "' to parameter type."); +} +} // namespace Wrapper +} // namespace otb diff --git a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt index f1095d67229291c10b02b3541ad0dd3d4342dc39..05eb4e41f41523b3f5f2ddbdc3e754769ef21490 100644 --- a/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt @@ -28,7 +28,6 @@ otbWrapperStringParameterTest.cxx otbWrapperChoiceParameterTest.cxx otbWrapperApplicationRegistryTest.cxx otbWrapperStringListParameterTest.cxx -otbWrapperRAMParameterTest.cxx otbWrapperDocExampleStructureTest.cxx otbWrapperParameterKeyTest.cxx otbWrapperParameterListTest.cxx @@ -54,11 +53,16 @@ otb_add_test(NAME owTvInputImageParameter COMMAND otbApplicationEngineTestDriver "my description" ) -otb_add_test(NAME owTvNumericalParameter COMMAND otbApplicationEngineTestDriver - otbWrapperNumericalParameterTest1 - 42.42 - "mykey" - "my description" +otb_add_test(NAME owTvFloatParameter COMMAND otbApplicationEngineTestDriver + otbWrapperFloatParameterTest + ) + +otb_add_test(NAME owTvIntParameter COMMAND otbApplicationEngineTestDriver + otbWrapperIntParameterTest + ) + +otb_add_test(NAME owTvRAMParameter COMMAND otbApplicationEngineTestDriver + otbWrapperRAMParameterTest ) otb_add_test(NAME owTvStringParameter COMMAND otbApplicationEngineTestDriver diff --git a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx index 246b1e983788735f53645497bed97dff189973c5..3b38170923ce50a613b05dc10de0a343c64d0cb4 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx @@ -23,7 +23,9 @@ void RegisterTests() { REGISTER_TEST(otbWrapperInputImageParameterTest1); - REGISTER_TEST(otbWrapperNumericalParameterTest1); + REGISTER_TEST(otbWrapperFloatParameterTest); + REGISTER_TEST(otbWrapperIntParameterTest); + REGISTER_TEST(otbWrapperRAMParameterTest); REGISTER_TEST(otbWrapperStringParameterTest1); REGISTER_TEST(otbWrapperChoiceParameterTest1); REGISTER_TEST(otbWrapperApplicationRegistry); diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperNumericalParameterTest.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperNumericalParameterTest.cxx index f49ce2aa0533ceaa4fcabee9aa9bd4d7206deef2..ae03d484ba4bcafd525f014e6692d3cfa42cb382 100644 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperNumericalParameterTest.cxx +++ b/Modules/Wrappers/ApplicationEngine/test/otbWrapperNumericalParameterTest.cxx @@ -24,20 +24,130 @@ #include "otbWrapperNumericalParameter.h" +using namespace otb::Wrapper; +template <typename T> +void assert_equal(const T& a, const T& b) +{ + if (a != b) + { + itkGenericExceptionMacro("assert_equal failed"); + } +} + +int otbWrapperFloatParameterTest(int, char* []) +{ + auto param = FloatParameter::New(); + + param->SetKey("mykey"); + param->SetDescription("My description."); + + assert_equal(param->GetType(), ParameterType_Float); + + { // SetValue + const float val = 42.005; + param->SetValue(val); + assert_equal(param->GetValue(), val); + assert_equal(param->ToInt(), int(val)); + assert_equal(param->ToFloat(), val); + assert_equal(param->ToString(), std::string("42.005")); + } -int otbWrapperNumericalParameterTest1(int itkNotUsed(argc), char* argv[]) + { // FromFloat + const float val = -6.5; + param->FromFloat(val); + assert_equal(param->GetValue(), val); + assert_equal(param->ToInt(), int(val)); + assert_equal(param->ToFloat(), val); + assert_equal(param->ToString(), std::string("-6.5")); + } + + { // FromString + const std::string str = "-100.01"; + const float val = -100.01; + param->FromString(str); + assert_equal(param->GetValue(), val); + assert_equal(param->ToInt(), int(val)); + assert_equal(param->ToFloat(), val); + assert_equal(param->ToString(), std::string("-100.01")); + } + + return EXIT_SUCCESS; +} + +int otbWrapperIntParameterTest(int, char* []) { - typedef otb::Wrapper::NumericalParameter <double> NumericalParameterType; - NumericalParameterType::Pointer numParam = NumericalParameterType::New(); + auto param = IntParameter::New(); + + param->SetKey("mykey"); + param->SetDescription("My description."); + + assert_equal(param->GetType(), ParameterType_Int); + + { // SetValue + const int val = 42; + param->SetValue(val); + assert_equal(param->GetValue(), val); + assert_equal(param->ToInt(), val); + assert_equal(param->ToFloat(), float(val)); + assert_equal(param->ToString(), std::string("42")); + } + + { // FromString + const std::string str = "-100"; + const int val = -100; + param->FromString(str); + assert_equal(param->GetValue(), val); + assert_equal(param->ToInt(), val); + assert_equal(param->ToFloat(), float(val)); + assert_equal(param->ToString(), std::string("-100")); + } + + return EXIT_SUCCESS; +} + +int otbWrapperRAMParameterTest(int, char* []) +{ + typedef RAMParameter RAMParameterType; + RAMParameterType::Pointer parameter = RAMParameterType::New(); + + // Test Set/Get Value + parameter->SetValue(256); + parameter->SetValue(2560); + parameter->SetValue(128); + std::cout << "Last RAMParameter Value set : " << parameter->GetValue() << std::endl; + + // Test Set/Get Default, extremum value + RAMParameterType::ScalarType min = 0; + RAMParameterType::ScalarType max = 1024; + RAMParameterType::ScalarType def = 256; + + parameter->SetDefaultValue(def); + parameter->SetMinimumValue(min); + parameter->SetMaximumValue(max); + + if (parameter->GetMinimumValue() != min) + { + std::cout << "Minimum Value : expexted " << min << " --> got " << parameter->GetMinimumValue() << std::endl; + return EXIT_FAILURE; + } + + if (parameter->GetMaximumValue() != max) + { + std::cout << "Maximum Value : expexted " << max << " --> got " << parameter->GetMaximumValue() << std::endl; + return EXIT_FAILURE; + } + + if (parameter->GetDefaultValue() != def) + { + std::cout << "Default Value : expexted " << def << " --> got " << parameter->GetDefaultValue() << std::endl; + return EXIT_FAILURE; + } - const double value = atof (argv[1]); - const std::string key = argv[2]; - const std::string desc = argv[3]; + // Reset Value + parameter->Reset(); + std::cout << "Last RAMParameter Value set : " << parameter->GetValue() << std::endl; - numParam->SetValue(value); - numParam->SetKey(key); - numParam->SetDescription(desc); return EXIT_SUCCESS; } diff --git a/Modules/Wrappers/ApplicationEngine/test/otbWrapperRAMParameterTest.cxx b/Modules/Wrappers/ApplicationEngine/test/otbWrapperRAMParameterTest.cxx deleted file mode 100644 index e49529b4dc39bd5930da71d1d143f223495a7cc9..0000000000000000000000000000000000000000 --- a/Modules/Wrappers/ApplicationEngine/test/otbWrapperRAMParameterTest.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) - * - * This file is part of Orfeo Toolbox - * - * https://www.orfeo-toolbox.org/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#if defined(_MSC_VER) -#pragma warning ( disable : 4786 ) -#endif - -#include "otbWrapperRAMParameter.h" - -int otbWrapperRAMParameterNew(int itkNotUsed(argc), char * itkNotUsed(argv)[]) -{ - typedef otb::Wrapper::RAMParameter RAMParameterType; - RAMParameterType::Pointer parameter = RAMParameterType::New(); - - // Test Set/Get Value - parameter->SetValue(256); - parameter->SetValue(2560); - parameter->SetValue(128); - std::cout <<"Last RAMParameter Value set : " << parameter->GetValue() << std::endl; - - // Test Set/Get Default, extremum value - RAMParameterType::ScalarType min = 0; - RAMParameterType::ScalarType max = 1024; - RAMParameterType::ScalarType def = 256; - - parameter->SetDefaultValue(def); - parameter->SetMinimumValue(min); - parameter->SetMaximumValue(max); - - if (parameter->GetMinimumValue() != min) - { - std::cout <<"Minimum Value : expexted "<< min << " --> got "<< parameter->GetMinimumValue() << std::endl; - return EXIT_FAILURE; - } - - if (parameter->GetMaximumValue() != max) - { - std::cout <<"Maximum Value : expexted "<< max << " --> got "<< parameter->GetMaximumValue() << std::endl; - return EXIT_FAILURE; - } - - if (parameter->GetDefaultValue() != def) - { - std::cout <<"Default Value : expexted "<< def<< " --> got "<< parameter->GetDefaultValue() << std::endl; - return EXIT_FAILURE; - } - - // Reset Value - parameter->Reset(); - std::cout <<"Last RAMParameter Value set : " << parameter->GetValue() << std::endl; - - - return EXIT_SUCCESS; -} diff --git a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx index bed8cd21dcbbfd8af0cf2cd0491151a2d7aa5a0e..63043c8b9f022420808193a44a8e8ddc64d9cbe5 100644 --- a/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx +++ b/Modules/Wrappers/CommandLine/src/otbWrapperCommandLineLauncher.cxx @@ -29,9 +29,8 @@ #include "otbWrapperInputVectorDataParameter.h" #include "otbWrapperOutputImageParameter.h" #include "otbWrapperOutputVectorDataParameter.h" -#include "otbWrapperRadiusParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperListViewParameter.h" -#include "otbWrapperRAMParameter.h" #include "otbWrapperOutputProcessXMLParameter.h" #include "otbWrapperAddProcessToWatchEvent.h" diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h index 28fca4aba5899248e901e9f6d325388bbf121336..a84acb452ddb484f934f8c7d4f6275f312a36f95 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h @@ -23,8 +23,6 @@ #include <QtWidgets> #include "otbWrapperParameterGroup.h" -#include "otbWrapperRadiusParameter.h" -#include "otbWrapperRAMParameter.h" #include "otbWrapperQtWidgetParameterBase.h" #include "otbWrapperInputProcessXMLParameter.h" #include "otbWrapperOutputProcessXMLParameter.h" diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h index 755be5a6f371987bf9dc807fd60beb37f9d5a019..847ee472e526812925940e462776635242ca1851 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetRAMParameter.h @@ -22,7 +22,7 @@ #define otbWrapperQtWidgetRAMParameter_h #include <QtWidgets> -#include "otbWrapperRAMParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperQtWidgetParameterBase.h" diff --git a/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx b/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx index a4500b4acb5df13f307220316e0ccd4ce73e3144..ddf3338c73e26fa9797ab000bf3e360ad5ac35b7 100644 --- a/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx +++ b/Modules/Wrappers/QtWidget/test/otbWrapperQtWidgetParameterFactory.cxx @@ -25,6 +25,7 @@ #include "otbWrapperQtWidgetParameterFactory.h" #include "otbWrapperStringParameter.h" #include "otbWrapperChoiceParameter.h" +#include "otbWrapperNumericalParameter.h" #include "otbWrapperQtWidgetModel.h" #include "otbWrapperQtWidgetParameterGroup.h"