Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
G4LocalThreadCoutMessenger Class Reference

#include <G4LocalThreadCoutMessenger.hh>

Inheritance diagram for G4LocalThreadCoutMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4LocalThreadCoutMessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
void SetNewValue (G4UIcommand *, G4String)
 
 ~G4LocalThreadCoutMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Attributes

G4UIcmdWithABoolbufferCoutCmd = nullptr
 
G4UIcommandcerrFileNameCmd = nullptr
 
G4UIdirectorycoutDir = nullptr
 
G4UIcommandcoutFileNameCmd = nullptr
 
G4UIcmdWithAnIntegerignoreCmd = nullptr
 
G4UIcmdWithABoolignoreInitCmd = nullptr
 
G4UIcmdWithAStringprefixCmd = nullptr
 

Detailed Description

Definition at line 46 of file G4LocalThreadCoutMessenger.hh.

Constructor & Destructor Documentation

◆ G4LocalThreadCoutMessenger()

G4LocalThreadCoutMessenger::G4LocalThreadCoutMessenger ( )

Definition at line 44 of file G4LocalThreadCoutMessenger.cc.

45{
46 coutDir = new G4UIdirectory("/control/cout/");
47 coutDir->SetGuidance("Control cout/cerr for local thread.");
48
49 coutFileNameCmd = new G4UIcommand("/control/cout/setCoutFile", this);
51 "Send G4cout stream to a file dedicated to a thread. ");
53 "To have a display output, use special keyword \"**Screen**\".");
55 "If append flag is true output is appended to file,");
56 coutFileNameCmd->SetGuidance("otherwise file output is overwritten.");
58 G4UIparameter* pp = new G4UIparameter("fileName", 's', true);
59 pp->SetDefaultValue("**Screen**");
61 pp = new G4UIparameter("append", 'b', true);
62 pp->SetDefaultValue(true);
64
65 cerrFileNameCmd = new G4UIcommand("/control/cout/setCerrFile", this);
67 "Send G4cerr stream to a file dedicated to a thread. ");
69 "To have a display output, use special keyword \"**Screen**\".");
71 "If append flag is true output is appended to file,");
72 cerrFileNameCmd->SetGuidance("otherwise file output is overwritten.");
74 pp = new G4UIparameter("fileName", 's', true);
75 pp->SetDefaultValue("**Screen**");
77 pp = new G4UIparameter("append", 'b', true);
78 pp->SetDefaultValue(true);
80
81 bufferCoutCmd = new G4UIcmdWithABool("/control/cout/useBuffer", this);
82 bufferCoutCmd->SetGuidance("Send cout and/or cerr stream to a buffer.");
84 "The buffered text will be printed at the end of the job");
86 "for each thread at a time, so that output of each thread is grouped.");
88 "This command has no effect if output goes to a file.");
89 bufferCoutCmd->SetParameterName("flag", true);
92
93 prefixCmd = new G4UIcmdWithAString("/control/cout/prefixString", this);
95 "Set the prefix string for each cout/cerr line from a thread.");
96 prefixCmd->SetParameterName("prefix", true);
99
100 ignoreCmd =
101 new G4UIcmdWithAnInteger("/control/cout/ignoreThreadsExcept", this);
102 ignoreCmd->SetGuidance("Omit cout from threads except the specified one.");
103 ignoreCmd->SetGuidance("This command takes effect only if cout destination "
104 "is screen without buffering.");
106 "If specified thread ID is greater than the number of threads,");
108 "no cout is displayed from worker threads. -1 to reset.");
109 ignoreCmd->SetGuidance("This command does not affect to cerr.");
110 ignoreCmd->SetParameterName("threadID", true);
113
115 new G4UIcmdWithABool("/control/cout/ignoreInitializationCout", this);
116 ignoreInitCmd->SetGuidance("Omit cout from threads during initialization, as "
117 "they should be identical to the master thread.");
118 ignoreInitCmd->SetGuidance("This command takes effect only if cout "
119 "destination is screen without buffering.");
120 ignoreInitCmd->SetGuidance("This command does not affect to cerr.");
121 ignoreInitCmd->SetParameterName("IgnoreInit", true);
124}
@ G4State_Idle
@ G4State_PreInit
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:288

References G4UIcommand::AvailableForStates(), bufferCoutCmd, cerrFileNameCmd, coutDir, coutFileNameCmd, G4State_Idle, G4State_PreInit, ignoreCmd, ignoreInitCmd, G4InuclParticleNames::pp, prefixCmd, G4UIcmdWithAString::SetDefaultValue(), G4UIcmdWithABool::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIcmdWithABool::SetParameterName(), G4UIcmdWithAnInteger::SetParameterName(), and G4UIcmdWithAString::SetParameterName().

