Commit 06bbce1b authored by Antoine Regimbeau's avatar Antoine Regimbeau

MRG: Merge branch 'string_parameter_refac' into param_refactoring

parents d301d979 46f27a7d
......@@ -95,9 +95,9 @@ public:
/** Set the parameter key */
// itkSetStringMacro( Key );
void SetKey( const std::string & key )
void SetKey( std::string key )
{
m_Key = key;
m_Key = std::move(key);
}
/** Get the parameter key */
......@@ -144,8 +144,7 @@ public:
*/
virtual void Reset() {};
/** Check wether the parameter has a value. Default implementation set
* m_Valule to an empty string.
/** Check wether the parameter has a value.
*/
virtual bool HasValue() const
{
......@@ -184,7 +183,7 @@ public:
virtual std::string GetValue( int i = -1 ) const = 0;
virtual void SetValue( const std::string & val , int i = 0 ) = 0;
virtual void SetValue( std::string val , int i = 0 ) = 0;
virtual ~Parameter() = default ;
......
......@@ -54,13 +54,13 @@ public:
return m_Value;
}
virtual void SetValue( const std::string & val , int i = 0 ) override
virtual void SetValue( std::string val , int i = 0 ) override
{
if ( i != 0 )
{
//log
}
m_Value = val;
m_Value = std::move(val);
}
~SingleParameter() override = default ;
......
/*
* Copyright (C) 2005-2017 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 otbWrapperExpStringParameter_h
#define otbWrapperExpStringParameter_h
#include "otbWrapperExpSingleParameter.h"
#include "OTBApplicationEngineExport.h"
namespace otb
{
namespace WrapperExp
{
class OTBApplicationEngine_EXPORT StringParameter : public SingleParameter
{
public:
typedef StringParameter Self;
typedef SingleParameter Superclass;
typedef std::shared_ptr<Self> Pointer;
typedef std::shared_ptr<const Self> ConstPointer;
itkTypeMacro( StringParameter , SingleParameter );
static Pointer New()
{
return std::shared_ptr<Self>( new Self() );
}
virtual void SetDefaultValue( std::string val)
{
m_Default = std::move(val);
}
virtual const std::string & GetDefaultValue() const
{
return m_Default;
}
virtual void Reset() override
{
m_Value = m_Default;
}
virtual ~StringParameter() override = default;
protected:
StringParameter() = default;
private:
std::string m_Default;
};
} // end namespace WrapperExp
} // end namespace otb
#endif
......@@ -24,6 +24,7 @@ set(OTBExpApplicationEngineTests
otbExpApplicationEngineTestDriver.cxx
otbWrapperExpNumericalParameterTest.cxx
otbWrapperExpAnyNumericTest.cxx
otbWrapperExpStringParameterTest.cxx
)
add_executable(otbExpApplicationEngineTestDriver ${OTBExpApplicationEngineTests})
......@@ -46,4 +47,8 @@ otb_add_test(NAME TuExpAnyNumeric COMMAND otbExpApplicationEngineTestDriver
otb_add_test(NAME TvExpAnyNumeric COMMAND otbExpApplicationEngineTestDriver
AnyNumericComp
)
otb_add_test(NAME TvExpStringParam COMMAND otbExpApplicationEngineTestDriver
StringParameterTest
)
\ No newline at end of file
......@@ -26,4 +26,5 @@ void RegisterTests()
REGISTER_TEST(NumericalManipulationTest);
REGISTER_TEST(AnyNumericTest);
REGISTER_TEST(AnyNumericComp);
REGISTER_TEST(StringParameterTest);
}
/*
* Copyright (C) 2005-2017 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 "otbWrapperExpStringParameter.h"
using namespace otb::WrapperExp;
int StringParameterTest( int , char ** )
{
auto param (StringParameter::New());
param->SetDefaultValue("toto");
param->SetValue("titi");
if (param->GetValue() != "titi")
{
return EXIT_FAILURE;
}
param->Reset();
if (param->GetValue() != "toto")
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment