Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# G4UIterminal Class Reference

`#include <G4UIterminal.hh>`

Inheritance diagram for G4UIterminal:

[legend]
Collaboration diagram for G4UIterminal:

[legend]
List of all members.

## Public Member Functions
| G4UIterminal (G4VUIshell *aShell=0)
| ~G4UIterminal ()
void | SetPrompt (const G4String &prompt)
virtual G4UIsession * | SessionStart ()
virtual void | PauseSessionStart (G4String msg)
virtual G4int | ReceiveG4cout (G4String coutString)
virtual G4int | ReceiveG4cerr (G4String cerrString)
## Private Member Functions
void | ExecuteCommand (G4String aCommand)
G4String | GetCommand (const char *msg=0)
G4bool | GetHelpChoice (G4int &aInt)
void | ExitHelp ()
## Private Attributes
G4UImanager * | UI
G4VUIshell * | shell
G4bool | iExit
G4bool | iCont

## Constructor & Destructor Documentation

G4UIterminal::G4UIterminal | ( | G4VUIshell * | aShell = 0 | ) |

| Definition at line 42 of file G4UIterminal.cc. References iCont, iExit, shell, and UI.
    00044 {
    00045   UI= G4UImanager::GetUIpointer();
    00046   UI-> SetSession(this);
    00047   UI-> SetCoutDestination(this);
    00048
    00049   iExit= FALSE;
    00050   iCont= FALSE;
    00051
    00052   if(aShell) shell= aShell;
    00053   else shell= new G4UIcsh;
    00054 }

G4UIterminal::~G4UIterminal | ( |  | ) |

| Definition at line 57 of file G4UIterminal.cc. References shell, and UI.
    00059 {
    00060   if(shell) delete shell;
    00061
    00062   if(G4UImanager::GetUIpointer()) {
    00063     UI-> SetSession(NULL);
    00064     UI-> SetCoutDestination(NULL);
    00065   }
    00066 }

## Member Function Documentation

void G4UIterminal::ExecuteCommand | ( | G4String | aCommand | ) | `[private, virtual]`

| !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Reimplemented from G4VBasicShell. Definition at line 104 of file G4UIterminal.cc. References G4VBasicShell::FindCommand(), and UI. Referenced by PauseSessionStart(), and SessionStart().
    00106 {
    00107   if(aCommand.length()<2) return;
    00108
    00109   G4int returnVal = UI-> ApplyCommand(aCommand);
    00110
    00111   G4int paramIndex = returnVal % 100;
    00112   // 0 - 98 : paramIndex-th parameter is invalid
    00113   // 99     : convination of parameters is invalid
    00114   G4int commandStatus = returnVal - paramIndex;
    00115
    00116   G4UIcommand* cmd = 0;
    00117   if(commandStatus!=fCommandSucceeded)
    00118   { cmd = FindCommand(aCommand); }
    00119
    00120   switch(commandStatus) {
    00121   case fCommandSucceeded:
    00122     break;
    00123   case fCommandNotFound:
    00124     G4cerr << "command <" << UI->SolveAlias(aCommand) << "> not found" << G4endl;
    00125     if( aCommand.index("@@") != G4String::npos) {
    00126       G4cout << "@@G4UIterminal" << G4endl;
    00127     }
    00128     break;
    00129   case fIllegalApplicationState:
    00130     G4cerr << "illegal application state -- command refused" << G4endl;
    00131     break;
    00132   case fParameterOutOfRange:
    00133     // if(paramIndex<99) {
    00134     //   G4cerr << "Parameter is out of range (index " << paramIndex << ")" << G4endl;
    00135     //   G4cerr << "Allowed range : " << cmd->GetParameter(paramIndex)->GetParameterRange() << G4endl;
    00136     // } else {
    00137     //   G4cerr << "Parameter is out of range" << G4endl;
    00138     //   G4cerr << "Allowed range : " << cmd->GetRange() << G4endl;
    00139     // }
    00140     break;
    00141   case fParameterOutOfCandidates:
    00142     G4cerr << "Parameter is out of candidate list (index " << paramIndex << ")" << G4endl;
    00143     G4cerr << "Candidates : " << cmd->GetParameter(paramIndex)->GetParameterCandidates() << G4endl;
    00144     break;
    00145   case fParameterUnreadable:
    00146     G4cerr << "Parameter is wrong type and/or is not omittable (index " << paramIndex << ")" << G4endl;
    00147     break;
    00148   case fAliasNotFound:
    00149   default:
    00150     G4cerr << "command refused (" << commandStatus << ")" << G4endl;
    00151   }
    00152 }

