Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
G4Timer.cc File Reference
#include "G4Timer.hh"
#include "G4ios.hh"
#include "G4ExceptionSeverity.hh"

Go to the source code of this file.

Functions

void G4Exception (const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
std::ostream & operator<< (std::ostream &os, const G4Timer &t)
 

Function Documentation

void G4Exception ( const char *  originOfException,
const char *  exceptionCode,
G4ExceptionSeverity  severity,
const char *  comments 
)

Definition at line 41 of file G4Exception.cc.

References EventMustBeAborted, FatalErrorInArgument, FatalException, G4cerr, G4cout, G4endl, G4State_Abort, G4StateManager::GetExceptionHandler(), G4StateManager::GetStateManager(), G4VExceptionHandler::Notify(), and RunMustBeAborted.

Referenced by G4Exception(), G4Timer::GetRealElapsed(), G4Timer::GetSystemElapsed(), and G4Timer::GetUserElapsed().

45 {
46  G4VExceptionHandler* exceptionHandler
48  G4bool toBeAborted = true;
49  if(exceptionHandler)
50  {
51  toBeAborted = exceptionHandler
52  ->Notify(originOfException,exceptionCode,severity,description);
53  }
54  else
55  {
56  static const G4String es_banner
57  = "\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
58  static const G4String ee_banner
59  = "\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
60  static const G4String ws_banner
61  = "\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
62  static const G4String we_banner
63  = "\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
64  std::ostringstream message;
65  message << "\n*** ExceptionHandler is not defined ***\n"
66  << "*** G4Exception : " << exceptionCode << G4endl
67  << " issued by : " << originOfException << G4endl
68  << description << G4endl;
69  switch(severity)
70  {
71  case FatalException:
72  G4cerr << es_banner << message.str() << "*** Fatal Exception ***"
73  << ee_banner << G4endl;
74  break;
76  G4cerr << es_banner << message.str() << "*** Fatal Error In Argument ***"
77  << ee_banner << G4endl;
78  break;
79  case RunMustBeAborted:
80  G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***"
81  << ee_banner << G4endl;
82  break;
83  case EventMustBeAborted:
84  G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***"
85  << ee_banner << G4endl;
86  break;
87  default:
88  G4cout << ws_banner << message.str()
89  << "*** This is just a warning message. ***"
90  << we_banner << G4endl;
91  toBeAborted = false;
92  break;
93  }
94  }
95  if(toBeAborted)
96  {
98  {
99  G4cerr << G4endl << "*** G4Exception: Aborting execution ***" << G4endl;
100  abort();
101  }
102  else
103  {
104  G4cerr << G4endl << "*** G4Exception: Abortion suppressed ***"
105  << G4endl << "*** No guarantee for further execution ***" << G4endl;
106  }
107  }
108 }
virtual G4bool Notify(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)=0
G4VExceptionHandler * GetExceptionHandler() const
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
std::ostream& operator<< ( std::ostream &  os,
const G4Timer t 
)

Definition at line 87 of file G4Timer.cc.

References G4Timer::GetRealElapsed(), G4Timer::GetSystemElapsed(), G4Timer::GetUserElapsed(), and G4Timer::IsValid().

88 {
89  if (t.IsValid())
90  {
91  os << "User=" << t.GetUserElapsed()
92  << "s Real=" << t.GetRealElapsed()
93  << "s Sys=" << t.GetSystemElapsed() << "s";
94  }
95  else
96  {
97  os << "User=****s Real=****s Sys=****s";
98  }
99  return os;
100 }
G4double GetSystemElapsed() const
Definition: G4Timer.cc:119
G4bool IsValid() const
G4double GetUserElapsed() const
Definition: G4Timer.cc:130
G4double GetRealElapsed() const
Definition: G4Timer.cc:107