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

#include <G4UIcontrolMessenger.hh>

Inheritance diagram for G4UIcontrolMessenger:
G4UImessenger

Public Member Functions

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

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

G4UIcommandaddCommand = nullptr
 
G4UIcommandaliasCommand = nullptr
 
G4UIdirectorycontrolDirectory = nullptr
 
G4UIcommanddivideCommand = nullptr
 
G4UIcmdWithAStringdoifBatchCommand = nullptr
 
G4UIcommanddoifCommand = nullptr
 
G4UIcmdWithAStringdoifInteractiveCommand = nullptr
 
G4UIcmdWithABooldoublePrecCommand = nullptr
 
G4UIcmdWithAStringechoCmd = nullptr
 
G4UIcmdWithAStringExecuteCommand = nullptr
 
G4UIcommandforeachCommand = nullptr
 
G4UIcmdWithAStringgetEnvCmd = nullptr
 
G4UIcommandgetValCmd = nullptr
 
G4UIcmdWithAStringhistoryCommand = nullptr
 
G4UIcmdWithAStringHTMLCommand = nullptr
 
G4UIcmdWithAStringifBatchCommand = nullptr
 
G4UIcommandifCommand = nullptr
 
G4UIcmdWithAStringifInteractiveCommand = nullptr
 
G4UIcmdWithoutParameterlistAliasCommand = nullptr
 
G4UIcommandloopCommand = nullptr
 
G4UIcmdWithAStringmacroPathCommand = nullptr
 
G4UIcmdWithAStringManualCommand = nullptr
 
G4UIcmdWithAnIntegermaxStoredHistCommand = nullptr
 
G4UIcommandmultiplyCommand = nullptr
 
G4UIcommandremainderCommand = nullptr
 
G4UIcmdWithAStringshellCommand = nullptr
 
G4UIcmdWithoutParameterstopStoreHistoryCommand = nullptr
 
G4UIcommandstrdoifCommand = nullptr
 
G4UIcommandstrifCommand = nullptr
 
G4UIcommandsubtractCommand = nullptr
 
G4UIcmdWithAnIntegersuppressAbortionCommand = nullptr
 
G4UIcmdWithAStringunaliasCommand = nullptr
 
G4UIcmdWithAnIntegerverboseCommand = nullptr
 

Detailed Description

Definition at line 80 of file G4UIcontrolMessenger.hh.

Constructor & Destructor Documentation

◆ G4UIcontrolMessenger()

G4UIcontrolMessenger::G4UIcontrolMessenger ( )

Definition at line 49 of file G4UIcontrolMessenger.cc.

