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 // 00027 // $Id: G4UIterminal.hh,v 1.9 2006/06/29 19:09:39 gunter Exp $ 00028 // GEANT4 tag $Name: geant4-08-01-patch-01 $ 00029 // 00030 00031 #ifndef G4UIterminal_h 00032 #define G4UIterminal_h 1 00033 00034 #include <fstream> 00035 #include "G4UImanager.hh" 00036 #include "G4VBasicShell.hh" 00037 #include "G4VUIshell.hh" 00038 00039 // 00040 // Description: 00041 // 00042 // This class inherits the class G4UIsession. 00043 // This is the class to use a character-terminal sesion. 00044 // 00045 // Usage: 00046 // G4UIsession* terminalSession = new G4UIterminal; 00047 // or G4UIsession* terminalSession = new G4UIterminal(new your-shell); 00048 // 00049 // A character-terminal session "terminalSession" is instantiated. 00050 // G4cout stream is redirected by default to the constructed instance. 00051 // 00052 // terminalSession-> SessionStart(); // "terminalSession" is started. 00053 // delete terminalSession; // "terminalSession" is deleted. 00054 // 00055 // 00056 // In default(no arguments are given), csh-like shell is instantiated. 00057 // If you want to use another shell (e.g. tcsh-like), you can give 00058 // your favorite shell in an argument of the constructor. 00059 // 00060 // Which shell? / How to define your own shell? 00061 // Currently two kinds of shells, 00062 // G4UIcsh / G4UItcsh 00063 // , are presented. 00064 // They inherit the abstract base class, G4VUIshell. 00065 // In order to define your own shell, 00066 // - Define your own shell class derived from G4VUIshell. 00067 // - Implement GetCommandLine() method (pure virtual). 00068 // - Add more functionality, if need. 00069 // 00070 // For more detail, see source codes. 00071 // 00072 00073 class G4UIterminal : public G4VBasicShell { 00074 private: 00075 G4UImanager* UI; 00076 // shell 00077 G4VUIshell* shell; 00078 00079 // program states 00080 G4bool iExit; 00081 G4bool iCont; 00082 00083 public: 00084 G4UIterminal(G4VUIshell* aShell=0); 00085 ~G4UIterminal(); 00086 00087 void SetPrompt(const G4String& prompt); 00088 00089 private: 00090 void ExecuteCommand(G4String aCommand); 00091 G4String GetCommand(const char* msg=0); 00092 G4bool GetHelpChoice(G4int& aInt); 00093 void ExitHelp(); 00094 00095 public: 00096 // These methods are implementation of corresponding virtual methods 00097 // of G4UIsession class. 00098 virtual G4UIsession* SessionStart(); 00099 virtual void PauseSessionStart(G4String msg); 00100 virtual G4int ReceiveG4cout(G4String coutString); 00101 virtual G4int ReceiveG4cerr(G4String cerrString); 00102 00103 }; 00104 00105 #endif 00106