diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 156449c48ec60712acb6dc2c06f3ee023fdfe57b..a4a82c6ac35979a2a904919c269d14583f763f87 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -53,157 +53,87 @@ public: /** RTTI support */ itkTypeMacro(Parameter, itk::Object); - /** Set the parameter name */ - itkSetStringMacro(Name); - - /** Get the parameter name */ - itkGetStringMacro(Name); - - /** Set the parameter description */ - itkSetStringMacro(Description); - - /** Get the parameter description */ - itkGetConstReferenceMacro( Description, std::string ); - - /** Set the parameter key */ - itkSetStringMacro(Key); - - /** Get the parameter key */ - itkGetStringMacro(Key); - + /** Set/get the parameter name */ + virtual void SetName(const std::string&); + virtual const char* GetName() const; + + /** Set/get the parameter description */ + virtual void SetDescription(const std::string&); + virtual const std::string & GetDescription() const; + + /** Set/get the parameter key */ + virtual void SetKey(const std::string&); + virtual const char* GetKey() const; + /** Set the parameter Active flag */ - itkSetMacro(Active, bool); - - /** Get the parameter Active flag */ - bool GetActive(bool recurseParents = false) const - { - bool result = m_Active; - if (recurseParents && !IsRoot()) - { - 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); + virtual void SetActive(bool flag); + bool GetActive(bool recurseParents = false) const; + + /** Set the parameter Mandatory flag */ + virtual void SetMandatory(bool flag); + virtual bool GetMandatory() const; + virtual void MandatoryOn(); + virtual void MandatoryOff(); /** Set the parameter AutomaticValue flag (which is the opposite of UserValue)*/ - virtual void SetAutomaticValue(bool flag) - { - this->SetUserValue(!flag); - } - + virtual void SetAutomaticValue(bool flag); + /** Get the parameter AutomaticValue flag */ - virtual bool GetAutomaticValue() const - { - return !m_UserValue; - } - + virtual bool GetAutomaticValue() const; + /** Toogle ON the parameter AutomaticValue flag */ - void AutomaticValueOn() - { - this->SetAutomaticValue(true); - } - + void AutomaticValueOn(); + /** Toogle OFF the parameter AutomaticValue flag */ - void AutomaticValueOff() - { - this->SetAutomaticValue(false); - } + void AutomaticValueOff(); /** Set the user access level */ - itkSetEnumMacro(UserLevel, UserLevel); - + virtual void SetUserLevel(const UserLevel level); + /** Get the user access level */ - itkGetEnumMacro(UserLevel, UserLevel); + virtual UserLevel GetUserLevel() const; /** Set the parameter io type*/ - itkSetEnumMacro(Role, Role); + virtual void SetRole(const Role role); /** Get the user access level */ - itkGetEnumMacro(Role, Role); + virtual Role GetRole() const; /** Reset to the the default value. Default implementation does * nothing */ - virtual void Reset() - { - } - + virtual void Reset(); + virtual bool HasValue() const = 0; - virtual bool HasUserValue() const - { - return this->HasValue() && m_UserValue; - } + virtual bool HasUserValue() const; - virtual void SetUserValue(bool isUserValue) - { - m_UserValue = isUserValue; - } + virtual void SetUserValue(bool isUserValue); - virtual void ClearValue() - { - SetActive( false ); - Modified(); - } + virtual void ClearValue(); /** Set/Get the root of the current parameter (direct parent) */ - virtual void SetRoot(const Parameter::Pointer root) - { - m_Root = root.GetPointer(); - } + virtual void SetRoot(const Parameter::Pointer root); - virtual const Parameter::Pointer GetRoot() const - { - return m_Root.GetPointer(); - } + virtual const Parameter::Pointer GetRoot() const; /** Is the parameter a root or a child of another param */ - virtual bool IsRoot() const - { - return (this == m_Root.GetPointer()); - } + virtual bool IsRoot() const; /** Add a child of this parameter when the param is a Group or a * choice */ - virtual void AddChild(Parameter::Pointer child) - { - m_ChildrenList.push_back(child); - } + virtual void AddChild(Parameter::Pointer child); + /** Get the children pointer list : not const cause we need to * alterate the m_Active status and the m_IsCheckbox */ - virtual std::vector<Parameter::Pointer > GetChildrenList() - { - return m_ChildrenList; - } + virtual std::vector<Parameter::Pointer > GetChildrenList(); protected: /** Constructor */ - 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 {} + Parameter(); /** Name of the parameter */ std::string m_Name; diff --git a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt index 4b665b6f97843fecb8e4d192949ce1316626c42e..4ba19c8e8ba810eb63234c4a94d184487d5d4323 100644 --- a/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt +++ b/Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt @@ -58,6 +58,7 @@ set( OTBApplicationEngine_SRC otbWrapperParameterList.cxx otbWrapperBoolParameter.cxx otbWrapperMetaDataHelper.cxx + otbWrapperParameter.cxx ) add_library(OTBApplicationEngine ${OTBApplicationEngine_SRC}) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4ac31c8ff1b87ebdbf2e0886e2f0fd2e466f9011 --- /dev/null +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperParameter.cxx @@ -0,0 +1,224 @@ +/* + * 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; +} + + + + +} +}