50{
51 controlDirectory = new G4UIdirectory("/control/");
52 controlDirectory->SetGuidance("UI control commands.");
53
54 macroPathCommand = new G4UIcmdWithAString("/control/macroPath", this);
55 macroPathCommand->SetGuidance("Set macro search path"
56 " with colon-separated list.");
57 macroPathCommand->SetParameterName("path", false);
58
59 ExecuteCommand = new G4UIcmdWithAString("/control/execute", this);
60 ExecuteCommand->SetGuidance("Execute a macro file.");
61 ExecuteCommand->SetParameterName("fileName", false);
63
64 loopCommand = new G4UIcommand("/control/loop", this);
65 loopCommand->SetGuidance("Execute a macro file more than once.");
66 loopCommand->SetGuidance("Loop counter can be used as an aliased variable.");
67 G4UIparameter* param1 = new G4UIparameter("macroFile", 's', false);
69 G4UIparameter* param2 = new G4UIparameter("counterName", 's', false);
71 G4UIparameter* param3 = new G4UIparameter("initialValue", 'd', false);
73 G4UIparameter* param4 = new G4UIparameter("finalValue", 'd', false);
75 G4UIparameter* param5 = new G4UIparameter("stepSize", 'd', true);
76 param5->SetDefaultValue(1.0);
79
80 foreachCommand = new G4UIcommand("/control/foreach", this);
81 foreachCommand->SetGuidance("Execute a macro file more than once.");
83 "Loop counter can be used as an aliased variable.");
84 foreachCommand->SetGuidance("Values must be separated by a space.");
85 G4UIparameter* param6 = new G4UIparameter("macroFile", 's', false);
87 G4UIparameter* param7 = new G4UIparameter("counterName", 's', false);
89 G4UIparameter* param8 = new G4UIparameter("valueList", 's', false);
92
94 new G4UIcmdWithAnInteger("/control/suppressAbortion", this);
96 "Suppress the program abortion caused by G4Exception.");
98 "Suppression level = 0 : no suppression");
100 " = 1 : suppress during EventProc state");
102 " = 2 : full suppression, i.e. no abortion by "
103 "G4Exception");
105 "When abortion is suppressed, you will get error messages issued by "
106 "G4Exception,");
108 "and there is NO guarantee for the correct result after the G4Exception "
109 "error message.");
111 suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
113
114 verboseCommand = new G4UIcmdWithAnInteger("/control/verbose", this);
115 verboseCommand->SetGuidance("Applied command will also be shown on screen.");
116 verboseCommand->SetGuidance("This command is useful with MACRO file.");
117 verboseCommand->SetGuidance(" 0 : silent");
118 verboseCommand->SetGuidance(" 1 : only the valid commands are shown.");
119 verboseCommand->SetGuidance(" 2 : comment lines are also shown (default).");
120 verboseCommand->SetParameterName("switch", true);
121 verboseCommand->SetRange("switch >= 0 && switch <=2");
123
124 doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision", this);
126 "Use double precision for printing out the current parameter value(s).");
127 doublePrecCommand->SetParameterName("useDoublePrecision", true);
129
130 historyCommand = new G4UIcmdWithAString("/control/saveHistory", this);
131 historyCommand->SetGuidance("Store command history to a file.");
132 historyCommand->SetGuidance("Defaul file name is G4history.macro.");
133 historyCommand->SetParameterName("fileName", true);
134 historyCommand->SetDefaultValue("G4History.macro");
136
138 new G4UIcmdWithoutParameter("/control/stopSavingHistory", this);
139 stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
141
142 aliasCommand = new G4UIcommand("/control/alias", this);
143 aliasCommand->SetGuidance("Set an alias.");
144 aliasCommand->SetGuidance("String can be aliased by this command.");
145 aliasCommand->SetGuidance("The string may contain one or more spaces,");
147 "the string must be enclosed by double quotes (\").");
148 aliasCommand->SetGuidance("To use an alias, enclose the alias name with");
149 aliasCommand->SetGuidance("parenthesis \"{\" and \"}\".");
150 G4UIparameter* aliasNameParam = new G4UIparameter("aliasName", 's', false);
151 aliasCommand->SetParameter(aliasNameParam);
152 G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue", 's', false);
153 aliasCommand->SetParameter(aliasValueParam);
154
155 unaliasCommand = new G4UIcmdWithAString("/control/unalias", this);
156 unaliasCommand->SetGuidance("Remove an alias.");
157 unaliasCommand->SetParameterName("aliasName", false);
158
159 listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias", this);
160 listAliasCommand->SetGuidance("List aliases.");
161
162 getEnvCmd = new G4UIcmdWithAString("/control/getEnv", this);
164 "Get a shell environment variable and define it as an alias.");
166
167 getValCmd = new G4UIcommand("/control/getVal", this);
169 "Get the current value of the UI command and define it as an alias.");
171 "Command is ignored if the UI command does not support GetCurrentValue().");
172 getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>");
173 G4UIparameter* aliName = new G4UIparameter("alias_name", 's', false);
174 getValCmd->SetParameter(aliName);
175 G4UIparameter* comName = new G4UIparameter("UI_command", 's', false);
176 getValCmd->SetParameter(comName);
177 G4UIparameter* iIdxParam = new G4UIparameter("iIdx", 'i', true);
178 iIdxParam->SetDefaultValue(0);
179 getValCmd->SetParameter(iIdxParam);
181
182 echoCmd = new G4UIcmdWithAString("/control/echo", this);
183 echoCmd->SetGuidance("Display the valuerameter string.");
184 echoCmd->SetGuidance("If alias is contained, it is converted to the aliased value.");
185
186 shellCommand = new G4UIcmdWithAString("/control/shell", this);
187 shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
189
190 ManualCommand = new G4UIcmdWithAString("/control/manual", this);
191 ManualCommand->SetGuidance("Display all of sub-directories and commands.");
192 ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
193 ManualCommand->SetParameterName("dirPath", true);
196
197 HTMLCommand = new G4UIcmdWithAString("/control/createHTML", this);
199 "Generate HTML files for all of sub-directories and commands.");
200 HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
201 HTMLCommand->SetParameterName("dirPath", true);
204
206 new G4UIcmdWithAnInteger("/control/maximumStoredHistory", this);
208 "Set maximum number of stored UI commands.");
211
212 ifCommand = new G4UIcommand("/control/if", this);
213 ifCommand->SetGuidance("Execute a macro file if the expression is true.");
214 ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>");
215 G4UIparameter* leftParam = new G4UIparameter("left", 'd', false);
216 ifCommand->SetParameter(leftParam);
217 G4UIparameter* compParam = new G4UIparameter("comp", 's', false);
218 compParam->SetParameterCandidates("> >= < <= == !=");
219 ifCommand->SetParameter(compParam);
220 G4UIparameter* rightParam = new G4UIparameter("right", 'd', false);
221 ifCommand->SetParameter(rightParam);
222 G4UIparameter* macroFileParam = new G4UIparameter("macroFile", 's', false);
223 ifCommand->SetParameter(macroFileParam);
225
226 doifCommand = new G4UIcommand("/control/doif", this);
227 doifCommand->SetGuidance("Execute a UI command if the expression is true.");
228 doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
229 G4UIparameter* doleftParam = new G4UIparameter("left", 'd', false);
230 doifCommand->SetParameter(doleftParam);
231 G4UIparameter* docompParam = new G4UIparameter("comp", 's', false);
232 docompParam->SetParameterCandidates("> >= < <= == !=");
233 doifCommand->SetParameter(docompParam);
234 G4UIparameter* dorightParam = new G4UIparameter("right", 'd', false);
235 doifCommand->SetParameter(dorightParam);
236 G4UIparameter* comParam = new G4UIparameter("UI_command", 's', false);
237 doifCommand->SetParameter(comParam);
239
240 addCommand = new G4UIcommand("/control/add", this);
241 addCommand->SetGuidance("Define a new alias as the sum of two values.");
242 addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
244 " <new_alias> may be an already existing alias. If it is the case,");
245 addCommand->SetGuidance(" aliased value is alternated.");
246 G4UIparameter* newAlias1 = new G4UIparameter("new_alias", 's', false);
247 addCommand->SetParameter(newAlias1);
248 G4UIparameter* val1a = new G4UIparameter("value1", 'd', false);
249 addCommand->SetParameter(val1a);
250 G4UIparameter* val1b = new G4UIparameter("value2", 'd', false);
251 addCommand->SetParameter(val1b);
253
254 subtractCommand = new G4UIcommand("/control/subtract", this);
256 "Define a new alias as the subtraction of two values.");
257 subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
259 " <new_alias> may be an already existing alias. If it is the case,");
260 subtractCommand->SetGuidance(" aliased value is alternated.");
261 G4UIparameter* newAlias2 = new G4UIparameter("new_alias", 's', false);
262 subtractCommand->SetParameter(newAlias2);
263 G4UIparameter* val2a = new G4UIparameter("value1", 'd', false);
265 G4UIparameter* val2b = new G4UIparameter("value2", 'd', false);
268
269 multiplyCommand = new G4UIcommand("/control/multiply", this);
271 "Define a new alias as the multiplication of two values.");
272 multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
274 " <new_alias> may be an already existing alias. If it is the case,");
275 multiplyCommand->SetGuidance(" aliased value is alternated.");
276 G4UIparameter* newAlias3 = new G4UIparameter("new_alias", 's', false);
277 multiplyCommand->SetParameter(newAlias3);
278 G4UIparameter* val3a = new G4UIparameter("value1", 'd', false);
280 G4UIparameter* val3b = new G4UIparameter("value2", 'd', false);
283
284 divideCommand = new G4UIcommand("/control/divide", this);
286 "Define a new alias as the division of two values.");
287 divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
289 " <new_alias> may be an already existing alias. If it is the case,");
290 divideCommand->SetGuidance(" aliased value is alternated.");
291 G4UIparameter* newAlias4 = new G4UIparameter("new_alias", 's', false);
292 divideCommand->SetParameter(newAlias4);
293 G4UIparameter* val4a = new G4UIparameter("value1", 'd', false);
295 G4UIparameter* val4b = new G4UIparameter("value2", 'd', false);
296 val4b->SetParameterRange("value2 != 0.");
299
300 remainderCommand = new G4UIcommand("/control/remainder", this);
302 "Define a new alias as the remainder of two values.");
303 remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
305 " <new_alias> may be an already existing alias. If it is the case,");
306 remainderCommand->SetGuidance(" aliased value is alternated.");
307 G4UIparameter* newAlias5 = new G4UIparameter("new_alias", 's', false);
308 remainderCommand->SetParameter(newAlias5);
309 G4UIparameter* val5a = new G4UIparameter("value1", 'i', false);
311 G4UIparameter* val5b = new G4UIparameter("value2", 'i', false);
312 val4b->SetParameterRange("value2 != 0");
315
316 strifCommand = new G4UIcommand("/control/strif", this);
317 strifCommand->SetGuidance("Execute a macro file if the expression is true.");
318 strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>");
319 G4UIparameter* strleftParam = new G4UIparameter("left", 's', false);
320 strifCommand->SetParameter(strleftParam);
321 G4UIparameter* strcompParam = new G4UIparameter("comp", 's', false);
322 strcompParam->SetParameterCandidates("== !=");
323 strifCommand->SetParameter(strcompParam);
324 G4UIparameter* strrightParam = new G4UIparameter("right", 's', false);
325 strifCommand->SetParameter(strrightParam);
326 G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile", 's', false);
327 strifCommand->SetParameter(strmacroFileParam);
329
330 strdoifCommand = new G4UIcommand("/control/strdoif", this);
332 "Execute a UI command if the expression is true.");
334 " Syntax : <string> <comp> <string> <UI_command>");
335 G4UIparameter* strdoleftParam = new G4UIparameter("left", 's', false);
336 strdoifCommand->SetParameter(strdoleftParam);
337 G4UIparameter* strdocompParam = new G4UIparameter("comp", 's', false);
338 strdocompParam->SetParameterCandidates("== !=");
339 strdoifCommand->SetParameter(strdocompParam);
340 G4UIparameter* strdorightParam = new G4UIparameter("right", 's', false);
341 strdoifCommand->SetParameter(strdorightParam);
342 G4UIparameter* strdomacroFileParam =
343 new G4UIparameter("UI_command", 's', false);
344 strdoifCommand->SetParameter(strdomacroFileParam);
346
347 ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch", this);
349 "Execute a macro file if program is running in batch mode.");
350 ifBatchCommand->SetParameterName("macroFile", false);
352
353 ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive", this);
355 "Execute a macro file if program is running in interactive mode.");
356 ifInteractiveCommand->SetParameterName("macroFile", false);
358
359 doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch", this);
361 "Execute a UI command if program is running in batch mode.");
362 doifBatchCommand->SetParameterName("UIcommand", false);
364
366 new G4UIcmdWithAString("/control/doifInteractive", this);
368 "Execute a UI command if program is running in interactive mode.");
369 doifInteractiveCommand->SetParameterName("UIcommand", false);
371}
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 SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:172
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
G4UIcmdWithAnInteger * maxStoredHistCommand
G4UIcmdWithoutParameter * stopStoreHistoryCommand
G4UIcmdWithAString * ExecuteCommand
G4UIcmdWithAString * unaliasCommand
G4UIcmdWithAString * doifBatchCommand
G4UIcmdWithAString * shellCommand
G4UIdirectory * controlDirectory
G4UIcmdWithoutParameter * listAliasCommand
G4UIcmdWithAString * doifInteractiveCommand
G4UIcmdWithAnInteger * verboseCommand
G4UIcmdWithAString * ifBatchCommand
G4UIcmdWithAString * ifInteractiveCommand
G4UIcmdWithAString * HTMLCommand
G4UIcmdWithAString * echoCmd
G4UIcmdWithAString * ManualCommand
G4UIcmdWithABool * doublePrecCommand
G4UIcmdWithAString * historyCommand
G4UIcmdWithAString * getEnvCmd
G4UIcmdWithAnInteger * suppressAbortionCommand
G4UIcmdWithAString * macroPathCommand
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)

