]>
Commit | Line | Data |
---|---|---|
2817d3e2 | 1 | // $Id$ |
2 | // Category: global | |
3 | // | |
e5967ab3 | 4 | // Author: I. Hrivnacova |
5 | // | |
6 | // Class TG4Globals | |
7 | // ---------------- | |
2817d3e2 | 8 | // See the class description in the header file. |
9 | ||
10 | #include "TG4Globals.h" | |
11 | ||
12 | #include <stdlib.h> | |
13 | ||
72095f7c | 14 | //_____________________________________________________________________________ |
2817d3e2 | 15 | TG4Globals::TG4Globals() { |
16 | // | |
17 | } | |
18 | ||
72095f7c | 19 | //_____________________________________________________________________________ |
2817d3e2 | 20 | TG4Globals::~TG4Globals() { |
21 | // | |
22 | } | |
23 | ||
24 | // static methods | |
25 | ||
72095f7c | 26 | //_____________________________________________________________________________ |
2817d3e2 | 27 | void TG4Globals::Exception(const char* string) |
28 | { | |
29 | // Prints error message end exits the program. | |
30 | // --- | |
31 | ||
32 | if (string) | |
3c7cd15a | 33 | { G4cerr << G4endl << " " << string << G4endl; } |
34 | G4cerr << "*** TG4Exception: Aborting execution ***" << G4endl; | |
2817d3e2 | 35 | exit(1); |
36 | } | |
37 | ||
72095f7c | 38 | //_____________________________________________________________________________ |
2817d3e2 | 39 | void TG4Globals::Warning(const char* string) |
40 | { | |
41 | // Prints warning message. | |
42 | // --- | |
43 | ||
3c7cd15a | 44 | G4cerr << "++++ TG4Warning: ++++" << G4endl; |
2817d3e2 | 45 | if (string) |
3c7cd15a | 46 | { G4cerr << " " << string << G4endl; } |
47 | G4cerr << "+++++++++++++++++++++++" << G4endl; | |
2817d3e2 | 48 | } |
68a77073 | 49 | |
72095f7c | 50 | //_____________________________________________________________________________ |
68a77073 | 51 | void TG4Globals::AppendNumberToString(G4String& s, G4int a) |
52 | { | |
53 | // Appends number to string. | |
54 | // --- | |
55 | ||
56 | const char* kpNumber="0123456789"; | |
57 | G4String p=""; G4String q=""; | |
58 | do | |
59 | { | |
60 | G4int b=a/10; | |
61 | G4int c=a%10; | |
62 | p=kpNumber[c]; | |
63 | q=p.append(q); | |
64 | a=b; | |
65 | } while (a>0); | |
66 | s.append(q); | |
67 | } | |
68 | ||
e5967ab3 | 69 | //_____________________________________________________________________________ |
70 | G4bool TG4Globals::Compare(G4bool activation, TG4G3ControlValue controlValue) | |
71 | { | |
72 | // Compares the boolean value of the process activation | |
73 | // with the process control value. | |
74 | // Returns true if the values correspond, false otherwise. | |
75 | // --- | |
76 | ||
77 | if (controlValue == kUnset) { | |
78 | TG4Globals::Warning( | |
79 | "TG4SpecialControls::Compare: control value = kUnset."); | |
80 | return false; | |
81 | } | |
82 | ||
83 | if (controlValue == kActivate || controlValue == kActivate2) | |
84 | return activation; | |
85 | else | |
86 | return !activation; | |
87 | } | |
88 | ||
89 | //_____________________________________________________________________________ | |
90 | void TG4Globals::PrintStars(G4bool emptyLineFirst) | |
91 | { | |
92 | // Print stars. | |
93 | // --- | |
94 | ||
95 | ||
96 | if (emptyLineFirst) G4cout << G4endl; | |
97 | ||
98 | G4cout << "**********************************************" << G4endl; | |
99 | ||
100 | if (!emptyLineFirst) G4cout << G4endl; | |
101 | } | |
102 |