From 9b86bf357340f84e2d9c023166e389eb6b39f4de Mon Sep 17 00:00:00 2001 From: Charl Wentzel Date: Mon, 17 Jul 2017 07:18:52 +0200 Subject: [PATCH] Important Update: - CApplicationCore: - Run() returns false if error on any Process() call - Add TerminateOnError param to Run() method, - if set, exit immediately if Process() on any process fails - if not set, exit after Process() on all processes - Remove "Terminating..." log --- ApplicationCore.cpp | 19 +++++++++++++------ ApplicationCore.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ApplicationCore.cpp b/ApplicationCore.cpp index a742e22..f0b0911 100644 --- a/ApplicationCore.cpp +++ b/ApplicationCore.cpp @@ -58,9 +58,6 @@ CApplication::~CApplication() if (FirstFunction) { - // Show Start of termination - if (Log) Log->Message( dlLow, dlLow, "%s: Terminating...", ProcessName ); - // Destroy functions while (FirstFunction) { @@ -353,8 +350,9 @@ CFunctionCore * CApplication::GetFunction( const char * Name ) } //--------------------------------------------------------------------------- -bool CApplication::Run() +bool CApplication::Run( bool TerminateOnError ) { + bool AllGood = true; TFunctionItem * FunctionItem; // Check for FD Events/States @@ -364,7 +362,16 @@ bool CApplication::Run() // Process Functions for (FunctionItem = FirstFunction; FunctionItem; FunctionItem = FunctionItem->Next ) - FunctionItem->Function->Process(); - return true; + { + if (!FunctionItem->Function->Process()) + { + if (TerminateOnError) + return false; + else { + AllGood = false; + } + } + } + return AllGood; } //--------------------------------------------------------------------------- diff --git a/ApplicationCore.h b/ApplicationCore.h index e3fd492..0702b05 100644 --- a/ApplicationCore.h +++ b/ApplicationCore.h @@ -92,7 +92,7 @@ public: CFunctionCore * GetFunction( const char * Name ); // Run Application - bool Run(); + bool Run( bool TerminateOnError ); }; //---------------------------------------------------------------------------