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++)
166 {
return (
this==&right); }
168 {
return (
this!=&right); }
191 for(
G4int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
193 token = savedToken();
195 if( token[(
size_t)0] ==
'"' )
198 token.
append(savedToken(
"\""));
205 const char * aParameterName,
G4bool reGet)
213 if( aParameterName ==
221 const char * aParameterName,
G4bool reGet)
226 const char* t = targetParameter;
227 std::istringstream is(t);
238 const char* t = targetParameter;
239 std::istringstream is(t);
245 const char * aParameterName,
G4bool reGet)
250 const char* t = targetParameter;
251 std::istringstream is(t);
262 const char* t = targetParameter;
263 std::istringstream is(t);
309 c1 += parameterToken();
311 c1 += parameterToken();
313 std::istringstream is(t1);
317 is >> d1 >> d2 >>
d3;
318 Loop(mf,vn,d1,d2,d3);
326 for(
G4double d=initialValue;d<=finalValue;d+=stepSize)
328 std::ostringstream os;
334 for(
G4double d=initialValue;d>=finalValue;d+=stepSize)
336 std::ostringstream os;
342 Foreach(macroFile,variableName,cd);
353 while(!((ca=parameterToken()).isNull()))
360 if(aliasValue(0)==
'"')
363 if(aliasValue(aliasValue.length()-1)==
'"')
364 { strippedValue = aliasValue(1,aliasValue.length()-2); }
366 { strippedValue = aliasValue(1,aliasValue.length()-1); }
367 aliasValue = strippedValue;
375 const char * candidates)
377 G4String candidatesString = candidates;
380 while(!((cd=parameterToken()).isNull()))
396 while((ia !=
G4int(std::string::npos))&&((iz==
G4int(std::string::npos))||(ia<iz)))
402 if( ib ==
G4int(std::string::npos) )
407 G4cerr <<
"Unmatched alias parenthis -- command ignored" <<
G4endl;
411 G4String ps = aCommand(ia+1,aCommand.length()-(ia+1));
414 if(ic!=
G4int(std::string::npos) && ic <
id)
422 if(ia>0) subs = aCommand(0,ia);
423 G4String alis = aCommand(ia+1,ibx-ia-1);
424 G4String rems = aCommand(ibx+1,aCommand.length()-ibx);
429 G4cerr <<
"Alias <" << alis <<
"> not found -- command ignored" <<
G4endl;
433 aCommand = subs+(*alVal)+rems;
434 ia = aCommand.
index(
"{");
455 if( i !=
G4int(std::string::npos) )
457 commandString = aCommand(0,i);
458 commandParameter = aCommand(i+1,aCommand.length()-(i+1));
462 commandString = aCommand;
466 G4int len = commandString.length();
472 if(commandString(ll,2)==
"//")
475 { commandString.
remove(ll,1); }
478 a1 = commandString(0,ll);
479 a2 = commandString(ll+1,len-ll-1);
480 commandString = a1+
a2;
490 std::vector<G4UIbridge*>::iterator itr =
bridges->begin();
491 for(;itr!=
bridges->end();itr++)
493 G4int leng = (*itr)->DirLength();
494 if(commandString(0,leng)==(*itr)->DirName())
495 {
return (*itr)->LocalUI()->ApplyCommand(commandString+
" "+commandParameter); }
500 if( targetCommand == NULL )
505 {
commandStack->push_back(commandString+
" "+commandParameter); }
513 {
commandStack->push_back(commandString+
" "+commandParameter); }
523 return targetCommand->
DoIt( commandParameter );
564 if( targetDir( targetDir.length()-1 ) !=
'/' )
565 { targetDir +=
"/"; }
567 if( targetDir ==
"/" )
570 while( idx <
G4int(targetDir.length())-1 )
573 G4String targetDirString = targetDir(0,i+1);
574 comTree = comTree->
GetTree(targetDirString);
575 if( comTree == NULL )
629 G4String aliasValue = aLine(i+1,aLine.length()-(i+1));
630 if(aliasValue(0)==
'"')
633 if(aliasValue(aliasValue.length()-1)==
'"')
634 { strippedValue = aliasValue(1,aliasValue.length()-2); }
636 { strippedValue = aliasValue(1,aliasValue.length()-1); }
637 aliasValue = strippedValue;
661 {
G4cerr <<
"Directory <" << dir <<
"> is not found." <<
G4endl; }
672 pathstring =
searchPath.substr(idxfirst, idxend-idxfirst);
673 if(pathstring.size() != 0)
searchDirs.push_back(pathstring);
674 idxfirst = idxend + 1;
678 if(pathstring.size() != 0)
searchDirs.push_back(pathstring);
686 fs.open(fname.c_str(), std::ios::in);
698 for (
size_t i = 0; i <
searchDirs.size(); i++) {
701 macrofile = fullpath;
721 "G4UIBridge cannot bridge between same object.");
750 if(fileN ==
"**Screen**")
754 std::stringstream fn;
765 if(fileN ==
"**Screen**")
769 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
void G4SetThreadId(G4int aNewValue)
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 SetIgnoreInit(G4bool val=true)
void ParseMacroSearchPath()
static G4StateManager * GetStateManager()
std::vector< G4String > searchDirs
void SetThreadIgnoreInit(G4bool flg=true)
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 SetUpForSpecialThread(G4String aPrefix)
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)