Skip to content
Snippets Groups Projects
Commit 93dcabad authored by Julien Michel's avatar Julien Michel
Browse files

Merge branch '1649-WrapperParameter-move-bodies-to-src' into 'develop'

Refactor WrapperParameter code to avoid method bodies in header

See merge request !167
parents 93d1d04e 63ef6d11
No related branches found
No related tags found
2 merge requests!621Release 7.0 (master),!167Refactor WrapperParameter code to avoid method bodies in header
...@@ -53,157 +53,87 @@ public: ...@@ -53,157 +53,87 @@ public:
/** RTTI support */ /** RTTI support */
itkTypeMacro(Parameter, itk::Object); itkTypeMacro(Parameter, itk::Object);
/** Set the parameter name */ /** Set/get the parameter name */
itkSetStringMacro(Name); virtual void SetName(const std::string&);
virtual const char* GetName() const;
/** Get the parameter name */
itkGetStringMacro(Name); /** Set/get the parameter description */
virtual void SetDescription(const std::string&);
/** Set the parameter description */ virtual const std::string & GetDescription() const;
itkSetStringMacro(Description);
/** Set/get the parameter key */
/** Get the parameter description */ virtual void SetKey(const std::string&);
itkGetConstReferenceMacro( Description, std::string ); virtual const char* GetKey() const;
/** Set the parameter key */
itkSetStringMacro(Key);
/** Get the parameter key */
itkGetStringMacro(Key);
/** Set the parameter Active flag */ /** Set the parameter Active flag */
itkSetMacro(Active, bool); virtual void SetActive(bool flag);
bool GetActive(bool recurseParents = false) const;
/** Get the parameter Active flag */
bool GetActive(bool recurseParents = false) const /** Set the parameter Mandatory flag */
{ virtual void SetMandatory(bool flag);
bool result = m_Active; virtual bool GetMandatory() const;
if (recurseParents && !IsRoot()) virtual void MandatoryOn();
{ virtual void MandatoryOff();
result = result && GetRoot()->GetActive(recurseParents);
}
return result;
}
/** Set the parameter mandatory flag */
itkSetMacro(Mandatory, bool);
/** Get the parameter mandatory flag */
itkGetConstMacro(Mandatory, bool);
/** Toogle the parameter mandatory flag */
itkBooleanMacro(Mandatory);
/** Set the parameter AutomaticValue flag (which is the opposite of UserValue)*/ /** Set the parameter AutomaticValue flag (which is the opposite of UserValue)*/
virtual void SetAutomaticValue(bool flag) virtual void SetAutomaticValue(bool flag);
{
this->SetUserValue(!flag);
}
/** Get the parameter AutomaticValue flag */ /** Get the parameter AutomaticValue flag */
virtual bool GetAutomaticValue() const virtual bool GetAutomaticValue() const;
{
return !m_UserValue;
}
/** Toogle ON the parameter AutomaticValue flag */ /** Toogle ON the parameter AutomaticValue flag */
void AutomaticValueOn() void AutomaticValueOn();
{
this->SetAutomaticValue(true);
}
/** Toogle OFF the parameter AutomaticValue flag */ /** Toogle OFF the parameter AutomaticValue flag */
void AutomaticValueOff() void AutomaticValueOff();
{
this->SetAutomaticValue(false);
}
/** Set the user access level */ /** Set the user access level */
itkSetEnumMacro(UserLevel, UserLevel); virtual void SetUserLevel(const UserLevel level);
/** Get the user access level */ /** Get the user access level */
itkGetEnumMacro(UserLevel, UserLevel); virtual UserLevel GetUserLevel() const;
/** Set the parameter io type*/ /** Set the parameter io type*/
itkSetEnumMacro(Role, Role); virtual void SetRole(const Role role);
/** Get the user access level */ /** Get the user access level */
itkGetEnumMacro(Role, Role); virtual Role GetRole() const;
/** Reset to the the default value. Default implementation does /** Reset to the the default value. Default implementation does
* nothing * nothing
*/ */
virtual void Reset() virtual void Reset();
{
}
virtual bool HasValue() const = 0; virtual bool HasValue() const = 0;
virtual bool HasUserValue() const virtual bool HasUserValue() const;
{
return this->HasValue() && m_UserValue;
}
virtual void SetUserValue(bool isUserValue) virtual void SetUserValue(bool isUserValue);
{
m_UserValue = isUserValue;
}
virtual void ClearValue() virtual void ClearValue();
{
SetActive( false );
Modified();
}
/** Set/Get the root of the current parameter (direct parent) */ /** Set/Get the root of the current parameter (direct parent) */
virtual void SetRoot(const Parameter::Pointer root) virtual void SetRoot(const Parameter::Pointer root);
{
m_Root = root.GetPointer();
}
virtual const Parameter::Pointer GetRoot() const virtual const Parameter::Pointer GetRoot() const;
{
return m_Root.GetPointer();
}
/** Is the parameter a root or a child of another param */ /** Is the parameter a root or a child of another param */
virtual bool IsRoot() const virtual bool IsRoot() const;
{
return (this == m_Root.GetPointer());
}
/** Add a child of this parameter when the param is a Group or a /** Add a child of this parameter when the param is a Group or a
* choice * choice
*/ */
virtual void AddChild(Parameter::Pointer child) virtual void AddChild(Parameter::Pointer child);
{
m_ChildrenList.push_back(child);
}
/** Get the children pointer list : not const cause we need to /** Get the children pointer list : not const cause we need to
* alterate the m_Active status and the m_IsCheckbox * alterate the m_Active status and the m_IsCheckbox
*/ */
virtual std::vector<Parameter::Pointer > GetChildrenList() virtual std::vector<Parameter::Pointer > GetChildrenList();
{
return m_ChildrenList;
}
protected: protected:
/** Constructor */ /** Constructor */
Parameter() : Parameter();
m_Name( "" ),
m_Description( "" ),
m_Key( "" ),
m_Mandatory( true ),
m_Active( false ),
m_UserValue( false ),
m_UserLevel( UserLevel_Basic ),
m_Role( Role_Input ),
m_Root( this )
{}
/** Destructor */
~Parameter() override {}
/** Name of the parameter */ /** Name of the parameter */
std::string m_Name; std::string m_Name;
......
...@@ -58,6 +58,7 @@ set( OTBApplicationEngine_SRC ...@@ -58,6 +58,7 @@ set( OTBApplicationEngine_SRC
otbWrapperParameterList.cxx otbWrapperParameterList.cxx
otbWrapperBoolParameter.cxx otbWrapperBoolParameter.cxx
otbWrapperMetaDataHelper.cxx otbWrapperMetaDataHelper.cxx
otbWrapperParameter.cxx
) )
add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC})
......
/*
* 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 "otbWrapperParameter.h"
namespace otb
{
namespace Wrapper
{
// TODO: Constructor/destructor
Parameter::Parameter() :
m_Name(),
m_Description(),
m_Key(),
m_Mandatory( true ),
m_Active( false ),
m_UserValue( false ),
m_UserLevel( UserLevel_Basic ),
m_Role( Role_Input ),
m_Root( this )
{}
/** Set/get the parameter name */
void Parameter::SetName(const std::string& name)
{
m_Name = name;
this->Modified();
}
const char* Parameter::GetName() const
{
return this->m_Name.c_str();
}
/** Set/get the parameter description */
void Parameter::SetDescription(const std::string& description)
{
m_Description = description;
this->Modified();
}
const std::string & Parameter::GetDescription() const
{
return m_Description;
}
/** Set/get the parameter key */
void Parameter::SetKey(const std::string& key)
{
m_Key = key;
this->Modified();
}
const char* Parameter::GetKey() const
{
return this->m_Key.c_str();
}
/** Set the parameter Mandatory flag */
void Parameter::SetMandatory(bool flag)
{
m_Mandatory = flag;
this->Modified();
}
bool Parameter::GetMandatory() const
{
return m_Mandatory;
}
void Parameter::MandatoryOn()
{
SetMandatory(true);
}
void Parameter::MandatoryOff()
{
SetMandatory(false);
}
/** Set the user access level */
void Parameter::SetUserLevel(const UserLevel level)
{
m_UserLevel = level;
this->Modified();
}
/** Parameter::Get the user access level */
UserLevel Parameter::GetUserLevel() const
{
return m_UserLevel;
}
/** Set the parameter io type*/
void Parameter::SetRole(const Role role)
{
m_Role = role;
this->Modified();
}
/** Parameter::Get the user access level */
Role Parameter::GetRole() const
{
return m_Role;
}
void Parameter::SetActive(bool flag)
{
m_Active = flag;
this->Modified();
}
bool Parameter::GetActive(bool recurseParents) const
{
bool result = m_Active;
if (recurseParents && !IsRoot())
{
result = result && GetRoot()->GetActive(recurseParents);
}
return result;
}
void Parameter::SetAutomaticValue(bool flag)
{
this->SetUserValue(!flag);
}
bool Parameter::GetAutomaticValue() const
{
return !m_UserValue;
}
/** Toogle ON the parameter AutomaticValue flag */
void Parameter::AutomaticValueOn()
{
this->SetAutomaticValue(true);
}
/** Toogle OFF the parameter AutomaticValue flag */
void Parameter::AutomaticValueOff()
{
this->SetAutomaticValue(false);
}
void Parameter::Reset()
{
}
bool Parameter::HasUserValue() const
{
return this->HasValue() && m_UserValue;
}
void Parameter::SetUserValue(bool isUserValue)
{
m_UserValue = isUserValue;
}
void Parameter::ClearValue()
{
SetActive( false );
Modified();
}
/** Set/Get the root of the current parameter (direct parent) */
void Parameter::SetRoot(const Parameter::Pointer root)
{
m_Root = root.GetPointer();
}
const Parameter::Pointer Parameter::GetRoot() const
{
return m_Root.GetPointer();
}
/** Is the parameter a root or a child of another param */
bool Parameter::IsRoot() const
{
return (this == m_Root.GetPointer());
}
/** Add a child of this parameter when the param is a Group or a
* choice
*/
void Parameter::AddChild(Parameter::Pointer child)
{
m_ChildrenList.push_back(child);
}
/** Get the children pointer list : not const cause we need to
* alterate the m_Active status and the m_IsCheckbox
*/
std::vector<Parameter::Pointer > Parameter::GetChildrenList()
{
return m_ChildrenList;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment