00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // $Id$ 00027 // 00028 // ==================================================================== 00029 // G4UIterminal.cc 00030 // 00031 // Description: 00032 // 00033 // This class inherits the class G4UIsession. 00034 // This is the class to use a character-terminal sesion. 00035 // 00036 // Usage: 00037 // G4UIsession* terminalSession = new G4UIterminal; 00038 // or G4UIsession* terminalSession = new G4UIterminal(new your-shell); 00039 // 00040 // A character-terminal session "terminalSession" is instantiated. 00041 // G4cout stream is redirected by default to the constructed instance. 00042 // 00043 // terminalSession-> SessionStart(); // "terminalSession" is started. 00044 // delete terminalSession; // "terminalSession" is deleted. 00045 // 00046 // 00047 // In default(no arguments are given), csh-like shell is instantiated. 00048 // If you want to use another shell (e.g. tcsh-like), you can give 00049 // your favorite shell in an argument of the constructor. 00050 // 00051 // Which shell? / How to define your own shell? 00052 // Currently two kinds of shells, 00053 // G4UIcsh / G4UItcsh 00054 // , are presented. 00055 // They inherit the abstract base class, G4VUIshell. 00056 // In order to define your own shell, 00057 // - Define your own shell class derived from G4VUIshell. 00058 // - Implement GetCommandLine() method (pure virtual). 00059 // - Add more functionality, if need. 00060 // 00061 // For more detail, see source codes. 00062 // ==================================================================== 00063 #ifndef G4UIterminal_h 00064 #define G4UIterminal_h 1 00065 00066 #include <fstream> 00067 #include "G4UImanager.hh" 00068 #include "G4VBasicShell.hh" 00069 #include "G4VUIshell.hh" 00070 00071 class G4UIterminal : public G4VBasicShell { 00072 private: 00073 G4UImanager* UI; 00074 // shell 00075 G4VUIshell* shell; 00076 00077 // program states 00078 G4bool iExit; 00079 G4bool iCont; 00080 00081 public: 00082 G4UIterminal(G4VUIshell* aShell=0, G4bool qsig=true); 00083 ~G4UIterminal(); 00084 00085 void SetPrompt(const G4String& prompt); 00086 00087 private: 00088 virtual void ExecuteCommand(const G4String& aCommand); 00089 virtual G4bool GetHelpChoice(G4int& aInt); 00090 virtual void ExitHelp() const; 00091 G4String GetCommand(const char* msg=0); 00092 00093 public: 00094 // These methods are implementation of corresponding virtual methods 00095 // of G4UIsession class. 00096 virtual G4UIsession* SessionStart(); 00097 virtual void PauseSessionStart(const G4String& msg); 00098 virtual G4int ReceiveG4cout(const G4String& coutString); 00099 virtual G4int ReceiveG4cerr(const G4String& cerrString); 00100 }; 00101 00102 #endif 00103