76 UImessenger(0), UnitsMessenger(0), CoutMessenger(0),
77 isMaster(false),bridges(0),
78 ignoreCmdNotFound(false), stackCommandsForBroadcast(false),
79 threadID(-1), threadCout(0)
109 std::vector<G4UIbridge*>::iterator itr =
bridges->begin();
110 for(;itr!=
bridges->end();itr++)
152 {
return (
this==&right); }
154 {
return (
this!=&right); }
177 for(
G4int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
179 token = savedToken();
181 if( token[(
size_t)0] ==
'"' )
184 token.
append(savedToken(
"\""));
191 const char * aParameterName,
G4bool reGet)
199 if( aParameterName ==
207 const char * aParameterName,
G4bool reGet)
212 const char* t = targetParameter;
213 std::istringstream is(t);
224 const char* t = targetParameter;
225 std::istringstream is(t);
231 const char * aParameterName,
G4bool reGet)
236 const char* t = targetParameter;
237 std::istringstream is(t);
248 const char* t = targetParameter;
249 std::istringstream is(t);
295 c1 += parameterToken();
297 c1 += parameterToken();
299 std::istringstream is(t1);
303 is >> d1 >> d2 >>
d3;
304 Loop(mf,vn,d1,d2,d3);
312 for(
G4double d=initialValue;d<=finalValue;d+=stepSize)
314 std::ostringstream os;
320 for(
G4double d=initialValue;d>=finalValue;d+=stepSize)
322 std::ostringstream os;
328 Foreach(macroFile,variableName,cd);
339 while(!((ca=parameterToken()).isNull()))
346 if(aliasValue(0)==
'"')
349 if(aliasValue(aliasValue.length()-1)==
'"')
350 { strippedValue = aliasValue(1,aliasValue.length()-2); }
352 { strippedValue = aliasValue(1,aliasValue.length()-1); }
353 aliasValue = strippedValue;
361 const char * candidates)
363 G4String candidatesString = candidates;
366 while(!((cd=parameterToken()).isNull()))
382 while((ia !=
G4int(std::string::npos))&&((iz==
G4int(std::string::npos))||(ia<iz)))
388 if( ib ==
G4int(std::string::npos) )
393 G4cerr <<
"Unmatched alias parenthis -- command ignored" <<
G4endl;
397 G4String ps = aCommand(ia+1,aCommand.length()-(ia+1));
400 if(ic!=
G4int(std::string::npos) && ic <
id)
408 if(ia>0) subs = aCommand(0,ia);
409 G4String alis = aCommand(ia+1,ibx-ia-1);
410 G4String rems = aCommand(ibx+1,aCommand.length()-ibx);
415 G4cerr <<
"Alias <" << alis <<
"> not found -- command ignored" <<
G4endl;
419 aCommand = subs+(*alVal)+rems;
420 ia = aCommand.
index(
"{");
441 if( i !=
G4int(std::string::npos) )
443 commandString = aCommand(0,i);
444 commandParameter = aCommand(i+1,aCommand.length()-(i+1));
448 commandString = aCommand;
452 G4int len = commandString.length();
458 if(commandString(ll,2)==
"//")
461 { commandString.
remove(ll,1); }
464 a1 = commandString(0,ll);
465 a2 = commandString(ll+1,len-ll-1);
466 commandString = a1+
a2;
476 std::vector<G4UIbridge*>::iterator itr =
bridges->begin();
477 for(;itr!=
bridges->end();itr++)
479 G4int leng = (*itr)->DirLength();
480 if(commandString(0,leng)==(*itr)->DirName())
481 {
return (*itr)->LocalUI()->ApplyCommand(commandString+
" "+commandParameter); }
486 if( targetCommand == NULL )
491 {
commandStack->push_back(commandString+
" "+commandParameter); }
499 {
commandStack->push_back(commandString+
" "+commandParameter); }
509 return targetCommand->
DoIt( commandParameter );
550 if( targetDir( targetDir.length()-1 ) !=
'/' )
551 { targetDir +=
"/"; }
553 if( targetDir ==
"/" )
556 while( idx <
G4int(targetDir.length())-1 )
559 G4String targetDirString = targetDir(0,i+1);
560 comTree = comTree->
GetTree(targetDirString);
561 if( comTree == NULL )
615 G4String aliasValue = aLine(i+1,aLine.length()-(i+1));
616 if(aliasValue(0)==
'"')
619 if(aliasValue(aliasValue.length()-1)==
'"')
620 { strippedValue = aliasValue(1,aliasValue.length()-2); }
622 { strippedValue = aliasValue(1,aliasValue.length()-1); }
623 aliasValue = strippedValue;
647 {
G4cerr <<
"Directory <" << dir <<
"> is not found." <<
G4endl; }
658 pathstring =
searchPath.substr(idxfirst, idxend-idxfirst);
659 if(pathstring.size() != 0)
searchDirs.push_back(pathstring);
660 idxfirst = idxend + 1;
664 if(pathstring.size() != 0)
searchDirs.push_back(pathstring);
672 fs.open(fname.c_str(), std::ios::in);
684 for (
size_t i = 0; i <
searchDirs.size(); i++) {
687 macrofile = fullpath;
707 "G4UIBridge cannot bridge between same object.");
726 if(fileN ==
"**Screen**")
730 std::stringstream fn;
741 if(fileN ==
"**Screen**")
745 std::stringstream fn;
void ForeachS(const char *valueList)
void ExecuteMacroFile(const char *fileName)
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
void RemoveAlias(const char *aliasName)
G4int operator==(const G4UImanager &right) const
static G4ThreadLocal G4UImanager * fUImanager
void SetThreadPrefixString(const G4String &s="W")
void SetAlias(const char *aliasLine)
G4UIcommand * savedCommand
void SetUpForAThread(G4int tId)
G4LocalThreadCoutMessenger * CoutMessenger
virtual void PauseSessionStart(const G4String &Prompt)
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
static G4UImanager * GetMasterUIpointer()
G4String & remove(str_size)
void RegisterBridge(G4UIbridge *brg)
G4UIcontrolMessenger * UImessenger
G4UIcommand * FindPath(const char *commandPath) const
G4String strip(G4int strip_Type=trailing, char c=' ')
G4UIcommandTree * treeTop
G4String GetParameterName() const
static G4bool FileFound(const G4String &fname)
std::ofstream historyFile
static G4UImanager * fMasterUImanager
void SetThreadUseBuffer(G4bool flg=true)
virtual G4UIsession * SessionStart()
G4bool stackCommandsForBroadcast
void RemoveWorkerCommand(G4UIcommand *aCommand)
std::vector< G4String > * GetCommandStack()
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
void SetPrefixString(const G4String &wd="G4WT")
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
static G4UImanager * GetUIpointer()
void ParseMacroSearchPath()
static G4StateManager * GetStateManager()
std::vector< G4String > searchDirs
G4UIaliasList * aliasList
G4bool ToBeBroadcasted() const
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
G4UIcommandTree * GetTree(G4int i)
void ChangeAlias(const char *aliasName, const char *aliasValue)
void Loop(const char *macroFile, const char *variableName, G4double initialValue, G4double finalValue, G4double stepSize=1.0)
G4MTcoutDestination * threadCout
G4UIparameter * GetParameter(G4int i) const
std::vector< G4UIbridge * > * bridges
void EnableBuffering(G4bool flag=true)
void RemoveCommand(G4UIcommand *aCommand)
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
G4UnitsMessenger * UnitsMessenger
G4String * FindAlias(const char *aliasName)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetIgnoreCout(G4int tid=0)
G4String GetCurrentValues(const char *aCommand)
const char * data() const
void ListCommands(const char *direc)
void PauseSession(const char *msg)
std::vector< G4String > histVec
void SetDestination(G4coutDestination *dest)
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
std::vector< G4String > * commandStack
void AddNewCommand(G4UIcommand *newCommand)
G4String & append(const G4String &)
void SetCoutDestination(G4UIsession *const value)
void G4iosInitialization()
G4String SolveAlias(const char *aCmd)
static G4ThreadLocal G4bool fUImanagerHasBeenKilled
void LoopS(const char *valueList)
const G4UImanager & operator=(const G4UImanager &right)
virtual G4bool Notify(G4ApplicationState requestedState)
void AddWorkerCommand(G4UIcommand *newCommand)
G4double GetCurrentDoubleValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
G4UImanager * LocalUI() const
void SetThreadIgnore(G4int tid=0)
void CreateHTML(const char *dir="/")
void StoreHistory(const char *fileName="G4history.macro")
G4int GetParameterEntries() const
G4String FindMacroPath(const G4String &fname) const
G4bool pauseAtBeginOfEvent
virtual G4int DoIt(G4String parameterList)
G4UIcommandTree * FindDirectory(const char *dirName)
G4int ApplyCommand(const char *aCommand)
G4String GetCurrentValue()
G4GLOB_DLL std::ostream G4cerr
G4int operator!=(const G4UImanager &right) const
void RemoveAlias(const char *aliasName)