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: G4VBasicShell.hh,v 1.7 2006/06/29 19:10:03 gunter Exp $ 00028 // GEANT4 tag $Name: geant4-08-01-patch-01 $ 00029 // 00030 00031 #ifndef G4VBasicShell_H 00032 #define G4VBasicShell_H 1 00033 00034 class G4UIcommandTree; 00035 class G4UIcommand; 00036 00037 #include "G4UIsession.hh" 00038 #include "globals.hh" 00039 00040 // Class description : 00041 // 00042 // G4VBasicShell : a base class to extract common things to various 00043 // sessions. 00044 // 00045 // It handles "seek" completion logic, help logic. 00046 // VBasicShell handles also commands like "cd, ls, pwd" 00047 // without passing by a Geant4 "intercom" command. This feature, 00048 // which is similar to a UNIX shell one, had given. 00049 // its name to the class. 00050 // 00051 // Class description - end : 00052 00053 class G4VBasicShell : public G4UIsession 00054 { 00055 public: 00056 G4VBasicShell(); 00057 virtual ~G4VBasicShell(); 00058 00059 virtual G4UIsession* SessionStart() = 0; 00060 // null should be returned for interactive session 00061 00062 virtual void PauseSessionStart(G4String Prompt) = 0; 00063 // Prompt string can be ignored 00064 00065 protected: 00066 G4String ModifyToFullPathCommand(const char* aCommandLine); 00067 // convert "BeamOn 10" to "/run/BeamOn 10" if the 00068 // current working directory is "/run/" 00069 00070 G4String GetCurrentWorkingDirectory(); 00071 // directory string starts with '/' and ends with '/' 00072 00073 G4bool ChangeDirectory(const char* newDir); 00074 // change directory to newDir 00075 // false will be returned if the target directory doesn't exist 00076 00077 G4UIcommandTree* FindDirectory(const char* dirName); 00078 // find G4UIcommandTree object 00079 // null returned if the taregt does not exist 00080 00081 G4UIcommand* FindCommand(const char* commandName); 00082 // find G4UIcommand object 00083 // null returned if the target does not exist 00084 00085 G4String Complete(G4String); 00086 // command completion 00087 G4String FindMatchingPath(G4UIcommandTree*,G4String); 00088 00090 // Methods involving an interactive G4cout // 00092 virtual void ExecuteCommand(G4String); 00093 virtual G4bool GetHelpChoice(G4int&) = 0; 00094 virtual void ExitHelp() = 0; 00095 void ApplyShellCommand(G4String,G4bool&,G4bool&); 00096 void ShowCurrent(G4String); 00097 void ChangeDirectoryCommand(G4String); 00098 void ListDirectory(G4String); 00099 void TerminalHelp(G4String); 00100 00101 private: 00102 G4String currentDirectory; 00103 00104 G4String ModifyPath(G4String tempPath); 00105 }; 00106 00107 #endif 00108