References addCommand, aliasCommand, controlDirectory, divideCommand, doifBatchCommand, doifCommand, doifInteractiveCommand, doublePrecCommand, echoCmd, ExecuteCommand, foreachCommand, getEnvCmd, getValCmd, historyCommand, HTMLCommand, ifBatchCommand, ifCommand, ifInteractiveCommand, listAliasCommand, loopCommand, macroPathCommand, ManualCommand, maxStoredHistCommand, multiplyCommand, remainderCommand, G4UIcmdWithAString::SetDefaultValue(), G4UIparameter::SetDefaultValue(), G4UIcmdWithABool::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIparameter::SetParameterCandidates(), G4UIcmdWithABool::SetParameterName(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4UIparameter::SetParameterRange(), G4UIcommand::SetRange(), G4UIcommand::SetToBeBroadcasted(), shellCommand, stopStoreHistoryCommand, strdoifCommand, strifCommand, subtractCommand, suppressAbortionCommand, unaliasCommand, and verboseCommand.

◆ ~G4UIcontrolMessenger()

G4UIcontrolMessenger::~G4UIcontrolMessenger ( )

Definition at line 374 of file G4UIcontrolMessenger.cc.

375{
376 delete macroPathCommand;
377 delete ExecuteCommand;
379 delete verboseCommand;
380 delete doublePrecCommand;
381 delete historyCommand;
383 delete ManualCommand;
384 delete aliasCommand;
385 delete unaliasCommand;
386 delete listAliasCommand;
387 delete getEnvCmd;
388 delete getValCmd;
389 delete echoCmd;
390 delete shellCommand;
391 delete loopCommand;
392 delete foreachCommand;
393 delete HTMLCommand;
395 delete ifCommand;
396 delete doifCommand;
397 delete addCommand;
398 delete subtractCommand;
399 delete multiplyCommand;
400 delete divideCommand;
401 delete remainderCommand;
402 delete strifCommand;
403 delete strdoifCommand;
404 delete ifBatchCommand;
406 delete doifBatchCommand;
408 delete controlDirectory;
409}

References addCommand, aliasCommand, controlDirectory, divideCommand, doifBatchCommand, doifCommand, doifInteractiveCommand, doublePrecCommand, echoCmd, ExecuteCommand, foreachCommand, getEnvCmd, getValCmd, historyCommand, HTMLCommand, ifBatchCommand, ifCommand, ifInteractiveCommand, listAliasCommand, loopCommand, macroPathCommand, ManualCommand, maxStoredHistCommand, multiplyCommand, remainderCommand, shellCommand, stopStoreHistoryCommand, strdoifCommand, strifCommand, subtractCommand, suppressAbortionCommand, unaliasCommand, and verboseCommand.

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 SetNewValue().

◆ GetCurrentValue()

G4String G4UIcontrolMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 767 of file G4UIcontrolMessenger.cc.

768{
770 G4String currentValue;
771
772 if(command == macroPathCommand)
773 {
774 currentValue = UI->GetMacroSearchPath();
775 }
776 if(command == verboseCommand)
777 {
778 currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
779 }
780 if(command == doublePrecCommand)
781 {
782 currentValue =
784 }
785 if(command == suppressAbortionCommand)
786 {
788 G4StateManager::GetStateManager()->GetSuppressAbortion());
789 }
790 if(command == maxStoredHistCommand)
791 {
793 }
794
795 return currentValue;
796}
static G4StateManager * GetStateManager()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
static G4bool DoublePrecisionStr()
Definition: G4UImanager.cc:158
const G4String & GetMacroSearchPath() const
Definition: G4UImanager.hh:215
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:200
G4int GetMaxHistSize() const
Definition: G4UImanager.hh:212