◆ ~G4LocalThreadCoutMessenger()

G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger ( )

Definition at line 127 of file G4LocalThreadCoutMessenger.cc.

128{
129 delete coutFileNameCmd;
130 delete cerrFileNameCmd;
131 delete bufferCoutCmd;
132 delete prefixCmd;
133 delete ignoreCmd;
134 delete ignoreInitCmd;
135 delete coutDir;
136}

References bufferCoutCmd, cerrFileNameCmd, coutDir, coutFileNameCmd, ignoreCmd, ignoreInitCmd, and prefixCmd.

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4UImessenger::GetCurrentValue ( G4UIcommand command)
virtualinherited

Reimplemented in G4ScoreQuantityMessenger, G4VisCommandModelCreate< Factory >, G4VisCommandListManagerList< Manager >, G4VisCommandListManagerSelect< Manager >, G4VisCommandManagerMode< Manager >, G4ToolsAnalysisMessenger, G4ScoringMessenger, G4EvManMessenger, G4GeneralParticleSourceMessenger, G4ParticleGunMessenger, G4GeometryMessenger, G4GenericMessenger, G4UIcontrolMessenger, GFlashShowerModelMessenger, G4DecayTableMessenger, G4ParticleMessenger, G4ParticlePropertyMessenger, G4tgrMessenger, G4PersistencyCenterMessenger, G4ProductionCutsTableMessenger, G4SchedulerMessenger, G4VITSteppingVerbose, G4MoleculeShootMessenger, G4MoleculeGunMessenger, G4ProcessManagerMessenger, G4ProcessTableMessenger, G4MatScanMessenger, G4RunMessenger, G4UserPhysicsListMessenger, G4TrackingMessenger, G4GMocrenMessenger, G4HepRepMessenger, G4VisCommandAbortReviewKeptEvents, G4VisCommandDrawOnlyToBeKeptEvents, G4VisCommandEnable, G4VisCommandList, G4VisCommandReviewKeptEvents, G4VisCommandVerbose, G4VisCommandGeometryList, G4VisCommandGeometryRestore, G4VisCommandGeometrySetColour, G4VisCommandGeometrySetDaughtersInvisible, G4VisCommandGeometrySetForceAuxEdgeVisible, G4VisCommandGeometrySetForceCloud, G4VisCommandGeometrySetForceSolid, G4VisCommandGeometrySetForceLineSegmentsPerCircle, G4VisCommandGeometrySetForceWireframe, G4VisCommandGeometrySetLineStyle, G4VisCommandGeometrySetLineWidth, G4VisCommandGeometrySetVisibility, G4VisCommandSceneActivateModel, G4VisCommandSceneCreate, G4VisCommandSceneEndOfEventAction, G4VisCommandSceneEndOfRunAction, G4VisCommandSceneList, G4VisCommandSceneNotifyHandlers, G4VisCommandSceneRemoveModel, G4VisCommandSceneSelect, G4VisCommandSceneShowExtents, G4VisCommandSceneAddArrow, G4VisCommandSceneAddArrow2D, G4VisCommandSceneAddAxes, G4VisCommandSceneAddDate, G4VisCommandSceneAddDigis, G4VisCommandSceneAddEventID, G4VisCommandSceneAddExtent, G4VisCommandSceneAddElectricField, G4VisCommandSceneAddFrame, G4VisCommandSceneAddGPS, G4VisCommandSceneAddGhosts, G4VisCommandSceneAddHits, G4VisCommandSceneAddLine, G4VisCommandSceneAddLine2D, G4VisCommandSceneAddLocalAxes, G4VisCommandSceneAddLogicalVolume, G4VisCommandSceneAddLogo, G4VisCommandSceneAddLogo2D, G4VisCommandSceneAddMagneticField, G4VisCommandSceneAddPSHits, G4VisCommandSceneAddScale, G4VisCommandSceneAddText, G4VisCommandSceneAddText2D, G4VisCommandSceneAddTrajectories, G4VisCommandSceneAddUserAction, G4VisCommandSceneAddVolume, G4VisCommandSceneAddPlotter, G4VisCommandSceneHandlerAttach, G4VisCommandSceneHandlerCreate, G4VisCommandSceneHandlerList, G4VisCommandSceneHandlerSelect, G4VisCommandSetArrow3DLineSegmentsPerCircle, G4VisCommandSetColour, G4VisCommandSetExtentForField, G4VisCommandSetLineWidth, G4VisCommandSetTextColour, G4VisCommandSetTextLayout, G4VisCommandSetTextSize, G4VisCommandSetTouchable, G4VisCommandSetVolumeForField, G4VisCommandsTouchable, G4VisCommandsTouchableSet, G4VisCommandViewerAddCutawayPlane, G4VisCommandViewerCentreOn, G4VisCommandViewerChangeCutawayPlane, G4VisCommandViewerClear, G4VisCommandViewerClearCutawayPlanes, G4VisCommandViewerClearTransients, G4VisCommandViewerClearVisAttributesModifiers, G4VisCommandViewerClone, G4VisCommandViewerColourByDensity, G4VisCommandViewerCopyViewFrom, G4VisCommandViewerCreate, G4VisCommandViewerDolly, G4VisCommandViewerFlush, G4VisCommandViewerInterpolate, G4VisCommandViewerList, G4VisCommandViewerPan, G4VisCommandViewerReset, G4VisCommandViewerRefresh, G4VisCommandViewerRebuild, G4VisCommandViewerSave, G4VisCommandViewerScale, G4VisCommandViewerSelect, G4VisCommandViewerUpdate, G4VisCommandViewerZoom, G4VisCommandViewerDefaultHiddenEdge, G4VisCommandViewerDefaultStyle, G4VisCommandsViewerSet, G4VModelCommand< T >, G4VModelCommand< M >, G4RTMessenger, G4ASCIITreeMessenger, G4VtkMessenger, G4PolarizationMessenger, and G4DNAChemistryManager.

