Commit 31fa2cd1 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: add IsInPrivateDoFlag

No related merge requests found
Showing with 23 additions and 2 deletions
+23 -2
...@@ -212,6 +212,9 @@ public: ...@@ -212,6 +212,9 @@ public:
bool GetParameterEmpty(std::string paramKey); bool GetParameterEmpty(std::string paramKey);
/** Set HasUserValue flag of parameter with key paramKey /** Set HasUserValue flag of parameter with key paramKey
* Note that when this function is called from DoInit, DoUpdateParameters
* or DoExecute, it will always set this flag to false, because this is
* the core behavior of the application.
*/ */
void SetParameterUserValue(std::string paramKey, bool value); void SetParameterUserValue(std::string paramKey, bool value);
...@@ -1022,6 +1025,10 @@ private: ...@@ -1022,6 +1025,10 @@ private:
bool m_HaveInXML; bool m_HaveInXML;
bool m_HaveOutXML; bool m_HaveOutXML;
bool m_IsInXMLParsed; bool m_IsInXMLParsed;
/** Flag is true when executing DoInit, DoUpdateParameters or DoExecute */
bool m_IsInPrivateDo;
/** /**
* Declare the class * Declare the class
* - Wrapper::MapProjectionParametersHandler * - Wrapper::MapProjectionParametersHandler
......
...@@ -65,7 +65,8 @@ Application::Application() ...@@ -65,7 +65,8 @@ Application::Application()
m_Doclink(""), m_Doclink(""),
m_HaveInXML(true), m_HaveInXML(true),
m_HaveOutXML(true), m_HaveOutXML(true),
m_IsInXMLParsed(false) m_IsInXMLParsed(false),
m_IsInPrivateDo(false)
{ {
// Don't call Init from the constructor, since it calls a virtual method ! // Don't call Init from the constructor, since it calls a virtual method !
m_Logger->SetName("Application.logger"); m_Logger->SetName("Application.logger");
...@@ -304,7 +305,14 @@ void Application::SetParameterUserValue(std::string paramKey, bool value) ...@@ -304,7 +305,14 @@ void Application::SetParameterUserValue(std::string paramKey, bool value)
using Application::EnableParameter(); using Application::EnableParameter();
**/ **/
EnableParameter(paramKey); EnableParameter(paramKey);
GetParameterByKey(paramKey)->SetUserValue(value); if (m_IsInPrivateDo)
{
GetParameterByKey(paramKey)->SetUserValue(false);
}
else
{
GetParameterByKey(paramKey)->SetUserValue(value);
}
} }
const Parameter* Application::GetParameterByKey(std::string name, bool follow) const const Parameter* Application::GetParameterByKey(std::string name, bool follow) const
...@@ -320,7 +328,9 @@ void Application::Init() ...@@ -320,7 +328,9 @@ void Application::Init()
m_ParameterList = ParameterGroup::New(); m_ParameterList = ParameterGroup::New();
//reset inXML parse checker in case if reinit-ing //reset inXML parse checker in case if reinit-ing
m_IsInXMLParsed = false; m_IsInXMLParsed = false;
m_IsInPrivateDo = true;
this->DoInit(); this->DoInit();
m_IsInPrivateDo = false;
//rashad: global parameters. now used only for inxml and outxml //rashad: global parameters. now used only for inxml and outxml
if(this->GetHaveInXML()) if(this->GetHaveInXML())
...@@ -352,7 +362,9 @@ void Application::UpdateParameters() ...@@ -352,7 +362,9 @@ void Application::UpdateParameters()
} }
} }
} }
m_IsInPrivateDo = true;
this->DoUpdateParameters(); this->DoUpdateParameters();
m_IsInPrivateDo = false;
} }
void Application::AfterExecuteAndWriteOutputs() void Application::AfterExecuteAndWriteOutputs()
...@@ -387,7 +399,9 @@ int Application::Execute() ...@@ -387,7 +399,9 @@ int Application::Execute()
itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->Initialize(); itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->Initialize();
} }
m_IsInPrivateDo = true;
this->DoExecute(); this->DoExecute();
m_IsInPrivateDo = false;
// Ensure that all output image parameter have called UpdateOutputInformation() // Ensure that all output image parameter have called UpdateOutputInformation()
for (auto it = paramList.begin(); it != paramList.end(); ++it) for (auto it = paramList.begin(); it != paramList.end(); ++it)
......
Supports Markdown
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