Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4UIGAG Class Reference

#include <G4UIGAG.hh>

Inheritance diagram for G4UIGAG:
G4UIsession G4coutDestination

Public Member Functions

 G4UIGAG ()
 
 ~G4UIGAG ()
 
G4UIsessionSessionStart ()
 
void PauseSessionStart (const G4String &)
 
G4int ReceiveG4cout (const G4String &)
 
G4int ReceiveG4cerr (const G4String &)
 
void SessionTerminate ()
 
void Prompt (const G4String &)
 
G4String GetCommand ()
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
virtual ~G4UIsession ()
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()
 
virtual ~G4coutDestination ()
 

Detailed Description

Definition at line 53 of file G4UIGAG.hh.

Constructor & Destructor Documentation

G4UIGAG::G4UIGAG ( )

Definition at line 39 of file G4UIGAG.cc.

References G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), G4StateManager::GetStateString(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), G4UImanager::SetCoutDestination(), G4UImanager::SetSession(), terminal_mode, and gammaraytel::tree.

40 {
41  TVersion="T1.0a"; JVersion="J1.0a";
42  //G4cout << "G4UIGAG: Apr15,98." << G4endl;
43  prefix = "/";
45  UI->SetSession(this);
46  UI->SetCoutDestination(this);
48  promptCharacter = statM->GetStateString(statM->GetCurrentState());
49  uiMode = terminal_mode; // GAG
50  iExit = false;
51  iCont = false;
52  // -- Initialize Notify routines begin
53  G4UIcommandTree * tree = UI->GetTree();
54  GetNewTreeStructure(tree,0);
55  GetNewTreeValues(tree,0);
56  previousTreeCommands = newTreeCommands;
57  previousTreeParams = newTreeParams;
58  previousTreePCP = newTreePCP;
59  // -- end
60 }
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:213
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
static G4StateManager * GetStateManager()
tuple tree
Definition: gammaraytel.py:4
G4ApplicationState GetCurrentState() const
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:206
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:591
G4String GetStateString(G4ApplicationState aState) const
G4UIGAG::~G4UIGAG ( )

Definition at line 62 of file G4UIGAG.cc.

References G4UImanager::GetUIpointer(), G4UImanager::SetCoutDestination(), and G4UImanager::SetSession().

63 {
64  if( G4UImanager::GetUIpointer() != 0)
65  {
66  UI->SetSession(NULL);
67  UI->SetCoutDestination(NULL);
68  // G4cout << "GAG session deleted" << G4endl;
69  }
70 }
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:213
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:591

Member Function Documentation

G4String G4UIGAG::GetCommand ( )

Definition at line 189 of file G4UIGAG.cc.

References G4String::append(), FALSE, G4cerr, G4cin, G4cout, G4endl, G4UImanager::GetNumberOfHistory(), G4UImanager::GetPreviousCommand(), G4UImanager::GetTree(), java_mode, G4String::leading, G4String::readLine(), G4String::remove(), G4String::strip(), tcl_mode, and terminal_mode.

Referenced by PauseSessionStart(), and SessionStart().

190 {
191  G4String newCommand;
192  G4String nullString;
193  while( 1 )
194  {
195  G4UIcommandTree* tree = UI->GetTree();
196  if ( uiMode != terminal_mode ){
197  G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
198  }
199  if ( uiMode != java_mode ){
200  G4cout << promptCharacter << "> " << std::flush;
201  }else{
202  G4cout << "@@Ready" << G4endl;
203  }
204  newCommand.readLine( G4cin, FALSE );
205  if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
206 
207  newCommand = newCommand.strip(G4String::leading);
208  if( newCommand.length() < 1) { break; }
209 
210  while( newCommand(newCommand.length()-1) == '_' )
211  {
212  G4String newLine;
213  newCommand.remove(newCommand.length()-1);
214  newLine.readLine( G4cin );
215  if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
216  newCommand.append(newLine);
217  }
218 
219  G4String nC = newCommand.strip(G4String::leading);
220  if( nC.length() < 1) { break; }
221 
222  // -------------------- nC.toUpper();
223  if( nC == "@@GAGmodeJAVA" ) {
224  uiMode = java_mode;
225  G4cout << G4endl << "@@Version " << JVersion << G4endl;
226  SendCommandProperties(tree);
227  NotifyStateChange();
228  }
229  else if( nC == "@@GAGmodeTcl" ) {
230  uiMode = tcl_mode;
231  G4cout << G4endl << "@@Version " << TVersion << G4endl;
232  SendCommandProperties(tree);
233  NotifyStateChange();
234  }
235  else if( nC(0) == '#' )
236  { G4cout << nC << G4endl; }
237 
238  else if( nC == "ls" || nC(0,3) == "ls " )
239  { ListDirectory( nC ); }
240  else if( nC == "pwd" )
241  { G4cout << "Current Working Directory : " << prefix << G4endl; }
242  else if( nC(0,2) == "cd" || nC(0,3) == "cd " )
243  { ChangeDirectory( nC ); }
244  else if( nC == "help" || nC(0,5) == "help ")
245  { TerminalHelp( nC ); }
246  else if( nC(0) == '?' )
247  { ShowCurrent( nC ); }
248  else if( nC(0,4) == "hist" || nC == "history")
249  {
250  G4int nh = UI->GetNumberOfHistory();
251  for(int i=0;i<nh;i++)
252  { G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl; }
253  }
254  else if( nC(0) == '!' )
255  {
256  G4String ss = nC(1,nC.length()-1);
257  G4int vl;
258  const char* tt = ss;
259  std::istringstream is((char*)tt);
260  is >> vl;
261  G4int nh = UI->GetNumberOfHistory();
262  if(vl>=0 && vl<nh)
263  {
264  newCommand = UI->GetPreviousCommand(vl);
265  G4cout << newCommand << G4endl;
266  break;
267  }
268  else
269  { G4cerr << "history " << vl << " is not found." << G4endl; }
270  }
271  else if( nC(0,4) == "exit" )
272  {
273  if( iCont )
274  {
275  if ( uiMode == terminal_mode){
276  G4cerr << "You are now processing RUN." << G4endl;
277  G4cerr << "Please abrot it using \"/run/abort\" command first" << G4endl;
278  G4cerr << " and use \"continue\" command until the application" << G4endl;
279  G4cerr << " becomes to Idle." << G4endl;
280  }else{
281  G4cout << "@@ErrResult \"You are now processing RUN.\"" << G4endl;
282  }
283  }
284  else
285  {
286  iExit = false;
287  newCommand = nullString;
288  break;
289  }
290  }
291  else if( nC == "cont" || nC == "continue" )
292  {
293  iCont = false;
294  newCommand = nullString;
295  break;
296  }
297  else
298  { break; }
299  }
300  return GetFullPath(newCommand);
301 }
G4int GetNumberOfHistory() const
Definition: G4UImanager.hh:229
G4String GetPreviousCommand(G4int i) const
Definition: G4UImanager.hh:231
G4String & remove(str_size)
G4String strip(G4int strip_Type=trailing, char c=' ')
std::istream & readLine(std::istream &, G4bool skipWhite=true)
int G4int
Definition: G4Types.hh:78
#define G4cin
Definition: G4ios.hh:60
G4GLOB_DLL std::ostream G4cout
tuple tree
Definition: gammaraytel.py:4
#define FALSE
Definition: globals.hh:52
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:206
G4String & append(const G4String &)
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
void G4UIGAG::PauseSessionStart ( const G4String msg)
virtual

Reimplemented from G4UIsession.

Definition at line 87 of file G4UIGAG.cc.

References G4cout, G4endl, and GetCommand().

88 {
89  promptCharacter = msg;
90  G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
91  iCont = true;
92  G4String newCommand = GetCommand();
93  while( iCont )
94  {
95  ExecuteCommand(newCommand);
96  newCommand = GetCommand();
97  }
98 }
G4GLOB_DLL std::ostream G4cout
G4String GetCommand()
Definition: G4UIGAG.cc:189
#define G4endl
Definition: G4ios.hh:61
void G4UIGAG::Prompt ( const G4String aPrompt)

Definition at line 184 of file G4UIGAG.cc.

185 {
186  promptCharacter = aPrompt;
187 }
G4int G4UIGAG::ReceiveG4cerr ( const G4String cerrString)
virtual

Reimplemented from G4UIsession.

Definition at line 178 of file G4UIGAG.cc.

179 {
180  std::cerr << cerrString << std::flush;
181  return 0;
182 }
G4int G4UIGAG::ReceiveG4cout ( const G4String coutString)
virtual

Reimplemented from G4UIsession.

Definition at line 172 of file G4UIGAG.cc.

173 {
174  std::cout << coutString << std::flush;
175  return 0;
176 }
G4UIsession * G4UIGAG::SessionStart ( )
virtual

Reimplemented from G4UIsession.

Definition at line 72 of file G4UIGAG.cc.

References GetCommand(), G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), and G4StateManager::GetStateString().

73 {
74  iExit = true;
76  promptCharacter = statM->GetStateString(statM->GetCurrentState());
77  G4String newCommand = GetCommand();
78  while( iExit )
79  {
80  ExecuteCommand(newCommand);
81  promptCharacter = statM->GetStateString(statM->GetCurrentState());
82  newCommand = GetCommand();
83  }
84  return NULL;
85 }
static G4StateManager * GetStateManager()
G4ApplicationState GetCurrentState() const
G4String GetCommand()
Definition: G4UIGAG.cc:189
G4String GetStateString(G4ApplicationState aState) const
void G4UIGAG::SessionTerminate ( )

Definition at line 337 of file G4UIGAG.cc.

References G4cout, and G4endl.

338 {
339  G4cout << "***** Terminal session end *****" << G4endl;
340 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

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