From 6cefe7c51a657330827ed286f263a361bd440371 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 13 Aug 2016 21:18:42 +0200 Subject: [PATCH] Catch exception during ctools construction. --- src/ctbin/main.cpp | 41 +++++++++++++++++++++++++++-------------- src/ctbkgcube/main.cpp | 35 ++++++++++++++++++++++++----------- src/ctbutterfly/main.cpp | 37 +++++++++++++++++++++++++------------ src/ctcubemask/main.cpp | 36 ++++++++++++++++++++++++++---------- src/ctedispcube/main.cpp | 35 ++++++++++++++++++++++++----------- src/cterror/main.cpp | 35 ++++++++++++++++++++++++----------- src/ctexpcube/main.cpp | 35 ++++++++++++++++++++++++----------- src/ctlike/main.cpp | 37 +++++++++++++++++++++++++------------ src/ctmapcube/main.cpp | 35 ++++++++++++++++++++++++----------- src/ctmodel/main.cpp | 38 +++++++++++++++++++++++++------------- src/ctobssim/main.cpp | 36 ++++++++++++++++++++++++++---------- src/ctpsfcube/main.cpp | 35 ++++++++++++++++++++++++----------- src/ctselect/main.cpp | 36 ++++++++++++++++++++++++++---------- src/ctskymap/main.cpp | 35 ++++++++++++++++++++++++----------- src/cttsmap/main.cpp | 35 ++++++++++++++++++++++++----------- src/ctulimit/main.cpp | 31 +++++++++++++++++++++---------- 16 files changed, 393 insertions(+), 179 deletions(-) diff --git a/src/ctbin/main.cpp b/src/ctbin/main.cpp index 4e1da8c..89b3418 100644 --- a/src/ctbin/main.cpp +++ b/src/ctbin/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** - * ctbin - CTA data binning main code * + * ctbin - CTA binning tool main code * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2011 by Jurgen Knodlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -21,7 +21,7 @@ /** * @file ctbin/main.cpp * @brief CTA data binning tool main code - * @author J. Knodlseder + * @author Juergen Knoedlseder */ /* __ Includes ___________________________________________________________ */ @@ -38,21 +38,30 @@ * @param[in] argc Number of command line arguments. * @param[in] argv Command line arguments. * - * This is the main entry point of the gtbin application. It allocates a - * ctbin object and runs the application. + * This is the main entry point of the ctbin application. It allocates a + * ctbin object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctbin application(argc, argv); + // Initialise pointer on application + ctbin* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctbin(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctbin. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctbin. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctbkgcube/main.cpp b/src/ctbkgcube/main.cpp index 93c4277..bd1e749 100644 --- a/src/ctbkgcube/main.cpp +++ b/src/ctbkgcube/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbkgcube - CTA background cube tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,20 +39,29 @@ * @param[in] argv Command line arguments. * * This is the main entry point of the ctbkgcube application. It allocates a - * ctbkgcube object and runs the application. + * ctbkgcube object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctbkgcube application(argc, argv); + // Initialise pointer on application + ctbkgcube* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctbkgcube(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctbkgcube. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctbkgcube. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctbutterfly/main.cpp b/src/ctbutterfly/main.cpp index 920caa1..803ffd5 100644 --- a/src/ctbutterfly/main.cpp +++ b/src/ctbutterfly/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctbutterfly - TS map calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -38,21 +38,30 @@ * @param[in] argc Number of command line arguments. * @param[in] argv Command line arguments. * - * This is the main entry point of the ctbutterfly application. It allocates a - * ctbutterfly object and runs the application. + * This is the main entry point of the ctbutterfly application. It allocates + * a ctbutterfly object and executes the application. Any exceptions that + * occur will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctbutterfly application(argc, argv); + // Initialise pointer on application + ctbutterfly* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctbutterfly(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctbutterfly. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctbutterfly. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctcubemask/main.cpp b/src/ctcubemask/main.cpp index ed6b6b4..a265732 100644 --- a/src/ctcubemask/main.cpp +++ b/src/ctcubemask/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctcubemask - CTA mask cube tool main code * * ----------------------------------------------------------------------- * - * copyright (C) 2014 Chia-Chun Lu * + * copyright (C) 2014-2016 Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -37,19 +37,31 @@ * * @param[in] argc Number of arguments * @param[in] argv Arguments + * + * This is the main entry point of the ctcubemask application. It allocates + * a ctcubemask object and executes the application. Any exceptions that + * occur will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctcubemask application(argc, argv); + // Initialise pointer on application + ctcubemask* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctcubemask(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -58,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctcubemask. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctcubemask. Run aborted ..."; - // Write error in logger - application.log << message << std::endl; - application.log << signal << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << message << std::endl; diff --git a/src/ctedispcube/main.cpp b/src/ctedispcube/main.cpp index 0a11700..fab8d44 100644 --- a/src/ctedispcube/main.cpp +++ b/src/ctedispcube/main.cpp @@ -38,21 +38,30 @@ * @param[in] argc Number of command line arguments. * @param[in] argv Command line arguments. * - * This is the main entry point of the ctedispcube application. It allocates a - * ctedispcube object and runs the application. + * This is the main entry point of the ctedispcube application. It allocates + * a ctedispcube object and executes the application. Any exceptions that + * occur will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctedispcube application(argc, argv); + // Initialise pointer on application + ctedispcube* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctedispcube(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctedispcube. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctedispcube. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/cterror/main.cpp b/src/cterror/main.cpp index be6435a..a9246f8 100644 --- a/src/cterror/main.cpp +++ b/src/cterror/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * cterror - Parameter error calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2015 by Florent Forest * + * copyright (C) 2015-2016 by Florent Forest * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,20 +39,29 @@ * @param[in] argv Command line arguments. * * This is the main entry point of the cterror application. It allocates a - * cterror object and runs the application. + * cterror object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - cterror application(argc, argv); + // Initialise pointer on application + cterror* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new cterror(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " cterror. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "cterror. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctexpcube/main.cpp b/src/ctexpcube/main.cpp index d34d230..58f7d8a 100644 --- a/src/ctexpcube/main.cpp +++ b/src/ctexpcube/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctexpcube - CTA exposure cube tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Juergen Knoedlseder * + * copyright (C) 2014-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,20 +39,29 @@ * @param[in] argv Command line arguments. * * This is the main entry point of the ctexpcube application. It allocates a - * ctexpcube object and runs the application. + * ctexpcube object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctexpcube application(argc, argv); + // Initialise pointer on application + ctexpcube* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctexpcube(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctexpcube. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctexpcube. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctlike/main.cpp b/src/ctlike/main.cpp index 70cd2ea..22c7375 100644 --- a/src/ctlike/main.cpp +++ b/src/ctlike/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctlike - CTA maximum likelihood tool main code * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2011 by Jurgen Knodlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -21,7 +21,7 @@ /** * @file ctlike/main.cpp * @brief CTA maximum likelihood tool main code - * @author J. Knodlseder + * @author Juergen Knoedlseder */ /* __ Includes ___________________________________________________________ */ @@ -39,20 +39,29 @@ * @param[in] argv Arguments * * This is the main entry point of the ctlike application. It allocates a - * ctlike object and executes the application. + * ctlike object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctlike application(argc, argv); + // Initialise pointer on application + ctlike* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctlike(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctlike. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctlike. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctmapcube/main.cpp b/src/ctmapcube/main.cpp index ad9412b..f5b03f3 100644 --- a/src/ctmapcube/main.cpp +++ b/src/ctmapcube/main.cpp @@ -38,21 +38,30 @@ * @param[in] argc Number of command line arguments. * @param[in] argv Command line arguments. * - * This is the main entry point of the gtbin application. It allocates a - * ctmapcube object and runs the application. + * This is the main entry point of the ctmapcube application. It allocates a + * ctmapcube object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctmapcube application(argc, argv); + // Initialise pointer on application + ctmapcube* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctmapcube(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctmapcube. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctmapcube. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctmodel/main.cpp b/src/ctmodel/main.cpp index 6a7fafa..9e929cc 100644 --- a/src/ctmodel/main.cpp +++ b/src/ctmodel/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctmodel - CTA counts model tool * * ----------------------------------------------------------------------- * - * copyright (C) 2012 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -38,21 +38,30 @@ * @param[in] argc Number of command line arguments. * @param[in] argv Command line arguments. * - * This is the main entry point of the gtbin application. It allocates a - * ctmodel object and runs the application. + * This is the main entry point of the ctmodel application. It allocates a + * ctmodel object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctmodel application(argc, argv); + // Initialise pointer on application + ctmodel* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctmodel(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,13 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctmodel. Run aborted ..."; - - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + std::string signal = "*** ERROR encounterted in the execution of " + "ctmodel. Run aborted ..."; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; std::cout << message << std::endl; diff --git a/src/ctobssim/main.cpp b/src/ctobssim/main.cpp index f2ba206..0ed8426 100644 --- a/src/ctobssim/main.cpp +++ b/src/ctobssim/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctobssim - CTA observation simulator tool main code * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2013 by Juergen Knoedlseder * + * copyright (C) 2011-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -37,19 +37,31 @@ * * @param[in] argc Number of arguments. * @param[in] argv Arguments. + * + * This is the main entry point of the ctobssim application. It allocates a + * ctobssim object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctobssim application(argc, argv); + // Initialise pointer on application + ctobssim* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctobssim(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -58,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctobssim. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctobssim. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctpsfcube/main.cpp b/src/ctpsfcube/main.cpp index bd50b4f..5dd9836 100644 --- a/src/ctpsfcube/main.cpp +++ b/src/ctpsfcube/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctpsfcube - CTA PSF cube tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Chia-Chun Lu * + * copyright (C) 2014-2016 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,20 +39,29 @@ * @param[in] argv Command line arguments. * * This is the main entry point of the ctpsfcube application. It allocates a - * ctpsfcube object and runs the application. + * ctpsfcube object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctpsfcube application(argc, argv); + // Initialise pointer on application + ctpsfcube* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctpsfcube(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctpsfcube. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctpsfcube. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctselect/main.cpp b/src/ctselect/main.cpp index de41de3..9b0170e 100644 --- a/src/ctselect/main.cpp +++ b/src/ctselect/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctselect - CTA data selection tool main code * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2013 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -37,19 +37,31 @@ * * @param[in] argc Number of arguments * @param[in] argv Arguments + * + * This is the main entry point of the ctselect application. It allocates a + * ctselect object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctselect application(argc, argv); + // Initialise pointer on application + ctselect* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctselect(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -58,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctselect. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctselect. Run aborted ..."; - // Write error in logger - application.log << message << std::endl; - application.log << signal << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << message << std::endl; diff --git a/src/ctskymap/main.cpp b/src/ctskymap/main.cpp index 0ca50bd..09a1516 100644 --- a/src/ctskymap/main.cpp +++ b/src/ctskymap/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctskymap - CTA sky mapping main code * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2013 by Juergen Knoedlseder * + * copyright (C) 2010-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,20 +39,29 @@ * @param[in] argv Command line arguments. * * This is the main entry point of the ctskymap application. It allocates a - * ctskymap object and runs the application. + * ctskymap object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - ctskymap application(argc, argv); + // Initialise pointer on application + ctskymap* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctskymap(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctskymap. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctskymap. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/cttsmap/main.cpp b/src/cttsmap/main.cpp index 2d3bdbd..5dad9ec 100644 --- a/src/cttsmap/main.cpp +++ b/src/cttsmap/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * cttsmap - TS map calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2014 by Michael Mayer * + * copyright (C) 2014-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,20 +39,29 @@ * @param[in] argv Command line arguments. * * This is the main entry point of the cttsmap application. It allocates a - * cttsmap object and runs the application. + * cttsmap object and executes the application. Any exceptions that occur + * will be catched and corresponding error messages written in the + * application logger and on the standard output. ***************************************************************************/ int main (int argc, char *argv[]) { // Initialise return code int rc = 1; - // Create instance of application - cttsmap application(argc, argv); + // Initialise pointer on application + cttsmap* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new cttsmap(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +70,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " cttsmap. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "cttsmap. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; diff --git a/src/ctulimit/main.cpp b/src/ctulimit/main.cpp index 0afef65..3a33aa2 100644 --- a/src/ctulimit/main.cpp +++ b/src/ctulimit/main.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * ctulimit - upper limit calculation tool * * ----------------------------------------------------------------------- * - * copyright (C) 2015 by Michael Mayer * + * copyright (C) 2015-2016 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -46,13 +46,20 @@ int main (int argc, char *argv[]) // Initialise return code int rc = 1; - // Create instance of application - ctulimit application(argc, argv); + // Initialise pointer on application + ctulimit* application = NULL; - // Run application + // Execute application try { + + // Create instance of application + application = new ctulimit(argc, argv); + // Execute application - application.execute(); + application->execute(); + + // Delete application + delete application; // Signal success rc = 0; @@ -61,12 +68,16 @@ int main (int argc, char *argv[]) // Extract error message std::string message = e.what(); - std::string signal = "*** ERROR encounterted in the execution of" - " ctulimit. Run aborted ..."; + std::string signal = "*** ERROR encounterted in the execution of " + "ctulimit. Run aborted ..."; - // Write error in logger - application.log << signal << std::endl; - application.log << message << std::endl; + // If application exists then write error in logger and delete + // application + if (application != NULL) { + application->log << signal << std::endl; + application->log << message << std::endl; + delete application; + } // Write error on standard output std::cout << signal << std::endl; -- libgit2 0.21.4