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 ()

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(), and terminal_mode.

00039                   : TVersion("T1.0a"), JVersion("J1.0a")
00040 {
00041  TVersion="T1.0a"; JVersion="J1.0a";
00042   //G4cout << "G4UIGAG: Apr15,98." << G4endl;
00043   prefix = "/";
00044   UI = G4UImanager::GetUIpointer();
00045   UI->SetSession(this);
00046   UI->SetCoutDestination(this); 
00047   G4StateManager * statM = G4StateManager::GetStateManager();
00048   promptCharacter = statM->GetStateString(statM->GetCurrentState());
00049   uiMode = terminal_mode; // GAG
00050   iExit = false;
00051   iCont = false;
00052   // -- Initialize Notify routines begin
00053   G4UIcommandTree * tree = UI->GetTree();
00054   GetNewTreeStructure(tree,0);
00055   GetNewTreeValues(tree,0);
00056   previousTreeCommands = newTreeCommands;
00057   previousTreeParams = newTreeParams;
00058   previousTreePCP = newTreePCP;
00059   // -- end
00060 }

G4UIGAG::~G4UIGAG (  ) 

Definition at line 62 of file G4UIGAG.cc.

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

00063 {
00064   if( G4UImanager::GetUIpointer() != 0)
00065   {
00066      UI->SetSession(NULL);
00067      UI->SetCoutDestination(NULL);
00068      //     G4cout << "GAG session deleted" << G4endl;
00069   }
00070 }                                                 


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().

00190 {
00191   G4String newCommand;
00192   G4String nullString;
00193   while( 1 )
00194   {
00195     G4UIcommandTree* tree = UI->GetTree();
00196     if ( uiMode != terminal_mode ){
00197       G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
00198     }
00199     if ( uiMode != java_mode ){
00200       G4cout << promptCharacter << "> " << std::flush;
00201     }else{
00202       G4cout << "@@Ready" << G4endl;
00203     }
00204     newCommand.readLine( G4cin, FALSE );
00205     if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
00206 
00207     newCommand = newCommand.strip(G4String::leading);
00208     if( newCommand.length() < 1) { break; }
00209 
00210     while( newCommand(newCommand.length()-1) == '_' )
00211     {
00212       G4String newLine;
00213       newCommand.remove(newCommand.length()-1);
00214       newLine.readLine( G4cin );
00215       if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
00216       newCommand.append(newLine);
00217     }
00218 
00219     G4String nC = newCommand.strip(G4String::leading);
00220     if( nC.length() < 1) { break; }
00221 
00222     // -------------------- nC.toUpper();
00223     if( nC == "@@GAGmodeJAVA" ) {
00224       uiMode = java_mode;
00225       G4cout << G4endl << "@@Version " << JVersion << G4endl;
00226       SendCommandProperties(tree);
00227       NotifyStateChange();
00228     }
00229     else if( nC == "@@GAGmodeTcl" ) {
00230       uiMode = tcl_mode;
00231       G4cout << G4endl << "@@Version " << TVersion << G4endl;
00232       SendCommandProperties(tree);
00233       NotifyStateChange();
00234     }
00235     else if( nC(0) == '#' )
00236       { G4cout << nC << G4endl; }
00237 
00238     else if( nC == "ls"  || nC(0,3) == "ls " )
00239     { ListDirectory( nC ); }
00240     else if( nC == "pwd" )
00241     { G4cout << "Current Working Directory : " << prefix << G4endl; }
00242     else if( nC(0,2) == "cd"  || nC(0,3) == "cd " )
00243     { ChangeDirectory( nC ); }
00244     else if(  nC == "help" || nC(0,5) == "help ")
00245     { TerminalHelp( nC ); }
00246     else if( nC(0) == '?' )
00247     { ShowCurrent( nC ); }
00248     else if( nC(0,4) == "hist"   || nC == "history")
00249     {
00250       G4int nh = UI->GetNumberOfHistory();
00251       for(int i=0;i<nh;i++)
00252       { G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl; }
00253     }
00254     else if( nC(0) == '!' )
00255     {
00256       G4String ss = nC(1,nC.length()-1);
00257       G4int vl;
00258       const char* tt = ss;
00259       std::istringstream is((char*)tt);
00260       is >> vl;
00261       G4int nh = UI->GetNumberOfHistory();
00262       if(vl>=0 && vl<nh)
00263       { 
00264         newCommand = UI->GetPreviousCommand(vl); 
00265         G4cout << newCommand << G4endl;
00266         break;
00267       }
00268       else
00269       { G4cerr << "history " << vl << " is not found." << G4endl; }
00270     }
00271     else if( nC(0,4) == "exit" )
00272     { 
00273       if( iCont )
00274       { 
00275         if ( uiMode == terminal_mode){
00276           G4cerr << "You are now processing RUN." << G4endl;
00277           G4cerr << "Please abrot it using \"/run/abort\" command first" << G4endl;
00278           G4cerr << " and use \"continue\" command until the application" << G4endl;
00279           G4cerr << " becomes to Idle." << G4endl;
00280         }else{
00281           G4cout << "@@ErrResult \"You are now processing RUN.\"" << G4endl;
00282         }
00283       }
00284       else
00285       {
00286         iExit = false;
00287         newCommand = nullString;
00288         break;
00289       }
00290     }
00291     else if(  nC == "cont" || nC == "continue" )
00292     { 
00293       iCont = false;
00294       newCommand = nullString;
00295       break;
00296     }
00297     else
00298     { break; }
00299   }
00300   return GetFullPath(newCommand);
00301 }