Definition at line 58 of file G4UImessenger.cc.

59{
60 G4String nullString;
61 return nullString;
62}

Referenced by G4UIcommand::DoIt(), and G4UIcommand::GetCurrentValue().

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetNewValue()

void G4LocalThreadCoutMessenger::SetNewValue ( G4UIcommand command,
G4String  newVal 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 139 of file G4LocalThreadCoutMessenger.cc.

141{
143 if(command == coutFileNameCmd)
144 {
145 G4Tokenizer next(newVal);
146 G4String fn = next();
147 G4bool af = StoB(next());
148 UI->SetCoutFileName(fn, af);
149 }
150 else if(command == cerrFileNameCmd)
151 {
152 G4Tokenizer next(newVal);
153 G4String fn = next();
154 G4bool af = StoB(next());
155 UI->SetCerrFileName(fn, af);
156 }
157 else if(command == bufferCoutCmd)
158 {
159 UI->SetThreadUseBuffer(StoB(newVal));
160 }
161 else if(command == prefixCmd)
162 {
163 UI->SetThreadPrefixString(newVal);
164 }
165 else if(command == ignoreCmd)
166 {
167 UI->SetThreadIgnore(StoI(newVal));
168 }
169 else if(command == ignoreInitCmd)
170 {
171 UI->SetThreadIgnoreInit(StoB(newVal));
172 }
173}
bool G4bool
Definition: G4Types.hh:86
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
Definition: G4UImanager.cc:899
void SetThreadIgnoreInit(G4bool flg=true)
Definition: G4UImanager.cc:948
void SetThreadPrefixString(const G4String &prefix="W")
Definition: G4UImanager.cc:918
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
Definition: G4UImanager.cc:880
void SetThreadIgnore(G4int tid=0)
Definition: G4UImanager.cc:936
void SetThreadUseBuffer(G4bool flg=true)
Definition: G4UImanager.cc:927
G4int StoI(G4String s)
G4bool StoB(G4String s)

References bufferCoutCmd, cerrFileNameCmd, coutFileNameCmd, G4UImanager::GetUIpointer(), ignoreCmd, ignoreInitCmd, prefixCmd, G4UImanager::SetCerrFileName(), G4UImanager::SetCoutFileName(), G4UImanager::SetThreadIgnore(), G4UImanager::SetThreadIgnoreInit(), G4UImanager::SetThreadPrefixString(), G4UImanager::SetThreadUseBuffer(), G4UImessenger::StoB(), and G4UImessenger::StoI().

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ bufferCoutCmd

G4UIcmdWithABool* G4LocalThreadCoutMessenger::bufferCoutCmd = nullptr
private

◆ cerrFileNameCmd

G4UIcommand* G4LocalThreadCoutMessenger::cerrFileNameCmd = nullptr
private

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ coutDir

G4UIdirectory* G4LocalThreadCoutMessenger::coutDir = nullptr
private

◆ coutFileNameCmd

G4UIcommand* G4LocalThreadCoutMessenger::coutFileNameCmd = nullptr
private

◆ ignoreCmd

G4UIcmdWithAnInteger* G4LocalThreadCoutMessenger::ignoreCmd = nullptr
private

◆ ignoreInitCmd

G4UIcmdWithABool* G4LocalThreadCoutMessenger::ignoreInitCmd = nullptr
private

◆ prefixCmd

G4UIcmdWithAString* G4LocalThreadCoutMessenger::prefixCmd = nullptr
private

The documentation for this class was generated from the following files: