Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4UImanager.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4UImanager.cc 102562 2017-02-09 08:27:31Z gcosmo $
28 //
29 //
30 // ---------------------------------------------------------------------
31 
32 #include "G4UImanager.hh"
33 #include "G4UIcommandTree.hh"
34 #include "G4UIcommand.hh"
35 #include "G4UIsession.hh"
36 #include "G4UIbatch.hh"
37 #include "G4UIcontrolMessenger.hh"
38 #include "G4UnitsMessenger.hh"
40 #include "G4ios.hh"
41 #include "G4strstreambuf.hh"
42 #include "G4StateManager.hh"
43 #include "G4UIaliasList.hh"
44 #include "G4Tokenizer.hh"
45 #include "G4MTcoutDestination.hh"
46 #include "G4UIbridge.hh"
47 #include "G4Threading.hh"
48 
49 #include <sstream>
50 #include <fstream>
51 
52 G4ThreadLocal G4UImanager * G4UImanager::fUImanager = 0;
53 G4ThreadLocal G4bool G4UImanager::fUImanagerHasBeenKilled = false;
54 G4UImanager * G4UImanager::fMasterUImanager = 0;
55 G4bool G4UImanager::doublePrecisionStr = false;
56 
57 G4int G4UImanager::igThreadID = -1;
58 
60 {
61  if(!fUImanager)
62  {
63  if(!fUImanagerHasBeenKilled)
64  {
65  fUImanager = new G4UImanager;
66  fUImanager->CreateMessenger();
67  }
68  }
69  return fUImanager;
70 }
71 
73 { return fMasterUImanager; }
74 
76  : G4VStateDependent(true),
77  UImessenger(0), UnitsMessenger(0), CoutMessenger(0),
78  isMaster(false),bridges(0),
79  ignoreCmdNotFound(false), stackCommandsForBroadcast(false),
80  threadID(-1), threadCout(0)
81 {
82  savedCommand = 0;
83  treeTop = new G4UIcommandTree("/");
84  aliasList = new G4UIaliasList;
85  G4String nullString;
86  savedParameters = nullString;
87  verboseLevel = 0;
88  saveHistory = false;
89  session = NULL;
90  g4UIWindow = NULL;
91  SetCoutDestination(session);
92  pauseAtBeginOfEvent = false;
93  pauseAtEndOfEvent = false;
94  maxHistSize = 20;
95  searchPath="";
96  commandStack = new std::vector<G4String>;
97 }
98 
99 void G4UImanager::CreateMessenger()
100 {
101  UImessenger = new G4UIcontrolMessenger;
102  UnitsMessenger = new G4UnitsMessenger;
103  CoutMessenger = new G4LocalThreadCoutMessenger;
104 }
105 
107 {
108  if(bridges)
109  {
110  std::vector<G4UIbridge*>::iterator itr = bridges->begin();
111  for(;itr!=bridges->end();itr++)
112  { delete *itr; }
113  delete bridges;
114  }
115  SetCoutDestination(NULL);
116  histVec.clear();
117  if(saveHistory) historyFile.close();
118  delete CoutMessenger;
119  delete UnitsMessenger;
120  delete UImessenger;
121  delete treeTop;
122  delete aliasList;
123  fUImanagerHasBeenKilled = true;
124  fUImanager = NULL;
125  if(commandStack)
126  {
127  commandStack->clear();
128  delete commandStack;
129  }
130  if(threadID >= 0)
131  {
132  if(threadCout) delete threadCout;
134  threadID = -1;
135  }
136 }
137 
139  : G4VStateDependent(true)
140 {
141  UImessenger = ui.UImessenger;
142  UnitsMessenger = ui.UnitsMessenger;
143  aliasList = ui.aliasList;
144  g4UIWindow = ui.g4UIWindow;
145  savedCommand= ui.savedCommand;
146  session = ui.session;
147  treeTop = ui.treeTop;
148  verboseLevel = ui.verboseLevel;
149  saveHistory = ui.saveHistory;
150  CoutMessenger = 0;
151  maxHistSize = ui.maxHistSize;
152  pauseAtBeginOfEvent = ui.pauseAtBeginOfEvent;
153  pauseAtEndOfEvent = ui.pauseAtEndOfEvent;
154  isMaster = ui.isMaster;
155  bridges = ui.bridges;
156  ignoreCmdNotFound = ui.ignoreCmdNotFound;
157  stackCommandsForBroadcast = ui.stackCommandsForBroadcast;
158  commandStack = ui.commandStack;
159  threadID = ui.threadID;
160  threadCout = ui.threadCout;
161  CreateMessenger();
162 }
163 
164 const G4UImanager & G4UImanager::operator=(const G4UImanager &right)
165 { return right; }
166 G4int G4UImanager::operator==(const G4UImanager &right) const
167 { return (this==&right); }
168 G4int G4UImanager::operator!=(const G4UImanager &right) const
169 { return (this!=&right); }
170 
172 {
173  G4String theCommand = aCommand;
174  savedCommand = treeTop->FindPath( theCommand );
175  if( savedCommand == NULL )
176  {
177  G4cerr << "command not found" << G4endl;
178  return G4String();
179  }
180  return savedCommand->GetCurrentValue();
181 }
182 
184 G4int parameterNumber, G4bool reGet)
185 {
186  if(reGet || savedCommand == NULL)
187  {
188  savedParameters = GetCurrentValues( aCommand );
189  }
190  G4Tokenizer savedToken( savedParameters );
191  G4String token;
192  for(G4int i_thParameter=0;i_thParameter<parameterNumber;i_thParameter++)
193  {
194  token = savedToken();
195  if( token.isNull() ) return G4String();
196  if( token[(size_t)0] == '"' )
197  {
198  token.append(" ");
199  token.append(savedToken("\""));
200  }
201  }
202  return token;
203 }
204 
206 const char * aParameterName, G4bool reGet)
207 {
208  if(reGet || savedCommand == NULL)
209  {
210  G4String parameterValues = GetCurrentValues( aCommand );
211  }
212  for(G4int i=0;i<savedCommand->GetParameterEntries();i++)
213  {
214  if( aParameterName ==
215  savedCommand->GetParameter(i)->GetParameterName() )
216  return GetCurrentStringValue(aCommand,i+1,false);
217  }
218  return G4String();
219 }
220 
222 const char * aParameterName, G4bool reGet)
223 {
224  G4String targetParameter =
225  GetCurrentStringValue( aCommand, aParameterName, reGet );
226  G4int value;
227  const char* t = targetParameter;
228  std::istringstream is(t);
229  is >> value;
230  return value;
231 }
232 
234 G4int parameterNumber, G4bool reGet)
235 {
236  G4String targetParameter =
237  GetCurrentStringValue( aCommand, parameterNumber, reGet );
238  G4int value;
239  const char* t = targetParameter;
240  std::istringstream is(t);
241  is >> value;
242  return value;
243 }
244 
246 const char * aParameterName, G4bool reGet)
247 {
248  G4String targetParameter =
249  GetCurrentStringValue( aCommand, aParameterName, reGet );
250  G4double value;
251  const char* t = targetParameter;
252  std::istringstream is(t);
253  is >> value;
254  return value;
255 }
256 
258 G4int parameterNumber, G4bool reGet)
259 {
260  G4String targetParameter =
261  GetCurrentStringValue( aCommand, parameterNumber, reGet );
262  G4double value;
263  const char* t = targetParameter;
264  std::istringstream is(t);
265  is >> value;
266  return value;
267 }
268 
270 {
271  treeTop->AddNewCommand( newCommand );
272  if(fMasterUImanager!=0&&G4Threading::G4GetThreadId()==0)
273  { fMasterUImanager->AddWorkerCommand(newCommand); }
274 }
275 
276 void G4UImanager::AddWorkerCommand(G4UIcommand * newCommand)
277 {
278  treeTop->AddNewCommand( newCommand, true );
279 }
280 
282 {
283  treeTop->RemoveCommand( aCommand );
284  if(fMasterUImanager!=0&&G4Threading::G4GetThreadId()==0)
285  { fMasterUImanager->RemoveWorkerCommand(aCommand); }
286 }
287 
288 void G4UImanager::RemoveWorkerCommand(G4UIcommand * aCommand)
289 {
290  treeTop->RemoveCommand( aCommand, true );
291 }
292 
293 void G4UImanager::ExecuteMacroFile(const char * fileName)
294 {
295  G4UIsession* batchSession = new G4UIbatch(fileName,session);
296  session = batchSession;
297  G4UIsession* previousSession = session->SessionStart();
298  delete session;
299  session = previousSession;
300 }
301 
302 void G4UImanager::LoopS(const char* valueList)
303 {
304  G4String vl = valueList;
305  G4Tokenizer parameterToken(vl);
306  G4String mf = parameterToken();
307  G4String vn = parameterToken();
308  G4String c1 = parameterToken();
309  c1 += " ";
310  c1 += parameterToken();
311  c1 += " ";
312  c1 += parameterToken();
313  const char* t1 = c1;
314  std::istringstream is(t1);
315  G4double d1;
316  G4double d2;
317  G4double d3;
318  is >> d1 >> d2 >> d3;
319  Loop(mf,vn,d1,d2,d3);
320 }
321 
322 void G4UImanager::Loop(const char * macroFile,const char * variableName,
323  G4double initialValue,G4double finalValue,G4double stepSize)
324 {
325  G4String cd;
326  if (stepSize > 0) {
327  for(G4double d=initialValue;d<=finalValue;d+=stepSize)
328  {
329  std::ostringstream os;
330  os << d;
331  cd += os.str();
332  cd += " ";
333  }
334  } else {
335  for(G4double d=initialValue;d>=finalValue;d+=stepSize)
336  {
337  std::ostringstream os;
338  os << d;
339  cd += os.str();
340  cd += " ";
341  }
342  }
343  Foreach(macroFile,variableName,cd);
344 }
345 
346 void G4UImanager::ForeachS(const char* valueList)
347 {
348  G4String vl = valueList;
349  G4Tokenizer parameterToken(vl);
350  G4String mf = parameterToken();
351  G4String vn = parameterToken();
352  G4String c1 = parameterToken();
353  G4String ca;
354  while(!((ca=parameterToken()).isNull()))
355  {
356  c1 += " ";
357  c1 += ca;
358  }
359 
360  G4String aliasValue = c1;
361  if(aliasValue(0)=='"')
362  {
363  G4String strippedValue;
364  if(aliasValue(aliasValue.length()-1)=='"')
365  { strippedValue = aliasValue(1,aliasValue.length()-2); }
366  else
367  { strippedValue = aliasValue(1,aliasValue.length()-1); }
368  aliasValue = strippedValue;
369  }
370 
371 // Foreach(mf,vn,c1);
372  Foreach(mf,vn,aliasValue);
373 }
374 
375 void G4UImanager::Foreach(const char * macroFile,const char * variableName,
376  const char * candidates)
377 {
378  G4String candidatesString = candidates;
379  G4Tokenizer parameterToken( candidatesString );
380  G4String cd;
381  while(!((cd=parameterToken()).isNull()))
382  {
383  G4String vl = variableName;
384  vl += " ";
385  vl += cd;
386  SetAlias(vl);
387  ExecuteMacroFile(FindMacroPath(macroFile));
388  }
389 }
390 
391 
393 {
394  G4String aCommand = aCmd;
395  G4int ia = aCommand.index("{");
396  G4int iz = aCommand.index("#");
397  while((ia != G4int(std::string::npos))&&((iz==G4int(std::string::npos))||(ia<iz)))
398  {
399  G4int ibx = -1;
400  while(ibx<0)
401  {
402  G4int ib = aCommand.index("}");
403  if( ib == G4int(std::string::npos) )
404  {
405  G4cerr << aCommand << G4endl;
406  for(G4int i=0;i<ia;i++) G4cerr << " ";
407  G4cerr << "^" << G4endl;
408  G4cerr << "Unmatched alias parenthis -- command ignored" << G4endl;
409  G4String nullStr;
410  return nullStr;
411  }
412  G4String ps = aCommand(ia+1,aCommand.length()-(ia+1));
413  G4int ic = ps.index("{");
414  G4int id = ps.index("}");
415  if(ic!=G4int(std::string::npos) && ic < id)
416  { ia+=ic+1; }
417  else
418  { ibx = ib; }
419  }
420  //--- Here ia represents the position of innermost "{"
421  //--- and ibx represents corresponding "}"
422  G4String subs;
423  if(ia>0) subs = aCommand(0,ia);
424  G4String alis = aCommand(ia+1,ibx-ia-1);
425  G4String rems = aCommand(ibx+1,aCommand.length()-ibx);
426  // G4cout << "<" << subs << "> <" << alis << "> <" << rems << ">" << G4endl;
427  G4String* alVal = aliasList->FindAlias(alis);
428  if(!alVal)
429  {
430  G4cerr << "Alias <" << alis << "> not found -- command ignored" << G4endl;
431  G4String nullStr;
432  return nullStr;
433  }
434  aCommand = subs+(*alVal)+rems;
435  ia = aCommand.index("{");
436  }
437  return aCommand;
438 }
439 
441 {
442  return ApplyCommand(aCmd.data());
443 }
444 
445 #include "G4Threading.hh"
446 
448 {
449  G4String aCommand = SolveAlias(aCmd);
450  if(aCommand.isNull()) return fAliasNotFound;
451  if(verboseLevel) G4cout << aCommand << G4endl;
452  G4String commandString;
453  G4String commandParameter;
454 
455  G4int i = aCommand.index(" ");
456  if( i != G4int(std::string::npos) )
457  {
458  commandString = aCommand(0,i);
459  commandParameter = aCommand(i+1,aCommand.length()-(i+1));
460  }
461  else
462  {
463  commandString = aCommand;
464  }
465 
466  // remove doubled slash
467  G4int len = commandString.length();
468  G4int ll = 0;
469  G4String a1;
470  G4String a2;
471  while(ll<len-1)
472  {
473  if(commandString(ll,2)=="//")
474  {
475  if(ll==0)
476  { commandString.remove(ll,1); }
477  else
478  {
479  a1 = commandString(0,ll);
480  a2 = commandString(ll+1,len-ll-1);
481  commandString = a1+a2;
482  }
483  len--;
484  }
485  else
486  { ll++; }
487  }
488 
489  if(isMaster&&bridges)
490  {
491  std::vector<G4UIbridge*>::iterator itr = bridges->begin();
492  for(;itr!=bridges->end();itr++)
493  {
494  G4int leng = (*itr)->DirLength();
495  if(commandString(0,leng)==(*itr)->DirName())
496  { return (*itr)->LocalUI()->ApplyCommand(commandString+" "+commandParameter); }
497  }
498  }
499 
500  G4UIcommand * targetCommand = treeTop->FindPath( commandString );
501  if( targetCommand == NULL )
502  {
503  if(ignoreCmdNotFound)
504  {
505  if(stackCommandsForBroadcast)
506  { commandStack->push_back(commandString+" "+commandParameter); }
507  return fCommandSucceeded;
508  }
509  else
510  { return fCommandNotFound; }
511  }
512 
513  if(stackCommandsForBroadcast && targetCommand->ToBeBroadcasted())
514  { commandStack->push_back(commandString+" "+commandParameter); }
515 
516  if(!(targetCommand->IsAvailable()))
517  { return fIllegalApplicationState; }
518 
519  if(saveHistory) historyFile << aCommand << G4endl;
520  if( G4int(histVec.size()) >= maxHistSize )
521  { histVec.erase(histVec.begin()); }
522  histVec.push_back(aCommand);
523 
524  return targetCommand->DoIt( commandParameter );
525 }
526 
527 void G4UImanager::StoreHistory(const char* fileName)
528 { StoreHistory(true,fileName); }
529 
530 void G4UImanager::StoreHistory(G4bool historySwitch,const char* fileName)
531 {
532  if(historySwitch)
533  {
534  if(saveHistory)
535  { historyFile.close(); }
536  historyFile.open((char*)fileName);
537  saveHistory = true;
538  }
539  else
540  {
541  historyFile.close();
542  saveHistory = false;
543  }
544  saveHistory = historySwitch;
545 }
546 
547 void G4UImanager::PauseSession(const char* msg)
548 {
549  if(session) session->PauseSessionStart(msg);
550 }
551 
552 void G4UImanager::ListCommands(const char* direct)
553 {
554  G4UIcommandTree* comTree = FindDirectory(direct);
555  if(comTree)
556  { comTree->List(); }
557  else
558  { G4cout << direct << " is not found." << G4endl; }
559 }
560 
561 G4UIcommandTree* G4UImanager::FindDirectory(const char* dirName)
562 {
563  G4String aDirName = dirName;
564  G4String targetDir = aDirName.strip(G4String::both);
565  if( targetDir( targetDir.length()-1 ) != '/' )
566  { targetDir += "/"; }
567  G4UIcommandTree* comTree = treeTop;
568  if( targetDir == "/" )
569  { return comTree; }
570  G4int idx = 1;
571  while( idx < G4int(targetDir.length())-1 )
572  {
573  G4int i = targetDir.index("/",idx);
574  G4String targetDirString = targetDir(0,i+1);
575  comTree = comTree->GetTree(targetDirString);
576  if( comTree == NULL )
577  { return NULL; }
578  idx = i+1;
579  }
580  return comTree;
581 }
582 
584 {
585  //G4cout << G4StateManager::GetStateManager()->GetStateString(requestedState) << " <--- " << G4StateManager::GetStateManager()->GetStateString(G4StateManager::GetStateManager()->GetPreviousState()) << G4endl;
586  if(pauseAtBeginOfEvent)
587  {
588  if(requestedState==G4State_EventProc &&
590  { PauseSession("BeginOfEvent"); }
591  }
592  if(pauseAtEndOfEvent)
593  {
594  if(requestedState==G4State_GeomClosed &&
595  G4StateManager::GetStateManager()->GetPreviousState()==G4State_EventProc)
596  { PauseSession("EndOfEvent"); }
597  }
598  return true;
599 }
600 
601 //void G4UImanager::Interact()
602 //{
603 // Interact(G4String("G4> "));
604 //}
605 
606 //void G4UImanager::Interact(const char * pC)
607 //{
608 // G4cerr << "G4UImanager::Interact() is out of date and is not used anymore." << G4endl;
609 // G4cerr << "This method will be removed shortly!!!" << G4endl;
610 // G4cerr << "In case of main() use" << G4endl;
611 // G4cerr << " G4UIsession * session = new G4UIterminal;" << G4endl;
612 // G4cerr << " session->SessionStart();" << G4endl;
613 // G4cerr << "In other cases use" << G4endl;
614 // G4cerr << " G4StateManager::GetStateManager()->Pause();" << G4endl;
615 //}
616 
617 
618 
620 {
621  G4coutbuf.SetDestination(value);
622  G4cerrbuf.SetDestination(value);
623 }
624 
625 void G4UImanager::SetAlias(const char * aliasLine)
626 {
627  G4String aLine = aliasLine;
628  G4int i = aLine.index(" ");
629  G4String aliasName = aLine(0,i);
630  G4String aliasValue = aLine(i+1,aLine.length()-(i+1));
631  if(aliasValue(0)=='"')
632  {
633  G4String strippedValue;
634  if(aliasValue(aliasValue.length()-1)=='"')
635  { strippedValue = aliasValue(1,aliasValue.length()-2); }
636  else
637  { strippedValue = aliasValue(1,aliasValue.length()-1); }
638  aliasValue = strippedValue;
639  }
640 
641  aliasList->ChangeAlias(aliasName,aliasValue);
642 }
643 
644 void G4UImanager::RemoveAlias(const char * aliasName)
645 {
646  G4String aL = aliasName;
647  G4String targetAlias = aL.strip(G4String::both);
648  aliasList->RemoveAlias(targetAlias);
649 }
650 
652 {
653  aliasList->List();
654 }
655 
656 void G4UImanager::CreateHTML(const char* dir)
657 {
658  G4UIcommandTree* tr = FindDirectory(dir);
659  if(tr!=0)
660  { tr->CreateHTML(); }
661  else
662  { G4cerr << "Directory <" << dir << "> is not found." << G4endl; }
663 }
664 
666 {
667  searchDirs.clear();
668 
669  size_t idxfirst = 0;
670  size_t idxend = 0;
671  G4String pathstring = "";
672  while( (idxend = searchPath.index(':', idxfirst)) != G4String::npos) {
673  pathstring = searchPath.substr(idxfirst, idxend-idxfirst);
674  if(pathstring.size() != 0) searchDirs.push_back(pathstring);
675  idxfirst = idxend + 1;
676  }
677 
678  pathstring = searchPath.substr(idxfirst, searchPath.size()-idxfirst);
679  if(pathstring.size() != 0) searchDirs.push_back(pathstring);
680 }
681 
682 
683 static G4bool FileFound(const G4String& fname)
684 {
685  G4bool qopen = false;
686  std::ifstream fs;
687  fs.open(fname.c_str(), std::ios::in);
688  if(fs.good()) {
689  fs.close();
690  qopen = true;
691  }
692  return qopen;
693 }
694 
696 {
697  G4String macrofile = fname;
698 
699  for (size_t i = 0; i < searchDirs.size(); i++) {
700  G4String fullpath = searchDirs[i] + "/" + fname;
701  if ( FileFound(fullpath) ) {
702  macrofile = fullpath;
703  break;
704  }
705  }
706 
707  return macrofile;
708 }
709 
710 std::vector<G4String>* G4UImanager::GetCommandStack()
711 {
712  std::vector<G4String>* returnValue = commandStack;
713  commandStack = new std::vector<G4String>;
714  return returnValue;
715 }
716 
718 {
719  if(brg->LocalUI()==this)
720  {
721  G4Exception("G4UImanager::RegisterBridge()","UI7002",FatalException,
722  "G4UIBridge cannot bridge between same object.");
723  }
724  else
725  { bridges->push_back(brg); }
726 }
727 
729 {
730  threadID = tId;
732  threadCout = new G4MTcoutDestination(threadID);
733  threadCout->SetIgnoreCout(igThreadID);
734 }
735 
737 {
739  G4Threading::G4SetThreadId(threadID);
741  threadCout = new G4MTcoutDestination(threadID);
742  threadCout->SetPrefixString(pref);
743  threadCout->SetIgnoreCout(igThreadID);
744 }
745 
746 void G4UImanager::SetCoutFileName(const G4String& fileN, G4bool ifAppend)
747 {
748  // for sequential mode, ignore this method.
749  if(threadID<0) return;
750 
751  if(fileN == "**Screen**")
752  { threadCout->SetCoutFileName(fileN,ifAppend); }
753  else
754  {
755  std::stringstream fn;
756  fn<<"G4W_"<<threadID<<"_"<<fileN;
757  threadCout->SetCoutFileName(fn.str(),ifAppend);
758  }
759 }
760 
761 void G4UImanager::SetCerrFileName(const G4String& fileN, G4bool ifAppend)
762 {
763  // for sequential mode, ignore this method.
764  if(threadID<0) return;
765 
766  if(fileN == "**Screen**")
767  { threadCout->SetCerrFileName(fileN,ifAppend); }
768  else
769  {
770  std::stringstream fn;
771  fn<<"G4W_"<<threadID<<"_"<<fileN;
772  threadCout->SetCerrFileName(fn.str(),ifAppend);
773  }
774 }
775 
777 {
778  // for sequential mode, ignore this method.
779  if(threadID<0) return;
780  threadCout->SetPrefixString(s);
781 }
782 
784 {
785  // for sequential mode, ignore this method.
786  if(threadID<0) return;
787  threadCout->EnableBuffering(flg);
788 }
789 
791 {
792  // for sequential mode, ignore this method.
793  if(threadID<0)
794  {
795  igThreadID = tid;
796  return;
797  }
798  threadCout->SetIgnoreCout(tid);
799 }
800 
802 {
803  // for sequential mode, ignore this method.
804  if(threadID<0) { return; }
805  threadCout->SetIgnoreInit(flg);
806 }
807 
const XML_Char int len
Definition: expat.h:262
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:346
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:293
void Foreach(const char *macroFile, const char *variableName, const char *candidates)
Definition: G4UImanager.cc:375
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:644
void SetThreadPrefixString(const G4String &s="W")
Definition: G4UImanager.cc:776
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:625
G4bool IsAvailable()
Definition: G4UIcommand.cc:290
void SetUpForAThread(G4int tId)
Definition: G4UImanager.cc:728
virtual void PauseSessionStart(const G4String &Prompt)
Definition: G4UIsession.cc:48
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:183
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
Definition: G4UImanager.cc:746
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
static G4UImanager * GetMasterUIpointer()
Definition: G4UImanager.cc:72
G4String & remove(str_size)
void RegisterBridge(G4UIbridge *brg)
Definition: G4UImanager.cc:717
G4UIcommand * FindPath(const char *commandPath) const
G4String strip(G4int strip_Type=trailing, char c=' ')
static const G4double d2
G4String GetParameterName() const
void G4SetThreadId(G4int aNewValue)
Definition: G4Threading.cc:147
static G4bool FileFound(const G4String &fname)
Definition: G4UImanager.cc:683
G4GLOB_DLL G4strstreambuf G4coutbuf
Definition: G4ios.cc:82
static const G4double cd
void SetThreadUseBuffer(G4bool flg=true)
Definition: G4UImanager.cc:783
virtual G4UIsession * SessionStart()
Definition: G4UIsession.cc:46
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
std::vector< G4String > * GetCommandStack()
Definition: G4UImanager.cc:710
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
Definition: G4UImanager.cc:761
void SetPrefixString(const G4String &wd="G4WT")
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
void SetIgnoreInit(G4bool val=true)
void ParseMacroSearchPath()
Definition: G4UImanager.cc:665
G4GLOB_DLL G4strstreambuf G4cerrbuf
Definition: G4ios.cc:83
const XML_Char * s
Definition: expat.h:262
static G4StateManager * GetStateManager()
void SetThreadIgnoreInit(G4bool flg=true)
Definition: G4UImanager.cc:801
G4bool ToBeBroadcasted() const
Definition: G4UIcommand.hh:186
G4GLOB_DLL std::ostream G4cout
str_size index(const char *, G4int pos=0) const
const XML_Char int const XML_Char * value
Definition: expat.h:331
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)
Definition: G4UImanager.cc:322
bool G4bool
Definition: G4Types.hh:79
G4UIparameter * GetParameter(G4int i) const
Definition: G4UIcommand.hh:145
void EnableBuffering(G4bool flag=true)
void RemoveCommand(G4UIcommand *aCommand)
Definition: G4UImanager.cc:281
void RemoveCommand(G4UIcommand *aCommand, G4bool workerThreadOnly=false)
G4int GetCurrentIntValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:233
G4String * FindAlias(const char *aliasName)
static const G4double d1
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetIgnoreCout(G4int tid=0)
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:171
const char * data() const
void ListCommands(const char *direc)
Definition: G4UImanager.cc:552
void SetDestination(G4coutDestination *dest)
void AddNewCommand(G4UIcommand *newCommand, G4bool workerThreadOnly=false)
void AddNewCommand(G4UIcommand *newCommand)
Definition: G4UImanager.cc:269
G4String & append(const G4String &)
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:619
void G4iosInitialization()
Definition: G4ios.cc:85
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:392
void ListAlias()
Definition: G4UImanager.cc:651
#define G4endl
Definition: G4ios.hh:61
void LoopS(const char *valueList)
Definition: G4UImanager.cc:302
virtual G4bool Notify(G4ApplicationState requestedState)
Definition: G4UImanager.cc:583
G4double GetCurrentDoubleValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:257
G4UImanager * LocalUI() const
Definition: G4UIbridge.hh:72
void G4iosFinalization()
Definition: G4ios.cc:86
double G4double
Definition: G4Types.hh:76
void SetUpForSpecialThread(G4String aPrefix)
Definition: G4UImanager.cc:736
void SetThreadIgnore(G4int tid=0)
Definition: G4UImanager.cc:790
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:656
static constexpr double ps
Definition: G4SIunits.hh:172
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:527
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:695
G4bool isNull() const
virtual G4int DoIt(G4String parameterList)
Definition: G4UIcommand.cc:123
G4ApplicationState
G4int G4GetThreadId()
Definition: G4Threading.cc:144
void List() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447
G4String GetCurrentValue()
Definition: G4UIcommand.cc:235
G4GLOB_DLL std::ostream G4cerr
void RemoveAlias(const char *aliasName)