void G4UIGAG::PauseSessionStart ( const G4String  )  [virtual]

Reimplemented from G4UIsession.

Definition at line 87 of file G4UIGAG.cc.

References G4cout, G4endl, and GetCommand().

00088 {
00089   promptCharacter = msg;
00090   G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
00091   iCont = true;
00092   G4String newCommand = GetCommand();
00093   while( iCont )
00094   {
00095     ExecuteCommand(newCommand);
00096     newCommand = GetCommand();
00097   }
00098 }

void G4UIGAG::Prompt ( const G4String  ) 

Definition at line 184 of file G4UIGAG.cc.

00185 {
00186   promptCharacter = aPrompt;
00187 }

G4int G4UIGAG::ReceiveG4cerr ( const G4String  )  [virtual]

Reimplemented from G4UIsession.

Definition at line 178 of file G4UIGAG.cc.

00179 {
00180   std::cerr << cerrString << std::flush;
00181   return 0;
00182 }                                                    

G4int G4UIGAG::ReceiveG4cout ( const G4String  )  [virtual]

Reimplemented from G4UIsession.

Definition at line 172 of file G4UIGAG.cc.

00173 {
00174   std::cout << coutString << std::flush;
00175   return 0;
00176 }

G4UIsession * G4UIGAG::SessionStart (  )  [virtual]

Reimplemented from G4UIsession.

Definition at line 72 of file G4UIGAG.cc.

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

00073 {
00074   iExit = true;
00075   G4StateManager * statM = G4StateManager::GetStateManager();
00076   promptCharacter = statM->GetStateString(statM->GetCurrentState());
00077   G4String newCommand = GetCommand();
00078   while( iExit )
00079   {
00080     ExecuteCommand(newCommand);
00081     promptCharacter = statM->GetStateString(statM->GetCurrentState());
00082     newCommand = GetCommand();
00083   }
00084   return NULL;
00085 }

void G4UIGAG::SessionTerminate (  ) 

Definition at line 337 of file G4UIGAG.cc.

References G4cout, and G4endl.

00338 {
00339   G4cout << "***** Terminal session end *****" << G4endl;
00340 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:37 2013 for Geant4 by  doxygen 1.4.7