References G4UIcommand::ConvertToString(), doublePrecCommand, G4UImanager::DoublePrecisionStr(), G4UImanager::GetMacroSearchPath(), G4UImanager::GetMaxHistSize(), G4StateManager::GetStateManager(), G4UImanager::GetUIpointer(), G4UImanager::GetVerboseLevel(), macroPathCommand, maxStoredHistCommand, suppressAbortionCommand, and verboseCommand.

◆ 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 G4UIcontrolMessenger::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 412 of file G4UIcontrolMessenger.cc.

413{
415
416 if(command == macroPathCommand)
417 {
418 UI->SetMacroSearchPath(newValue);
420 }
421 if(command == ExecuteCommand)
422 {
423 command->ResetFailure();
424 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
425 if(UI->GetLastReturnCode() != 0)
426 {
428 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
429 command->CommandFailed(UI->GetLastReturnCode(), ed);
430 }
431 }
432 if(command == suppressAbortionCommand)
433 {
436 }
437 if(command == verboseCommand)
438 {
440 }
441 if(command == doublePrecCommand)
442 {
445 }
446 if(command == historyCommand)
447 {
448 UI->StoreHistory(newValue);
449 }
450 if(command == stopStoreHistoryCommand)
451 {
452 UI->StoreHistory(false);
453 }
454 if(command == ManualCommand)
455 {
456 UI->ListCommands(newValue);
457 }
458 if(command == aliasCommand)
459 {
460 UI->SetAlias(newValue);
461 }
462 if(command == unaliasCommand)
463 {
464 UI->RemoveAlias(newValue);
465 }
466 if(command == listAliasCommand)
467 {
468 UI->ListAlias();
469 }
470 if(command == getEnvCmd)
471 {
472 command->ResetFailure();
473 if(std::getenv(newValue))
474 {
475 G4String st = newValue;
476 st += " ";
477 st += std::getenv(newValue);
478 UI->SetAlias(st.c_str());
479 }
480 else
481 {
483 ed << "<" << newValue
484 << "> is not defined as a shell variable. Command ignored.";
485 command->CommandFailed(ed);
486 }
487 }
488 if(command == getValCmd)
489 {
490 G4Tokenizer next(newValue);
491 G4String aliName = next();
492 G4String com = next();
493 G4String curVal = UI->GetCurrentValues(com);
494 if(!(curVal.empty()))
495 {
496 G4String theValue = curVal;
497 G4String iIdx = next();
498 if(!(iIdx.empty()))
499 {
500 G4int idx = StoI(iIdx);
501 G4Tokenizer nextVal(curVal);
502 for(G4int i = 0; i <= idx; i++)
503 {
504 theValue = nextVal();
505 }
506 }
507 G4String st = "/control/alias ";
508 st += aliName + " " + theValue;
509 UI->ApplyCommand(st);
510 }
511 }
512 if(command == echoCmd)
513 {
514 G4cout << UI->SolveAlias(newValue) << G4endl;
515 }
516 if(command == shellCommand)
517 {
518 command->ResetFailure();
519 int rc = system(newValue);
520 if(rc < 0)
521 {
523 ed << "<" << newValue
524 << "> is not a valid shell command. Command ignored.";
525 command->CommandFailed(ed);
526 }
527 }
528 if(command == loopCommand)
529 {
530 command->ResetFailure();
531 UI->LoopS(newValue);
532 if(UI->GetLastReturnCode() != 0)
533 {
535 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
536 command->CommandFailed(UI->GetLastReturnCode(), ed);
537 }
538 }
539 if(command == foreachCommand)
540 {
541 command->ResetFailure();
542 UI->ForeachS(newValue);
543 if(UI->GetLastReturnCode() != 0)
544 {
546 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
547 command->CommandFailed(UI->GetLastReturnCode(), ed);
548 }
549 }
550 if(command == HTMLCommand)
551 {
552 UI->CreateHTML(newValue);
553 }
554 if(command == maxStoredHistCommand)
555 {
557 }
558 if(command == ifCommand)
559 {
560 G4Tokenizer next(newValue);
561 G4double l = StoD(next());
562 G4String comp = next();
563 G4double r = StoD(next());
564 G4String mac = next();
565 G4bool x = false;
566 if(comp == ">")
567 x = (l > r);
568 else if(comp == ">=")
569 x = (l >= r);
570 else if(comp == "<")
571 x = (l < r);
572 else if(comp == "<=")
573 x = (l <= r);
574 else if(comp == "==")
575 x = (l == r);
576 else if(comp == "!=")
577 x = (l != r);
578 if(x)
579 UI->ExecuteMacroFile(mac);
580 }
581 if(command == doifCommand)
582 {
583 G4Tokenizer next(newValue);
584 G4double l = StoD(next());
585 G4String comp = next();
586 G4double r = StoD(next());
587
588 G4String c1 = next();
589 G4String ca;
590 while(!((ca = next()).empty()))
591 {
592 c1 += " ";
593 c1 += ca;
594 }
595 if(c1[0] == '"')
596 {
597 G4String strippedValue;
598 if(c1.back() == '"')
599 {
600 strippedValue = c1.substr(1, c1.length() - 2);
601 }
602 else
603 {
604 strippedValue = c1.substr(1, c1.length() - 1);
605 }
606 c1 = strippedValue;
607 }
608
609 G4bool x = false;
610 if(comp == ">")
611 x = (l > r);
612 else if(comp == ">=")
613 x = (l >= r);
614 else if(comp == "<")
615 x = (l < r);
616 else if(comp == "<=")
617 x = (l <= r);
618 else if(comp == "==")
619 x = (l == r);
620 else if(comp == "!=")
621 x = (l != r);
622 if(x)
623 UI->ApplyCommand(c1);
624 }
625 if(command == addCommand)
626 {
627 G4Tokenizer next(newValue);
628 G4String newA = next();
629 G4double l = StoD(next());
630 G4double r = StoD(next());
631 G4String st = "/control/alias ";
632 st += newA;
633 st += " ";
634 st += DtoS(l + r);
635 UI->ApplyCommand(st);
636 }
637 if(command == subtractCommand)
638 {
639 G4Tokenizer next(newValue);
640 G4String newA = next();
641 G4double l = StoD(next());
642 G4double r = StoD(next());
643 G4String st = "/control/alias ";
644 st += newA;
645 st += " ";
646 st += DtoS(l - r);
647 UI->ApplyCommand(st);
648 }
649 if(command == multiplyCommand)
650 {
651 G4Tokenizer next(newValue);
652 G4String newA = next();
653 G4double l = StoD(next());
654 G4double r = StoD(next());
655 G4String st = "/control/alias ";
656 st += newA;
657 st += " ";
658 st += DtoS(l * r);
659 UI->ApplyCommand(st);
660 }
661 if(command == divideCommand)
662 {
663 G4Tokenizer next(newValue);
664 G4String newA = next();
665 G4double l = StoD(next());
666 G4double r = StoD(next());
667 G4String st = "/control/alias ";
668 st += newA;
669 st += " ";
670 st += DtoS(l / r);
671 UI->ApplyCommand(st);
672 }
673 if(command == remainderCommand)
674 {
675 G4Tokenizer next(newValue);
676 G4String newA = next();
677 G4int l = StoI(next());
678 G4int r = StoI(next());
679 G4String st = "/control/alias ";
680 st += newA;
681 st += " ";
682 st += DtoS(l % r);
683 UI->ApplyCommand(st);
684 }
685 if(command == strifCommand)
686 {
687 G4Tokenizer next(newValue);
688 G4String l = next();
689 G4String comp = next();
690 G4String r = next();
691 G4String mac = next();
692 G4bool x = false;
693 if(comp == "==")
694 {
695 x = (l == r);
696 }
697 else if(comp == "!=")
698 {
699 x = (l != r);
700 }
701 if(x)
702 UI->ExecuteMacroFile(mac);
703 }
704 if(command == strdoifCommand)
705 {
706 G4Tokenizer next(newValue);
707 G4String l = next();
708 G4String comp = next();
709 G4String r = next();
710
711 G4String c1 = next();
712 G4String ca;
713 while(!((ca = next()).empty()))
714 {
715 c1 += " ";
716 c1 += ca;
717 }
718 if(c1[0] == '"')
719 {
720 G4String strippedValue;
721 if(c1.back() == '"')
722 {
723 strippedValue = c1.substr(1, c1.length() - 2);
724 }
725 else
726 {
727 strippedValue = c1.substr(1, c1.length() - 1);
728 }
729 c1 = strippedValue;
730 }
731
732 G4bool x = false;
733 if(comp == "==")
734 {
735 x = (l == r);
736 }
737 else if(comp == "!=")
738 {
739 x = (l != r);
740 }
741 if(x)
742 UI->ApplyCommand(c1);
743 }
744 if(command == ifBatchCommand)
745 {
746 if(G4UIsession::InSession() == 0)
747 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
748 }
749 if(command == ifInteractiveCommand)
750 {
751 if(G4UIsession::InSession() > 0)
752 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
753 }
754 if(command == doifBatchCommand)
755 {
756 if(G4UIsession::InSession() == 0)
757 UI->ApplyCommand(newValue);
758 }
759 if(command == doifInteractiveCommand)
760 {
761 if(G4UIsession::InSession() > 0)
762 UI->ApplyCommand(newValue);
763 }
764}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
void SetSuppressAbortion(G4int i)
static G4bool GetNewBoolValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
void ResetFailure()
Definition: G4UIcommand.hh:191
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
static void UseDoublePrecisionStr(G4bool val)
Definition: G4UImanager.cc:152
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:365
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:772
void LoopS(const char *valueList)
Definition: G4UImanager.cc:315
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:627
void ListCommands(const char *direc)
Definition: G4UImanager.cc:660
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:303
void SetMacroSearchPath(const G4String &path)
Definition: G4UImanager.hh:214
void SetMaxHistSize(G4int mx)
Definition: G4UImanager.hh:211
G4int GetLastReturnCode() const
Definition: G4UImanager.hh:254
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:164
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:734
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:821
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:758
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:424
void ListAlias()
Definition: G4UImanager.cc:766
void ParseMacroSearchPath()
Definition: G4UImanager.cc:786
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:199
G4int StoI(G4String s)
G4String DtoS(G4double a)
G4double StoD(G4String s)
static G4int InSession()
Definition: G4UIsession.cc:68

