186 for(
G4int i_thParameter = 0; i_thParameter < parameterNumber; ++i_thParameter)
188 token = savedToken();
191 if(token[(
size_t) 0] ==
'"')
194 token.append(savedToken(
"\""));
202 const char* aParameterName,
219 const char* aParameterName,
G4bool reGet)
224 const char* t = targetParameter;
225 std::istringstream is(t);
237 const char* t = targetParameter;
238 std::istringstream is(t);
245 const char* aParameterName,
251 const char* t = targetParameter;
252 std::istringstream is(t);
264 const char* t = targetParameter;
265 std::istringstream is(t);
323 c1 += parameterToken();
325 c1 += parameterToken();
327 std::istringstream is(t1);
331 is >>
d1 >>
d2 >> d3;
343 for(
G4double d = initialValue; d <= finalValue; d += stepSize)
345 std::ostringstream os;
353 for(
G4double d = initialValue; d >= finalValue; d += stepSize)
355 std::ostringstream os;
373 while(!((ca = parameterToken()).
empty()))
380 if(aliasValue[0] ==
'"')
383 if(aliasValue.back() ==
'"')
385 strippedValue = aliasValue.substr(1, aliasValue.length() - 2);
389 strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
391 aliasValue = strippedValue;
400 const char* candidates)
402 G4String candidatesString = candidates;
405 while(!((
cd = parameterToken()).
empty()))
415 ed <<
"Loop aborted due to a command execution error - "
416 <<
"error code " <<
lastRC;
427 G4int ia = aCommand.find(
"{");
428 G4int iz = aCommand.find(
"#");
429 while((ia !=
G4int(std::string::npos)) &&
430 ((iz ==
G4int(std::string::npos)) || (ia < iz)))
435 G4int ib = aCommand.find(
"}");
436 if(ib ==
G4int(std::string::npos))
439 for(
G4int i = 0; i < ia; ++i)
442 G4cerr <<
"Unmatched alias parenthesis -- command ignored" <<
G4endl;
446 G4String ps = aCommand.substr(ia + 1, aCommand.length() - (ia + 1));
449 if(ic !=
G4int(std::string::npos) && ic <
id)
462 subs = aCommand.substr(0, ia);
463 G4String alis = aCommand.substr(ia + 1, ibx - ia - 1);
464 G4String rems = aCommand.substr(ibx + 1, aCommand.length() - ibx);
468 G4cerr <<
"Alias <" << alis <<
"> not found -- command ignored" <<
G4endl;
472 aCommand = subs + (*alVal) + rems;
473 ia = aCommand.find(
"{");
497 std::size_t i = aCommand.find(
" ");
498 if(i != std::string::npos)
500 commandString = aCommand.substr(0, i);
501 commandParameter = aCommand.substr(i + 1, aCommand.length() - (i + 1));
505 commandString = aCommand;
509 G4int len = commandString.length();
515 if(commandString.substr(ll, 2) ==
"//")
520 commandString.erase(ll, 1);
524 a1 = commandString.substr(0, ll);
525 a2 = commandString.substr(ll + 1, len - ll - 1);
526 commandString = a1 + a2;
540 G4int leng = (*itr)->DirLength();
541 if(commandString.substr(0, leng) == (*itr)->DirName())
543 return (*itr)->LocalUI()->ApplyCommand(commandString +
" " +
550 if(targetCommand ==
nullptr)
556 commandStack->push_back(commandString +
" " + commandParameter);
568 commandStack->push_back(commandString +
" " + commandParameter);
585 G4int commandFailureCode = targetCommand->
DoIt(commandParameter);
586 if(commandFailureCode == 0)
589 if(additionalFailureCode > 0)
593 <<
"Error code : " << additionalFailureCode;
595 commandFailureCode += additionalFailureCode;
598 return commandFailureCode;
617 std::size_t i = aCommand.find(
" ");
618 if(i != std::string::npos)
619 { commandString = aCommand.substr(0, i); }
621 { commandString = aCommand; }
656 session->PauseSessionStart(msg);
663 if(comTree !=
nullptr)
678 if(targetDir.back() !=
'/')
688 while(idx <
G4int(targetDir.length()) - 1)
690 G4int i = targetDir.find(
"/", idx);
691 G4String targetDirString = targetDir.substr(0, i + 1);
692 comTree = comTree->
GetTree(targetDirString);
693 if(comTree ==
nullptr)
737 G4int i = aLine.find(
" ");
738 G4String aliasName = aLine.substr(0, i);
739 G4String aliasValue = aLine.substr(i + 1, aLine.length() - (i + 1));
740 if(aliasValue[0] ==
'"')
743 if(aliasValue.back() ==
'"')
745 strippedValue = aliasValue.substr(1, aliasValue.length() - 2);
749 strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
751 aliasValue = strippedValue;
781 G4cerr <<
"Directory <" << dir <<
"> is not found." <<
G4endl;
790 std::size_t idxfirst = 0;
791 std::size_t idxend = 0;
793 while((idxend =
searchPath.find(
':', idxfirst)) != G4String::npos)
795 pathstring =
searchPath.substr(idxfirst, idxend - idxfirst);
796 if(pathstring.size() != 0)
798 idxfirst = idxend + 1;
802 if(pathstring.size() != 0)
811 fs.open(
fname.c_str(), std::ios::in);
825 for(std::size_t i = 0; i <
searchDirs.size(); ++i)
830 macrofile = fullpath;
851 "G4UIBridge cannot bridge between same object.");
886 if(fileN ==
"**Screen**")
892 std::stringstream fn;
893 fn <<
"G4W_" <<
threadID <<
"_" << fileN;
905 if(fileN ==
"**Screen**")
911 std::stringstream fn;
912 fn <<
"G4W_" <<
threadID <<
"_" << fileN;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
static constexpr double s
static constexpr double ps
@ fIllegalApplicationState
static G4bool FileFound(const G4String &fname)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void G4iosInitialization()
G4GLOB_DLL G4strstreambuf G4coutbuf
G4GLOB_DLL G4strstreambuf G4cerrbuf
void SetPrefixString(const G4String &wd="G4WT")
void EnableBuffering(G4bool flag=true)
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
void SetIgnoreInit(G4bool val=true)
void SetIgnoreCout(G4int tid=0)
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
static G4StateManager * GetStateManager()
G4String * FindAlias(const char *aliasName)
void ChangeAlias(const char *aliasName, const char *aliasValue)
void RemoveAlias(const char *aliasName)
G4UImanager * LocalUI() const
G4UIcommandTree * GetTree(G4int i)
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
G4UIcommand * FindPath(const char *commandPath) const
void CreateHTML(G4String="")
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
std::size_t GetParameterEntries() const
G4UIparameter * GetParameter(G4int i) const
G4bool ToBeBroadcasted() const
virtual G4int DoIt(G4String parameterList)
const G4String & GetFailureDescription()
G4String GetCurrentValue()
static G4bool DoublePrecisionStr()
G4ProfilerMessenger * ProfileMessenger
void RemoveWorkerCommand(G4UIcommand *aCommand)
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
void SetCoutDestination(G4UIsession *const value)
static void UseDoublePrecisionStr(G4bool val)
G4UIaliasList * aliasList
static G4ICOMS_DLL G4int igThreadID
G4bool fLastCommandOutputTreated
void ForeachS(const char *valueList)
void SetUpForAThread(G4int tId)
std::vector< G4String > * GetCommandStack()
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
G4int ApplyCommand(const char *aCommand)
static G4ICOMS_DLL G4UImanager *& fMasterUImanager()
void SetThreadIgnoreInit(G4bool flg=true)
void CreateHTML(const char *dir="/")
void AddWorkerCommand(G4UIcommand *newCommand)
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
std::vector< G4String > * commandStack
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
std::vector< G4String > searchDirs
void SetThreadPrefixString(const G4String &prefix="W")
void LoopS(const char *valueList)
G4UIcommandTree * treeTop
void StoreHistory(const char *fileName="G4history.macro")
void ListCommands(const char *direc)
G4double GetCurrentDoubleValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
void PauseSession(const char *msg)
G4UIcommand * savedCommand
void ExecuteMacroFile(const char *fileName)
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
G4UnitsMessenger * UnitsMessenger
std::vector< G4UIbridge * > * bridges
static G4UImanager * GetMasterUIpointer()
std::ofstream historyFile
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
void SetUpForSpecialThread(G4String aPrefix)
void AddNewCommand(G4UIcommand *newCommand)
G4String GetCurrentValues(const char *aCommand)
virtual G4bool Notify(G4ApplicationState requestedState)
void SetThreadIgnore(G4int tid=0)
void SetAlias(const char *aliasLine)
std::vector< G4String > histVec
G4String FindMacroPath(const G4String &fname) const
static G4ICOMS_DLL G4bool doublePrecisionStr
void RemoveAlias(const char *aliasName)
G4String SolveAlias(const char *aCmd)
static G4ICOMS_DLL G4UImanager *& fUImanager()
G4LocalThreadCoutMessenger * CoutMessenger
void RemoveCommand(G4UIcommand *aCommand)
G4UIcommandTree * FindDirectory(const char *dirName)
G4MTcoutDestination * threadCout
G4bool stackCommandsForBroadcast
G4UIcommand * FindCommand(const char *aCommand)
void ParseMacroSearchPath()
static G4UImanager * GetUIpointer()
G4UIcontrolMessenger * UImessenger
void RegisterBridge(G4UIbridge *brg)
G4bool pauseAtBeginOfEvent
void SetThreadUseBuffer(G4bool flg=true)
static G4ICOMS_DLL G4bool & fUImanagerHasBeenKilled()
const G4String & GetParameterName() const
void SetDestination(G4coutDestination *dest)
G4String strip_copy(G4String str, char c=' ')
Return copy of string with leading and trailing characters removed.
void G4SetThreadId(G4int aNewValue)
#define G4ThreadLocalStatic