SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
SlicMain.cc
Go to the documentation of this file.
1 #include "SlicMain.hh"
2 
3 // slic
4 #include "SlicApplication.hh"
5 
6 // geant4
7 #include "G4RunManager.hh"
8 
9 namespace slic {
10 
12  Module("SlicMain") {
13  ;
14 }
15 
17  ;
18 }
19 
20 int SlicMain::main(int argc, char** argv) {
21  // Default return code.
22  int returnCode = 0;
23 
24  // Application instance.
25  SlicApplication* slicApp = 0;
26 
27  // Top-level try block.
28 #ifdef SLIC_CATCH_STD_EXCEPTIONS
29  try {
30  std::cout << "SLIC is enabled to catch std exceptions." << std::endl;
31 #endif
32  // Create the SLIC application using the singleton function.
33  slicApp = SlicApplication::instance();
34 
35  // Setup the command line arguments.
36  slicApp->initialize(argc, argv);
37 
38  // Run the app.
39  slicApp->run();
40 
41  // Get the application return code.
42  returnCode = slicApp->getReturnCode();
43 
44  // Delete the application.
45  if (slicApp) {
46  delete slicApp;
47  }
48 
49 #ifdef SLIC_CATCH_STD_EXCEPTIONS
50  // Catch a generic std::exception.
51 } catch(std::exception& stde) {
52  log() << LOG::error << LOG::head << stde.what() << LOG::done;
53  returnCode = SlicApplication::STD_EXCEPTION;
54 }
55 // Catch an unknown exception.
56 catch(...) {
57  log() << LOG::error << LOG::head << "Top-level catch block caught an unknown exception!" << LOG::done;
59 }
60 #endif
61 
62  return returnCode;
63 }
64 } // namespace slic
static SlicApplication * instance()
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
Singleton class for a Geant4 application.
virtual ~SlicMain()
Definition: SlicMain.cc:16
int main(int argc, char **argv)
Definition: SlicMain.cc:20
@ error
Definition: LogStream.hh:33
@ head
Definition: LogStream.hh:26
@ endl
Definition: LogStream.hh:26
@ done
Definition: LogStream.hh:26