References addCommand, aliasCommand, G4UImanager::ApplyCommand(), G4UIcommand::CommandFailed(), G4UImanager::CreateHTML(), divideCommand, doifBatchCommand, doifCommand, doifInteractiveCommand, doublePrecCommand, G4UImessenger::DtoS(), echoCmd, anonymous_namespace{G4MTcoutDestination.cc}::empty, ExecuteCommand, G4UImanager::ExecuteMacroFile(), G4UImanager::FindMacroPath(), foreachCommand, G4UImanager::ForeachS(), G4cout, G4endl, G4UImanager::GetCurrentValues(), getEnvCmd, G4UImanager::GetLastReturnCode(), G4UIcmdWithABool::GetNewBoolValue(), G4UIcmdWithAnInteger::GetNewIntValue(), G4StateManager::GetStateManager(), G4UImanager::GetUIpointer(), getValCmd, historyCommand, HTMLCommand, ifBatchCommand, ifCommand, ifInteractiveCommand, G4UIsession::InSession(), G4UImanager::ListAlias(), listAliasCommand, G4UImanager::ListCommands(), loopCommand, G4UImanager::LoopS(), macroPathCommand, ManualCommand, maxStoredHistCommand, multiplyCommand, G4UImanager::ParseMacroSearchPath(), remainderCommand, G4UImanager::RemoveAlias(), G4UIcommand::ResetFailure(), G4UImanager::SetAlias(), G4UImanager::SetMacroSearchPath(), G4UImanager::SetMaxHistSize(), G4StateManager::SetSuppressAbortion(), G4UImanager::SetVerboseLevel(), shellCommand, G4UImanager::SolveAlias(), G4UImessenger::StoD(), G4UImessenger::StoI(), stopStoreHistoryCommand, G4UImanager::StoreHistory(), strdoifCommand, strifCommand, subtractCommand, suppressAbortionCommand, unaliasCommand, G4UImanager::UseDoublePrecisionStr(), and verboseCommand.