Here is the call graph for this function:

void G4UIterminal::ExitHelp | ( |  | ) | `[private, virtual]`

| Implements G4VBasicShell. Definition at line 279 of file G4UIterminal.cc.
    00281 {
    00282   char temp[100];
    00283   G4cin.getline(temp, 100);
    00284 }

G4String G4UIterminal::GetCommand | ( | const char * | msg = 0 | ) | `[private]`

| Definition at line 155 of file G4UIterminal.cc. References G4VBasicShell::ChangeDirectoryCommand(), G4VBasicShell::GetCurrentWorkingDirectory(), iCont, iExit, G4VBasicShell::ListDirectory(), G4VBasicShell::ModifyToFullPathCommand(), shell, G4VBasicShell::ShowCurrent(), G4VBasicShell::TerminalHelp(), and UI. Referenced by PauseSessionStart(), and SessionStart().
    00157 {
    00158   G4String newCommand;
    00159   G4String nullString;
    00160
    00161   newCommand= shell-> GetCommandLine(msg);
    00162
    00163   G4String nC= newCommand.strip(G4String::leading);
    00164   if( nC.length() == 0 ) {
    00165     newCommand= nullString;
    00166
    00167   } else if( nC(0) == '#' ) {
    00168     G4cout << nC << G4endl;
    00169     newCommand= nullString;
    00170
    00171   } else if(nC=="ls" || nC(0,3)=="ls " ) {  // list commands
    00172     ListDirectory(nC);
    00173     newCommand= nullString;
    00174
    00175   } else if(nC=="lc" || nC(0,3)=="lc " ) {  // ... by shell
    00176     shell-> ListCommand(nC.remove(0,2));
    00177     newCommand= nullString;
    00178
    00179   } else if(nC == "pwd") { // show current directory
    00180     G4cout << "Current Command Directory : "
    00181            << GetCurrentWorkingDirectory() << G4endl;
    00182     newCommand= nullString;
    00183
    00184   } else if(nC == "cwd") { // ... by shell
    00185     shell-> ShowCurrentDirectory();
    00186     newCommand= nullString;
    00187
    00188   } else if(nC == "cd" || nC(0,3) == "cd ") {  // "cd"
    00189     ChangeDirectoryCommand(nC);
    00190     shell-> SetCurrentDirectory(GetCurrentWorkingDirectory());
    00191     newCommand= nullString;
    00192
    00193   } else if(nC == "help" || nC(0,5) == "help ") {  // "help"
    00194     TerminalHelp(nC);
    00195     newCommand= nullString;
    00196
    00197   } else if(nC(0) == '?') {   // "show current value of a parameter"
    00198     ShowCurrent(nC);
    00199     newCommand= nullString;
    00200
    00201   } else if(nC == "hist" || nC == "history") {     // "hist/history"
    00202     G4int nh= UI-> GetNumberOfHistory();
    00203     for (G4int i=0; i<nh; i++) {
    00204       G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl;
    00205     }
    00206     newCommand= nullString;
    00207
    00208   } else if(nC(0) == '!') {   // "!"
    00209     G4String ss= nC(1, nC.length()-1);
    00210     G4int vl;
    00211     const char* tt= ss;
    00212     std::istringstream is(tt);
    00213     is >> vl;
    00214     G4int nh= UI-> GetNumberOfHistory();
    00215     if(vl>=0 && vl<nh) {
    00216       newCommand= UI-> GetPreviousCommand(vl);
    00217       G4cout << newCommand << G4endl;
    00218     } else {
    00219       G4cerr << "history " << vl << " is not found." << G4endl;
    00220       newCommand= nullString;
    00221     }
    00222
    00223   } else if(nC == "exit") {   // "exit"
    00224     if(iCont) {
    00225       G4cout << "You are now processing RUN." << G4endl;
    00226       G4cout << "Please abort it using \"/run/abort\" command first" << G4endl;
    00227       G4cout << " and use \"continue\" command until the application"
    00228              << G4endl;
    00229       G4cout << " becomes to Idle." << G4endl;
    00230     } else {
    00231       iExit= FALSE;
    00232       newCommand= nullString;
    00233     }
    00234
    00235   } else if( nC == "cont" || nC == "continue"){     // "cont/continu"
    00236     iCont= FALSE;
    00237     newCommand= nullString;
    00238
    00239   } else if( nC.empty() ){ // NULL command
    00240     newCommand= nullString;
    00241
    00242   } else {
    00243   }
    00244
    00245   return ModifyToFullPathCommand(newCommand);
    00246 }

