SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
SlicApplication.hh
Go to the documentation of this file.
1 #ifndef SLIC_SLICAPPLICATION_HH_
2 #define SLIC_SLICAPPLICATION_HH_ 1
3 
4 // SLIC
5 #include "Singleton.hh"
6 #include "Module.hh"
7 
8 // Geant4
9 #include "G4UIsession.hh"
10 #include "G4ApplicationState.hh"
11 
12 class G4RunManager;
13 class G4UIExecutive;
14 
15 namespace slic {
16 
17 // slic
18 class FieldMessenger;
19 class SlicApplicationMessenger;
20 class RunManager;
21 
22 static const char* ErrorCodeStrings[] = {
23  "okay",
24  "unknown error",
25  "caught unknown exception",
26  "caught STD exception",
27  "output file already exists",
28  "failed to delete old output file",
29  "event underflow",
30  "invalid geometry setup",
31  "event generator was never setup"
32 };
33 
40 class SlicApplication: public Singleton<SlicApplication>, public Module {
41 
42  public:
43 
47  enum ERunMode {
49  };
50 
54  enum ErrorCode {
64  };
65 
66  private:
67 
68  public:
69 
74 
78  virtual ~SlicApplication();
79 
80  public:
81 
87 
91  void initialize();
92 
96  void run();
97 
101  void printUsage();
102 
106  void printVersion();
107 
111  void printSplashScreen();
112 
117 
121  void printEndTime();
122 
127  int getReturnCode() const;
128 
133  ERunMode getMode() const;
134 
139  void setAborting(bool a = true);
140 
144  bool isAborting() const;
145 
150  void setMode(ERunMode rmode);
151 
156  const std::string& getBinaryName() const;
157 
162  const std::string& getBinaryBasename() const;
163 
169  void initialize(int argc, char** argv);
170 
175  void setReturnCode(int rc);
176 
182  const char* getErrorCodeString(unsigned int errorCode) {
183  if (errorCode > (ERROR_CODE_SIZE - 1)) {
184  log() << LOG::error << "invalid error code requested: " << errorCode << LOG::done;
185  throw new std::exception();
186  }
187  return ErrorCodeStrings[errorCode];
188  }
189 
190  private:
191 
195  void setBinaryBasename();
196 
201 
205  void initializeLCDD();
206 
210  void initializeVis();
211 
212  protected:
213 
215  G4UIExecutive* m_ui;
216 
219 
222 
224 
227 
230 
233 
235  std::string m_binaryname;
236  std::string m_binarybasename;
237 
239  std::string* m_geant4VersionString;
240 };
241 }
242 
243 #endif
G4UImessenger to G4FieldManager and related classes.
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
Extension of G4RunManager.
Definition: RunManager.hh:18
G4UImessenger for the SLIC application.
Singleton class for a Geant4 application.
void setMode(ERunMode rmode)
RunManager * getRunManager()
SlicApplicationMessenger * m_appMessenger
ERunMode getMode() const
const std::string & getBinaryName() const
const char * getErrorCodeString(unsigned int errorCode)
FieldMessenger * m_fieldMessenger
bool isAborting() const
void setAborting(bool a=true)
std::string * m_geant4VersionString
const std::string & getBinaryBasename() const
@ error
Definition: LogStream.hh:33
@ done
Definition: LogStream.hh:26
static const char * ErrorCodeStrings[]