◆ 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 G4LocalThreadCoutMessenger::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

◆ addCommand

G4UIcommand* G4UIcontrolMessenger::addCommand = nullptr
private

◆ aliasCommand

G4UIcommand* G4UIcontrolMessenger::aliasCommand = nullptr
private

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ controlDirectory

G4UIdirectory* G4UIcontrolMessenger::controlDirectory = nullptr
private

Definition at line 91 of file G4UIcontrolMessenger.hh.

Referenced by G4UIcontrolMessenger(), and ~G4UIcontrolMessenger().

◆ divideCommand

G4UIcommand* G4UIcontrolMessenger::divideCommand = nullptr
private

◆ doifBatchCommand

G4UIcmdWithAString* G4UIcontrolMessenger::doifBatchCommand = nullptr
private

◆ doifCommand

G4UIcommand* G4UIcontrolMessenger::doifCommand = nullptr
private

◆ doifInteractiveCommand

G4UIcmdWithAString* G4UIcontrolMessenger::doifInteractiveCommand = nullptr
private

◆ doublePrecCommand

G4UIcmdWithABool* G4UIcontrolMessenger::doublePrecCommand = nullptr
private

◆ echoCmd

G4UIcmdWithAString* G4UIcontrolMessenger::echoCmd = nullptr
private