Here is the call graph for this function:

G4bool G4UIterminal::GetHelpChoice | ( | G4int & | aInt | ) | `[private, virtual]`

| Implements G4VBasicShell. Definition at line 266 of file G4UIterminal.cc.
    00268 {
    00269   G4cin >> aInt;
    00270   if(!G4cin.good()){
    00271     G4cin.clear();
    00272     G4cin.ignore(30,'\n');
    00273     return FALSE;
    00274   }
    00275   return TRUE;
    00276 }

void G4UIterminal::PauseSessionStart | ( | G4String | msg | ) | `[virtual]`

| Implements G4VBasicShell. Definition at line 91 of file G4UIterminal.cc. References ExecuteCommand(), GetCommand(), and iCont.
    00093 {
    00094   iCont= TRUE;
    00095
    00096   G4String newCommand= GetCommand(msg);
    00097   while(iCont){
    00098     ExecuteCommand(newCommand);
    00099     newCommand= GetCommand(msg);
    00100   }
    00101 }

Here is the call graph for this function:

G4int G4UIterminal::ReceiveG4cerr | ( | G4String | cerrString | ) | `[virtual]`

| Definition at line 258 of file G4UIterminal.cc.
    00260 {
    00261   std::cerr << cerrString << std::flush;
    00262   return 0;
    00263 }

G4int G4UIterminal::ReceiveG4cout | ( | G4String | coutString | ) | `[virtual]`

| Definition at line 250 of file G4UIterminal.cc.
    00252 {
    00253   std::cout << coutString << std::flush;
    00254   return 0;
    00255 }

G4UIsession * G4UIterminal::SessionStart | ( |  | ) | `[virtual]`

| Implements G4VBasicShell. Definition at line 77 of file G4UIterminal.cc. References ExecuteCommand(), GetCommand(), and iExit.
    00079 {
    00080   iExit= TRUE;
    00081
    00082   G4String newCommand= GetCommand();
    00083   while(iExit){
    00084     ExecuteCommand(newCommand);
    00085     newCommand= GetCommand();
    00086   }
    00087   return NULL;
    00088 }

Here is the call graph for this function:

void G4UIterminal::SetPrompt | ( | const G4String & | prompt | ) |

| Definition at line 70 of file G4UIterminal.cc. References shell.
    00072 {
    00073   shell-> SetPrompt(prompt);
    00074 }

## Member Data Documentation

G4bool G4UIterminal::iCont`[private]`

| Definition at line 81 of file G4UIterminal.hh. Referenced by G4UIterminal(), GetCommand(), and PauseSessionStart().

G4bool G4UIterminal::iExit`[private]`

| Definition at line 80 of file G4UIterminal.hh. Referenced by G4UIterminal(), GetCommand(), and SessionStart().

G4VUIshell* G4UIterminal::shell`[private]`

| Definition at line 77 of file G4UIterminal.hh. Referenced by G4UIterminal(), GetCommand(), SetPrompt(), and ~G4UIterminal().

G4UImanager* G4UIterminal::UI`[private]`

| Definition at line 75 of file G4UIterminal.hh. Referenced by ExecuteCommand(), G4UIterminal(), GetCommand(), and ~G4UIterminal().

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

- G4UIterminal.hh
- G4UIterminal.cc