ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4LocalThreadCoutMessenger.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4LocalThreadCoutMessenger.cc
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
27
#include "
G4LocalThreadCoutMessenger.hh
"
28
29
#include "
G4UImanager.hh
"
30
31
#include "
G4UIdirectory.hh
"
32
#include "
G4UIcommand.hh
"
33
#include "
G4UIcmdWithABool.hh
"
34
#include "
G4UIcmdWithAString.hh
"
35
#include "
G4UIcmdWithAnInteger.hh
"
36
#include "
G4UIparameter.hh
"
37
#include "
G4Tokenizer.hh
"
38
39
G4LocalThreadCoutMessenger::G4LocalThreadCoutMessenger
()
40
{
41
coutDir
=
new
G4UIdirectory
(
"/control/cout/"
);
42
coutDir
->
SetGuidance
(
"Control cout/cerr for local thread."
);
43
44
coutFileNameCmd
=
new
G4UIcommand
(
"/control/cout/setCoutFile"
,
this
);
45
coutFileNameCmd
->
SetGuidance
(
"Send G4cout stream to a file dedicated to a thread. "
);
46
coutFileNameCmd
->
SetGuidance
(
"To have a display output, use special keyword \"**Screen**\"."
);
47
coutFileNameCmd
->
SetGuidance
(
"If append flag is true output is appended to file,"
);
48
coutFileNameCmd
->
SetGuidance
(
"otherwise file output is overwritten."
);
49
coutFileNameCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
50
G4UIparameter
*
pp
=
new
G4UIparameter
(
"fileName"
,
's'
,
true
);
51
pp->
SetDefaultValue
(
"**Screen**"
);
52
coutFileNameCmd
->
SetParameter
(pp);
53
pp=
new
G4UIparameter
(
"append"
,
'b'
,
true
);
54
pp->
SetDefaultValue
(
true
);
55
coutFileNameCmd
->
SetParameter
(pp);
56
57
cerrFileNameCmd
=
new
G4UIcommand
(
"/control/cout/setCerrFile"
,
this
);
58
cerrFileNameCmd
->
SetGuidance
(
"Send G4cerr stream to a file dedicated to a thread. "
);
59
cerrFileNameCmd
->
SetGuidance
(
"To have a display output, use special keyword \"**Screen**\"."
);
60
cerrFileNameCmd
->
SetGuidance
(
"If append flag is true output is appended to file,"
);
61
cerrFileNameCmd
->
SetGuidance
(
"otherwise file output is overwritten."
);
62
cerrFileNameCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
63
pp =
new
G4UIparameter
(
"fileName"
,
's'
,
true
);
64
pp->
SetDefaultValue
(
"**Screen**"
);
65
cerrFileNameCmd
->
SetParameter
(pp);
66
pp=
new
G4UIparameter
(
"append"
,
'b'
,
true
);
67
pp->
SetDefaultValue
(
true
);
68
cerrFileNameCmd
->
SetParameter
(pp);
69
70
bufferCoutCmd
=
new
G4UIcmdWithABool
(
"/control/cout/useBuffer"
,
this
);
71
bufferCoutCmd
->
SetGuidance
(
"Send cout and/or cerr stream to a buffer."
);
72
bufferCoutCmd
->
SetGuidance
(
"The buffered text will be printed at the end of the job"
);
73
bufferCoutCmd
->
SetGuidance
(
"for each thread at a time, so that output of each thread is grouped."
);
74
bufferCoutCmd
->
SetGuidance
(
"This command has no effect if output goes to a file."
);
75
bufferCoutCmd
->
SetParameterName
(
"flag"
,
true
);
76
bufferCoutCmd
->
SetDefaultValue
(
true
);
77
bufferCoutCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
78
79
prefixCmd
=
new
G4UIcmdWithAString
(
"/control/cout/prefixString"
,
this
);
80
prefixCmd
->
SetGuidance
(
"Set the prefix string for each cout/cerr line from a thread."
);
81
prefixCmd
->
SetParameterName
(
"prefix"
,
true
);
82
prefixCmd
->
SetDefaultValue
(
"G4WT"
);
83
prefixCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
84
85
ignoreCmd
=
new
G4UIcmdWithAnInteger
(
"/control/cout/ignoreThreadsExcept"
,
this
);
86
ignoreCmd
->
SetGuidance
(
"Omit cout from threads except the specified one."
);
87
ignoreCmd
->
SetGuidance
(
"This command takes effect only if cout destination is screen without buffering."
);
88
ignoreCmd
->
SetGuidance
(
"If specified thread ID is greater than the number of threads,"
);
89
ignoreCmd
->
SetGuidance
(
"no cout is displayed from worker threads. -1 to reset."
);
90
ignoreCmd
->
SetGuidance
(
"This command does not affect to cerr."
);
91
ignoreCmd
->
SetParameterName
(
"threadID"
,
true
);
92
ignoreCmd
->
SetDefaultValue
(0);
93
ignoreCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
94
95
ignoreInitCmd
=
new
G4UIcmdWithABool
(
"/control/cout/ignoreInitializationCout"
,
this
);
96
ignoreInitCmd
->
SetGuidance
(
"Omit cout from threads during initialization, as they should be identical to the master thread."
);
97
ignoreInitCmd
->
SetGuidance
(
"This command takes effect only if cout destination is screen without buffering."
);
98
ignoreInitCmd
->
SetGuidance
(
"This command does not affect to cerr."
);
99
ignoreInitCmd
->
SetParameterName
(
"IgnoreInit"
,
true
);
100
ignoreInitCmd
->
SetDefaultValue
(
true
);
101
ignoreInitCmd
->
AvailableForStates
(
G4State_PreInit
,
G4State_Idle
);
102
}
103
104
G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger
()
105
{
106
delete
coutFileNameCmd
;
107
delete
cerrFileNameCmd
;
108
delete
bufferCoutCmd
;
109
delete
prefixCmd
;
110
delete
ignoreCmd
;
111
delete
ignoreInitCmd
;
112
delete
coutDir
;
113
}
114
115
void
G4LocalThreadCoutMessenger::SetNewValue
(
G4UIcommand
* command,
G4String
newVal)
116
{
117
G4UImanager
* UI =
G4UImanager::GetUIpointer
();
118
if
(command ==
coutFileNameCmd
)
119
{
120
G4Tokenizer
next(newVal);
121
G4String
fn = next();
122
G4bool
af =
StoB
(next());
123
UI->
SetCoutFileName
(fn,af);
124
}
125
else
if
(command ==
cerrFileNameCmd
)
126
{
127
G4Tokenizer
next(newVal);
128
G4String
fn = next();
129
G4bool
af =
StoB
(next());
130
UI->
SetCerrFileName
(fn,af);
131
}
132
else
if
(command ==
bufferCoutCmd
)
133
{ UI->
SetThreadUseBuffer
(
StoB
(newVal)); }
134
else
if
(command ==
prefixCmd
)
135
{ UI->
SetThreadPrefixString
(newVal); }
136
else
if
(command ==
ignoreCmd
)
137
{ UI->
SetThreadIgnore
(
StoI
(newVal)); }
138
else
if
(command ==
ignoreInitCmd
)
139
{ UI->
SetThreadIgnoreInit
(
StoB
(newVal)); }
140
}
141
geant4
tree
geant4-10.6-release
source
intercoms
src
G4LocalThreadCoutMessenger.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:22
using
1.8.2 with
ECCE GitHub integration