X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkFilterBase.cxx;h=09797d886c750959c84dfa4e6a4db0eb236563e4;hb=411da8daffce1e4ce2591df35b4fdd569354089b;hp=07b992512ce009257dedfdc7ae4640a9cce0a42c;hpb=868922dc773690f1be8f21159f10fc4702e5c09f;p=clitk.git diff --git a/common/clitkFilterBase.cxx b/common/clitkFilterBase.cxx index 07b9925..09797d8 100644 --- a/common/clitkFilterBase.cxx +++ b/common/clitkFilterBase.cxx @@ -18,38 +18,17 @@ // clitk #include "clitkFilterBase.h" +#include "clitkCommon.h" //-------------------------------------------------------------------- clitk::FilterBase::FilterBase() { - SetMustStop(false); SetVerboseOption(false); SetCurrentStepNumber(0); SetCurrentStepBaseId(""); - StopOnErrorOn(); - ResetLastError(); VerboseWarningOffOn(); // OffOn, it's cool no ? SetWarning(""); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::FilterBase::ResetLastError() -{ - m_LastError = ""; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::FilterBase::SetLastError(std::string e) -{ - m_LastError = e; - if (GetStopOnError()) { - std::cerr << GetLastError() << std::endl; - exit(0); - } + m_IsCancelled = false; } //-------------------------------------------------------------------- @@ -68,8 +47,10 @@ void clitk::FilterBase::SetWarning(std::string e) //-------------------------------------------------------------------- void clitk::FilterBase::StartNewStep(std::string s) { - //m_CurrentStepTimer.Reset(); - // m_CurrentStepTimer.Start(); + if (Cancelled()) { + throw clitk::ExceptionObject("Filter is canceled."); + } + m_CurrentStepNumber++; if (GetCurrentStepBaseId() != "") { std::ostringstream oss; @@ -94,33 +75,23 @@ void clitk::FilterBase::StartNewStep(std::string s) //-------------------------------------------------------------------- void clitk::FilterBase::StopCurrentStep() { - // m_CurrentStepTimer.Stop(); - // m_CurrentStepTimer.Print(std::cout); - // std::ostringstream oss; - //oss << " (" << - // m_CurrentStepName = m_CurrentStepName +" + } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void clitk::FilterBase::SetMustStop(bool b) +void clitk::FilterBase::Cancel() { - m_MustStop = b; - if (GetMustStop()) { - SetLastError("Filter is interrupted."); - } + m_IsCancelled = true; } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -bool clitk::FilterBase::GetMustStop() -{ - if (m_MustStop) return true; - if (HasError()) return true; - return false; -} + bool clitk::FilterBase::Cancelled() + { + return m_IsCancelled; + } //-------------------------------------------------------------------- -