G4VBasicShell.hh

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

Generated on Mon May 27 17:50:09 2013 for Geant4 by  doxygen 1.4.7