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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 /** 21 /**
22 * @file ctbin/main.cpp 22 * @file ctbin/main.cpp
23 * @brief CTA data binning tool main code 23 * @brief CTA data binning tool main code
24 - * @author J. Knodlseder 24 + * @author Juergen Knoedlseder
25 */ 25 */
26 26
27 /* __ Includes ___________________________________________________________ */ 27 /* __ Includes ___________________________________________________________ */
@@ -38,21 +38,30 @@ @@ -38,21 +38,30 @@
38 * @param[in] argc Number of command line arguments. 38 * @param[in] argc Number of command line arguments.
39 * @param[in] argv Command line arguments. 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctbin(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctbkgcube/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctbkgcube - CTA background cube tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Command line arguments. 39 * @param[in] argv Command line arguments.
40 * 40 *
41 * This is the main entry point of the ctbkgcube application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctbkgcube(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctbutterfly/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctbutterfly - TS map calculation tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -38,21 +38,30 @@ @@ -38,21 +38,30 @@
38 * @param[in] argc Number of command line arguments. 38 * @param[in] argc Number of command line arguments.
39 * @param[in] argv Command line arguments. 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctbutterfly(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctcubemask/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctcubemask - CTA mask cube tool main code * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -37,19 +37,31 @@ @@ -37,19 +37,31 @@
37 * 37 *
38 * @param[in] argc Number of arguments 38 * @param[in] argc Number of arguments
39 * @param[in] argv Arguments 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
42 { 47 {
43 // Initialise return code 48 // Initialise return code
44 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctcubemask(argc, argv);
  59 +
51 // Execute application 60 // Execute application
52 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
53 65
54 // Signal success 66 // Signal success
55 rc = 0; 67 rc = 0;
@@ -58,12 +70,16 @@ int main (int argc, char *argv[]) @@ -58,12 +70,16 @@ int main (int argc, char *argv[])
58 70
59 // Extract error message 71 // Extract error message
60 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
69 std::cout << message << std::endl; 85 std::cout << message << std::endl;
src/ctedispcube/main.cpp
@@ -38,21 +38,30 @@ @@ -38,21 +38,30 @@
38 * @param[in] argc Number of command line arguments. 38 * @param[in] argc Number of command line arguments.
39 * @param[in] argv Command line arguments. 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctedispcube(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/cterror/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * cterror - Parameter error calculation tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Command line arguments. 39 * @param[in] argv Command line arguments.
40 * 40 *
41 * This is the main entry point of the cterror application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new cterror(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctexpcube/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctexpcube - CTA exposure cube tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Command line arguments. 39 * @param[in] argv Command line arguments.
40 * 40 *
41 * This is the main entry point of the ctexpcube application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctexpcube(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctlike/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctlike - CTA maximum likelihood tool main code * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 /** 21 /**
22 * @file ctlike/main.cpp 22 * @file ctlike/main.cpp
23 * @brief CTA maximum likelihood tool main code 23 * @brief CTA maximum likelihood tool main code
24 - * @author J. Knodlseder 24 + * @author Juergen Knoedlseder
25 */ 25 */
26 26
27 /* __ Includes ___________________________________________________________ */ 27 /* __ Includes ___________________________________________________________ */
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Arguments 39 * @param[in] argv Arguments
40 * 40 *
41 * This is the main entry point of the ctlike application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctlike(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctmapcube/main.cpp
@@ -38,21 +38,30 @@ @@ -38,21 +38,30 @@
38 * @param[in] argc Number of command line arguments. 38 * @param[in] argc Number of command line arguments.
39 * @param[in] argv Command line arguments. 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctmapcube(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctmodel/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctmodel - CTA counts model tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -38,21 +38,30 @@ @@ -38,21 +38,30 @@
38 * @param[in] argc Number of command line arguments. 38 * @param[in] argc Number of command line arguments.
39 * @param[in] argv Command line arguments. 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctmodel(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,13 +70,16 @@ int main (int argc, char *argv[]) @@ -61,13 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 83 // Write error on standard output
72 std::cout << signal << std::endl; 84 std::cout << signal << std::endl;
73 std::cout << message << std::endl; 85 std::cout << message << std::endl;
src/ctobssim/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctobssim - CTA observation simulator tool main code * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -37,19 +37,31 @@ @@ -37,19 +37,31 @@
37 * 37 *
38 * @param[in] argc Number of arguments. 38 * @param[in] argc Number of arguments.
39 * @param[in] argv Arguments. 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
42 { 47 {
43 // Initialise return code 48 // Initialise return code
44 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctobssim(argc, argv);
  59 +
51 // Execute application 60 // Execute application
52 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
53 65
54 // Signal success 66 // Signal success
55 rc = 0; 67 rc = 0;
@@ -58,12 +70,16 @@ int main (int argc, char *argv[]) @@ -58,12 +70,16 @@ int main (int argc, char *argv[])
58 70
59 // Extract error message 71 // Extract error message
60 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
69 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctpsfcube/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctpsfcube - CTA PSF cube tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Command line arguments. 39 * @param[in] argv Command line arguments.
40 * 40 *
41 * This is the main entry point of the ctpsfcube application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctpsfcube(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctselect/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctselect - CTA data selection tool main code * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -37,19 +37,31 @@ @@ -37,19 +37,31 @@
37 * 37 *
38 * @param[in] argc Number of arguments 38 * @param[in] argc Number of arguments
39 * @param[in] argv Arguments 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
42 { 47 {
43 // Initialise return code 48 // Initialise return code
44 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctselect(argc, argv);
  59 +
51 // Execute application 60 // Execute application
52 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
53 65
54 // Signal success 66 // Signal success
55 rc = 0; 67 rc = 0;
@@ -58,12 +70,16 @@ int main (int argc, char *argv[]) @@ -58,12 +70,16 @@ int main (int argc, char *argv[])
58 70
59 // Extract error message 71 // Extract error message
60 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
69 std::cout << message << std::endl; 85 std::cout << message << std::endl;
src/ctskymap/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctskymap - CTA sky mapping main code * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Command line arguments. 39 * @param[in] argv Command line arguments.
40 * 40 *
41 * This is the main entry point of the ctskymap application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new ctskymap(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/cttsmap/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * cttsmap - TS map calculation tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -39,20 +39,29 @@ @@ -39,20 +39,29 @@
39 * @param[in] argv Command line arguments. 39 * @param[in] argv Command line arguments.
40 * 40 *
41 * This is the main entry point of the cttsmap application. It allocates a 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 int main (int argc, char *argv[]) 46 int main (int argc, char *argv[])
45 { 47 {
46 // Initialise return code 48 // Initialise return code
47 int rc = 1; 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 try { 55 try {
  56 +
  57 + // Create instance of application
  58 + application = new cttsmap(argc, argv);
  59 +
54 // Execute application 60 // Execute application
55 - application.execute(); 61 + application->execute();
  62 +
  63 + // Delete application
  64 + delete application;
56 65
57 // Signal success 66 // Signal success
58 rc = 0; 67 rc = 0;
@@ -61,12 +70,16 @@ int main (int argc, char *argv[]) @@ -61,12 +70,16 @@ int main (int argc, char *argv[])
61 70
62 // Extract error message 71 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 84 // Write error on standard output
72 std::cout << signal << std::endl; 85 std::cout << signal << std::endl;
src/ctulimit/main.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctulimit - upper limit calculation tool * 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 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -46,13 +46,20 @@ int main (int argc, char *argv[]) @@ -46,13 +46,20 @@ int main (int argc, char *argv[])
46 // Initialise return code 46 // Initialise return code
47 int rc = 1; 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 try { 53 try {
  54 +
  55 + // Create instance of application
  56 + application = new ctulimit(argc, argv);
  57 +
54 // Execute application 58 // Execute application
55 - application.execute(); 59 + application->execute();
  60 +
  61 + // Delete application
  62 + delete application;
56 63
57 // Signal success 64 // Signal success
58 rc = 0; 65 rc = 0;
@@ -61,12 +68,16 @@ int main (int argc, char *argv[]) @@ -61,12 +68,16 @@ int main (int argc, char *argv[])
61 68
62 // Extract error message 69 // Extract error message
63 std::string message = e.what(); 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 // Write error on standard output 82 // Write error on standard output
72 std::cout << signal << std::endl; 83 std::cout << signal << std::endl;