1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: G4VBasicShell.hh,v 1.7 2006/06/29 19:10:03 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-08-01 $ |
---|
29 | // |
---|
30 | |
---|
31 | #ifndef G4VBasicShell_H |
---|
32 | #define G4VBasicShell_H 1 |
---|
33 | |
---|
34 | class G4UIcommandTree; |
---|
35 | class G4UIcommand; |
---|
36 | |
---|
37 | #include "G4UIsession.hh" |
---|
38 | #include "globals.hh" |
---|
39 | |
---|
40 | // Class description : |
---|
41 | // |
---|
42 | // G4VBasicShell : a base class to extract common things to various |
---|
43 | // sessions. |
---|
44 | // |
---|
45 | // It handles "seek" completion logic, help logic. |
---|
46 | // VBasicShell handles also commands like "cd, ls, pwd" |
---|
47 | // without passing by a Geant4 "intercom" command. This feature, |
---|
48 | // which is similar to a UNIX shell one, had given. |
---|
49 | // its name to the class. |
---|
50 | // |
---|
51 | // Class description - end : |
---|
52 | |
---|
53 | class G4VBasicShell : public G4UIsession |
---|
54 | { |
---|
55 | public: |
---|
56 | G4VBasicShell(); |
---|
57 | virtual ~G4VBasicShell(); |
---|
58 | |
---|
59 | virtual G4UIsession* SessionStart() = 0; |
---|
60 | // null should be returned for interactive session |
---|
61 | |
---|
62 | virtual void PauseSessionStart(G4String Prompt) = 0; |
---|
63 | // Prompt string can be ignored |
---|
64 | |
---|
65 | protected: |
---|
66 | G4String ModifyToFullPathCommand(const char* aCommandLine); |
---|
67 | // convert "BeamOn 10" to "/run/BeamOn 10" if the |
---|
68 | // current working directory is "/run/" |
---|
69 | |
---|
70 | G4String GetCurrentWorkingDirectory(); |
---|
71 | // directory string starts with '/' and ends with '/' |
---|
72 | |
---|
73 | G4bool ChangeDirectory(const char* newDir); |
---|
74 | // change directory to newDir |
---|
75 | // false will be returned if the target directory doesn't exist |
---|
76 | |
---|
77 | G4UIcommandTree* FindDirectory(const char* dirName); |
---|
78 | // find G4UIcommandTree object |
---|
79 | // null returned if the taregt does not exist |
---|
80 | |
---|
81 | G4UIcommand* FindCommand(const char* commandName); |
---|
82 | // find G4UIcommand object |
---|
83 | // null returned if the target does not exist |
---|
84 | |
---|
85 | G4String Complete(G4String); |
---|
86 | // command completion |
---|
87 | G4String FindMatchingPath(G4UIcommandTree*,G4String); |
---|
88 | |
---|
89 | ///////////////////////////////////////////// |
---|
90 | // Methods involving an interactive G4cout // |
---|
91 | ///////////////////////////////////////////// |
---|
92 | virtual void ExecuteCommand(G4String); |
---|
93 | virtual G4bool GetHelpChoice(G4int&) = 0; |
---|
94 | virtual void ExitHelp() = 0; |
---|
95 | void ApplyShellCommand(G4String,G4bool&,G4bool&); |
---|
96 | void ShowCurrent(G4String); |
---|
97 | void ChangeDirectoryCommand(G4String); |
---|
98 | void ListDirectory(G4String); |
---|
99 | void TerminalHelp(G4String); |
---|
100 | |
---|
101 | private: |
---|
102 | G4String currentDirectory; |
---|
103 | |
---|
104 | G4String ModifyPath(G4String tempPath); |
---|
105 | }; |
---|
106 | |
---|
107 | #endif |
---|
108 | |
---|