Commit 6cefe7c51a657330827ed286f263a361bd440371

Authored by Jürgen Knödlseder
1 parent 55989652

Catch exception during ctools construction.

So far any exception occuring during the construction of the ctools were not catched. This is corrected now.
src/ctbin/main.cpp
1 1 /***************************************************************************
2   - * ctbin - CTA data binning main code *
  2 + * ctbin - CTA binning tool main code *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2011 by Jurgen Knodlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -21,7 +21,7 @@
21 21 /**
22 22 * @file ctbin/main.cpp
23 23 * @brief CTA data binning tool main code
24   - * @author J. Knodlseder
  24 + * @author Juergen Knoedlseder
25 25 */
26 26  
27 27 /* __ Includes ___________________________________________________________ */
... ... @@ -38,21 +38,30 @@
38 38 * @param[in] argc Number of command line arguments.
39 39 * @param[in] argv Command line arguments.
40 40 *
41   - * This is the main entry point of the gtbin application. It allocates a
42   - * ctbin object and runs the application.
  41 + * This is the main entry point of the ctbin application. It allocates a
  42 + * ctbin object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctbin application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctbin* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctbin(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctbin. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctbin. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctbkgcube/main.cpp
1 1 /***************************************************************************
2 2 * ctbkgcube - CTA background cube tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2016 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Command line arguments.
40 40 *
41 41 * This is the main entry point of the ctbkgcube application. It allocates a
42   - * ctbkgcube object and runs the application.
  42 + * ctbkgcube object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctbkgcube application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctbkgcube* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctbkgcube(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctbkgcube. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctbkgcube. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctbutterfly/main.cpp
1 1 /***************************************************************************
2 2 * ctbutterfly - TS map calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Michael Mayer *
  4 + * copyright (C) 2014-2016 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -38,21 +38,30 @@
38 38 * @param[in] argc Number of command line arguments.
39 39 * @param[in] argv Command line arguments.
40 40 *
41   - * This is the main entry point of the ctbutterfly application. It allocates a
42   - * ctbutterfly object and runs the application.
  41 + * This is the main entry point of the ctbutterfly application. It allocates
  42 + * a ctbutterfly object and executes the application. Any exceptions that
  43 + * occur will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctbutterfly application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctbutterfly* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctbutterfly(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctbutterfly. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctbutterfly. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctcubemask/main.cpp
1 1 /***************************************************************************
2 2 * ctcubemask - CTA mask cube tool main code *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 Chia-Chun Lu *
  4 + * copyright (C) 2014-2016 Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -37,19 +37,31 @@
37 37 *
38 38 * @param[in] argc Number of arguments
39 39 * @param[in] argv Arguments
  40 + *
  41 + * This is the main entry point of the ctcubemask application. It allocates
  42 + * a ctcubemask object and executes the application. Any exceptions that
  43 + * occur will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
40 45 ***************************************************************************/
41 46 int main (int argc, char *argv[])
42 47 {
43 48 // Initialise return code
44 49 int rc = 1;
45 50  
46   - // Create instance of application
47   - ctcubemask application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctcubemask* application = NULL;
48 53  
49   - // Run application
  54 + // Execute application
50 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctcubemask(argc, argv);
  59 +
51 60 // Execute application
52   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
53 65  
54 66 // Signal success
55 67 rc = 0;
... ... @@ -58,12 +70,16 @@ int main (int argc, char *argv[])
58 70  
59 71 // Extract error message
60 72 std::string message = e.what();
61   - std::string signal = "*** ERROR encounterted in the execution of"
62   - " ctcubemask. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctcubemask. Run aborted ...";
63 75  
64   - // Write error in logger
65   - application.log << message << std::endl;
66   - application.log << signal << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
67 83  
68 84 // Write error on standard output
69 85 std::cout << message << std::endl;
... ...
src/ctedispcube/main.cpp
... ... @@ -38,21 +38,30 @@
38 38 * @param[in] argc Number of command line arguments.
39 39 * @param[in] argv Command line arguments.
40 40 *
41   - * This is the main entry point of the ctedispcube application. It allocates a
42   - * ctedispcube object and runs the application.
  41 + * This is the main entry point of the ctedispcube application. It allocates
  42 + * a ctedispcube object and executes the application. Any exceptions that
  43 + * occur will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctedispcube application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctedispcube* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctedispcube(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctedispcube. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctedispcube. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/cterror/main.cpp
1 1 /***************************************************************************
2 2 * cterror - Parameter error calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015 by Florent Forest *
  4 + * copyright (C) 2015-2016 by Florent Forest *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Command line arguments.
40 40 *
41 41 * This is the main entry point of the cterror application. It allocates a
42   - * cterror object and runs the application.
  42 + * cterror object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - cterror application(argc, argv);
  51 + // Initialise pointer on application
  52 + cterror* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new cterror(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " cterror. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "cterror. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctexpcube/main.cpp
1 1 /***************************************************************************
2 2 * ctexpcube - CTA exposure cube tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2014-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Command line arguments.
40 40 *
41 41 * This is the main entry point of the ctexpcube application. It allocates a
42   - * ctexpcube object and runs the application.
  42 + * ctexpcube object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctexpcube application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctexpcube* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctexpcube(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctexpcube. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctexpcube. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctlike/main.cpp
1 1 /***************************************************************************
2 2 * ctlike - CTA maximum likelihood tool main code *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2011 by Jurgen Knodlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -21,7 +21,7 @@
21 21 /**
22 22 * @file ctlike/main.cpp
23 23 * @brief CTA maximum likelihood tool main code
24   - * @author J. Knodlseder
  24 + * @author Juergen Knoedlseder
25 25 */
26 26  
27 27 /* __ Includes ___________________________________________________________ */
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Arguments
40 40 *
41 41 * This is the main entry point of the ctlike application. It allocates a
42   - * ctlike object and executes the application.
  42 + * ctlike object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctlike application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctlike* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctlike(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctlike. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctlike. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctmapcube/main.cpp
... ... @@ -38,21 +38,30 @@
38 38 * @param[in] argc Number of command line arguments.
39 39 * @param[in] argv Command line arguments.
40 40 *
41   - * This is the main entry point of the gtbin application. It allocates a
42   - * ctmapcube object and runs the application.
  41 + * This is the main entry point of the ctmapcube application. It allocates a
  42 + * ctmapcube object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctmapcube application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctmapcube* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctmapcube(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctmapcube. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctmapcube. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctmodel/main.cpp
1 1 /***************************************************************************
2 2 * ctmodel - CTA counts model tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -38,21 +38,30 @@
38 38 * @param[in] argc Number of command line arguments.
39 39 * @param[in] argv Command line arguments.
40 40 *
41   - * This is the main entry point of the gtbin application. It allocates a
42   - * ctmodel object and runs the application.
  41 + * This is the main entry point of the ctmodel application. It allocates a
  42 + * ctmodel object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctmodel application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctmodel* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctmodel(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,13 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctmodel. Run aborted ...";
66   -
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctmodel. Run aborted ...";
70 75  
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
71 83 // Write error on standard output
72 84 std::cout << signal << std::endl;
73 85 std::cout << message << std::endl;
... ...
src/ctobssim/main.cpp
1 1 /***************************************************************************
2 2 * ctobssim - CTA observation simulator tool main code *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2011-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2011-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -37,19 +37,31 @@
37 37 *
38 38 * @param[in] argc Number of arguments.
39 39 * @param[in] argv Arguments.
  40 + *
  41 + * This is the main entry point of the ctobssim application. It allocates a
  42 + * ctobssim object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
40 45 ***************************************************************************/
41 46 int main (int argc, char *argv[])
42 47 {
43 48 // Initialise return code
44 49 int rc = 1;
45 50  
46   - // Create instance of application
47   - ctobssim application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctobssim* application = NULL;
48 53  
49   - // Run application
  54 + // Execute application
50 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctobssim(argc, argv);
  59 +
51 60 // Execute application
52   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
53 65  
54 66 // Signal success
55 67 rc = 0;
... ... @@ -58,12 +70,16 @@ int main (int argc, char *argv[])
58 70  
59 71 // Extract error message
60 72 std::string message = e.what();
61   - std::string signal = "*** ERROR encounterted in the execution of"
62   - " ctobssim. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctobssim. Run aborted ...";
63 75  
64   - // Write error in logger
65   - application.log << signal << std::endl;
66   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
67 83  
68 84 // Write error on standard output
69 85 std::cout << signal << std::endl;
... ...
src/ctpsfcube/main.cpp
1 1 /***************************************************************************
2 2 * ctpsfcube - CTA PSF cube tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Chia-Chun Lu *
  4 + * copyright (C) 2014-2016 by Chia-Chun Lu *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Command line arguments.
40 40 *
41 41 * This is the main entry point of the ctpsfcube application. It allocates a
42   - * ctpsfcube object and runs the application.
  42 + * ctpsfcube object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctpsfcube application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctpsfcube* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctpsfcube(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctpsfcube. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctpsfcube. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctselect/main.cpp
1 1 /***************************************************************************
2 2 * ctselect - CTA data selection tool main code *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -37,19 +37,31 @@
37 37 *
38 38 * @param[in] argc Number of arguments
39 39 * @param[in] argv Arguments
  40 + *
  41 + * This is the main entry point of the ctselect application. It allocates a
  42 + * ctselect object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
40 45 ***************************************************************************/
41 46 int main (int argc, char *argv[])
42 47 {
43 48 // Initialise return code
44 49 int rc = 1;
45 50  
46   - // Create instance of application
47   - ctselect application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctselect* application = NULL;
48 53  
49   - // Run application
  54 + // Execute application
50 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctselect(argc, argv);
  59 +
51 60 // Execute application
52   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
53 65  
54 66 // Signal success
55 67 rc = 0;
... ... @@ -58,12 +70,16 @@ int main (int argc, char *argv[])
58 70  
59 71 // Extract error message
60 72 std::string message = e.what();
61   - std::string signal = "*** ERROR encounterted in the execution of"
62   - " ctselect. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctselect. Run aborted ...";
63 75  
64   - // Write error in logger
65   - application.log << message << std::endl;
66   - application.log << signal << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
67 83  
68 84 // Write error on standard output
69 85 std::cout << message << std::endl;
... ...
src/ctskymap/main.cpp
1 1 /***************************************************************************
2 2 * ctskymap - CTA sky mapping main code *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2010-2013 by Juergen Knoedlseder *
  4 + * copyright (C) 2010-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Command line arguments.
40 40 *
41 41 * This is the main entry point of the ctskymap application. It allocates a
42   - * ctskymap object and runs the application.
  42 + * ctskymap object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - ctskymap application(argc, argv);
  51 + // Initialise pointer on application
  52 + ctskymap* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctskymap(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctskymap. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "ctskymap. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/cttsmap/main.cpp
1 1 /***************************************************************************
2 2 * cttsmap - TS map calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2014 by Michael Mayer *
  4 + * copyright (C) 2014-2016 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -39,20 +39,29 @@
39 39 * @param[in] argv Command line arguments.
40 40 *
41 41 * This is the main entry point of the cttsmap application. It allocates a
42   - * cttsmap object and runs the application.
  42 + * cttsmap object and executes the application. Any exceptions that occur
  43 + * will be catched and corresponding error messages written in the
  44 + * application logger and on the standard output.
43 45 ***************************************************************************/
44 46 int main (int argc, char *argv[])
45 47 {
46 48 // Initialise return code
47 49 int rc = 1;
48 50  
49   - // Create instance of application
50   - cttsmap application(argc, argv);
  51 + // Initialise pointer on application
  52 + cttsmap* application = NULL;
51 53  
52   - // Run application
  54 + // Execute application
53 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new cttsmap(argc, argv);
  59 +
54 60 // Execute application
55   - application.execute();
  61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65  
57 66 // Signal success
58 67 rc = 0;
... ... @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70  
62 71 // Extract error message
63 72 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " cttsmap. Run aborted ...";
  73 + std::string signal = "*** ERROR encounterted in the execution of "
  74 + "cttsmap. Run aborted ...";
66 75  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  76 + // If application exists then write error in logger and delete
  77 + // application
  78 + if (application != NULL) {
  79 + application->log << signal << std::endl;
  80 + application->log << message << std::endl;
  81 + delete application;
  82 + }
70 83  
71 84 // Write error on standard output
72 85 std::cout << signal << std::endl;
... ...
src/ctulimit/main.cpp
1 1 /***************************************************************************
2 2 * ctulimit - upper limit calculation tool *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015 by Michael Mayer *
  4 + * copyright (C) 2015-2016 by Michael Mayer *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -46,13 +46,20 @@ int main (int argc, char *argv[])
46 46 // Initialise return code
47 47 int rc = 1;
48 48  
49   - // Create instance of application
50   - ctulimit application(argc, argv);
  49 + // Initialise pointer on application
  50 + ctulimit* application = NULL;
51 51  
52   - // Run application
  52 + // Execute application
53 53 try {
  54 +
  55 + // Create instance of application
  56 + application = new ctulimit(argc, argv);
  57 +
54 58 // Execute application
55   - application.execute();
  59 + application->execute();
  60 +
  61 + // Delete application
  62 + delete application;
56 63  
57 64 // Signal success
58 65 rc = 0;
... ... @@ -61,12 +68,16 @@ int main (int argc, char *argv[])
61 68  
62 69 // Extract error message
63 70 std::string message = e.what();
64   - std::string signal = "*** ERROR encounterted in the execution of"
65   - " ctulimit. Run aborted ...";
  71 + std::string signal = "*** ERROR encounterted in the execution of "
  72 + "ctulimit. Run aborted ...";
66 73  
67   - // Write error in logger
68   - application.log << signal << std::endl;
69   - application.log << message << std::endl;
  74 + // If application exists then write error in logger and delete
  75 + // application
  76 + if (application != NULL) {
  77 + application->log << signal << std::endl;
  78 + application->log << message << std::endl;
  79 + delete application;
  80 + }
70 81  
71 82 // Write error on standard output
72 83 std::cout << signal << std::endl;
... ...