◆ ExecuteCommand

G4UIcmdWithAString* G4UIcontrolMessenger::ExecuteCommand = nullptr
private

◆ foreachCommand

G4UIcommand* G4UIcontrolMessenger::foreachCommand = nullptr
private

◆ getEnvCmd

G4UIcmdWithAString* G4UIcontrolMessenger::getEnvCmd = nullptr
private

◆ getValCmd

G4UIcommand* G4UIcontrolMessenger::getValCmd = nullptr
private

◆ historyCommand

G4UIcmdWithAString* G4UIcontrolMessenger::historyCommand = nullptr
private

◆ HTMLCommand

G4UIcmdWithAString* G4UIcontrolMessenger::HTMLCommand = nullptr
private

◆ ifBatchCommand

G4UIcmdWithAString* G4UIcontrolMessenger::ifBatchCommand = nullptr
private

◆ ifCommand

G4UIcommand* G4UIcontrolMessenger::ifCommand = nullptr
private

◆ ifInteractiveCommand

G4UIcmdWithAString* G4UIcontrolMessenger::ifInteractiveCommand = nullptr
private

◆ listAliasCommand

G4UIcmdWithoutParameter* G4UIcontrolMessenger::listAliasCommand = nullptr
private

◆ loopCommand

G4UIcommand* G4UIcontrolMessenger::loopCommand = nullptr
private

◆ macroPathCommand

G4UIcmdWithAString* G4UIcontrolMessenger::macroPathCommand = nullptr
private

◆ ManualCommand

G4UIcmdWithAString* G4UIcontrolMessenger::ManualCommand = nullptr
private

◆ maxStoredHistCommand

G4UIcmdWithAnInteger* G4UIcontrolMessenger::maxStoredHistCommand = nullptr
private

◆ multiplyCommand

G4UIcommand* G4UIcontrolMessenger::multiplyCommand = nullptr
private

◆ remainderCommand

G4UIcommand* G4UIcontrolMessenger::remainderCommand = nullptr
private

◆ shellCommand

G4UIcmdWithAString* G4UIcontrolMessenger::shellCommand = nullptr
private

◆ stopStoreHistoryCommand

G4UIcmdWithoutParameter* G4UIcontrolMessenger::stopStoreHistoryCommand = nullptr
private

◆ strdoifCommand

G4UIcommand* G4UIcontrolMessenger::strdoifCommand = nullptr
private

◆ strifCommand

G4UIcommand* G4UIcontrolMessenger::strifCommand = nullptr
private

◆ subtractCommand

G4UIcommand* G4UIcontrolMessenger::subtractCommand = nullptr
private

◆ suppressAbortionCommand

G4UIcmdWithAnInteger* G4UIcontrolMessenger::suppressAbortionCommand = nullptr
private

◆ unaliasCommand

G4UIcmdWithAString* G4UIcontrolMessenger::unaliasCommand = nullptr
private

◆ verboseCommand

G4UIcmdWithAnInteger* G4UIcontrolMessenger::verboseCommand = nullptr
private

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