Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIGAG Class Reference

#include <G4UIGAG.hh>

+ Inheritance diagram for G4UIGAG:

Public Member Functions

 G4UIGAG ()
 
 ~G4UIGAG ()
 
G4UIsessionSessionStart ()
 
void PauseSessionStart (const G4String &)
 
G4int ReceiveG4cout (const G4String &)
 
G4int ReceiveG4cerr (const G4String &)
 
void SessionTerminate ()
 
void Prompt (const G4String &)
 
G4String GetCommand ()
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
virtual ~G4UIsession ()
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
virtual G4int ReceiveG4cout (const G4String &coutString)
 
virtual G4int ReceiveG4cerr (const G4String &cerrString)
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()
 
virtual ~G4coutDestination ()
 
virtual G4int ReceiveG4cout (const G4String &)
 
virtual G4int ReceiveG4cerr (const G4String &)
 

Detailed Description

Definition at line 53 of file G4UIGAG.hh.

Constructor & Destructor Documentation

◆ G4UIGAG()

G4UIGAG::G4UIGAG ( )

Definition at line 39 of file G4UIGAG.cc.

40{
41 TVersion="T1.0a"; JVersion="J1.0a";
42 //G4cout << "G4UIGAG: Apr15,98." << G4endl;
43 prefix = "/";
45 UI->SetSession(this);
46 UI->SetCoutDestination(this);
48 promptCharacter = statM->GetStateString(statM->GetCurrentState());
49 uiMode = terminal_mode; // GAG
50 iExit = false;
51 iCont = false;
52 // -- Initialize Notify routines begin
53 G4UIcommandTree * tree = UI->GetTree();
54 GetNewTreeStructure(tree,0);
55 GetNewTreeValues(tree,0);
56 previousTreeCommands = newTreeCommands;
57 previousTreeParams = newTreeParams;
58 previousTreePCP = newTreePCP;
59 // -- end
60}
@ terminal_mode
Definition: G4UIGAG.hh:44
G4ApplicationState GetCurrentState() const
static G4StateManager * GetStateManager()
G4String GetStateString(G4ApplicationState aState) const
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:517
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:197
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:204

◆ ~G4UIGAG()

G4UIGAG::~G4UIGAG ( )

Definition at line 62 of file G4UIGAG.cc.

63{
65 {
66 UI->SetSession(NULL);
67 UI->SetCoutDestination(NULL);
68 // G4cout << "GAG session deleted" << G4endl;
69 }
70}

Member Function Documentation

◆ GetCommand()

G4String G4UIGAG::GetCommand ( )

Definition at line 189 of file G4UIGAG.cc.

190{
191 G4String newCommand;
192 G4String nullString;
193 while( 1 )
194 {
195 G4UIcommandTree* tree = UI->GetTree();
196 if ( uiMode != terminal_mode ){
197 G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
198 }
199 if ( uiMode != java_mode ){
200 G4cout << promptCharacter << "> " << std::flush;
201 }else{
202 G4cout << "@@Ready" << G4endl;
203 }
204 newCommand.readLine( G4cin, FALSE );
205 if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
206
207 newCommand = newCommand.strip(G4String::leading);
208 if( newCommand.length() < 1) { break; }
209
210 while( newCommand(newCommand.length()-1) == '_' )
211 {
212 G4String newLine;
213 newCommand.remove(newCommand.length()-1);
214 newLine.readLine( G4cin );
215 if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;}
216 newCommand.append(newLine);
217 }
218
219 G4String nC = newCommand.strip(G4String::leading);
220 if( nC.length() < 1) { break; }
221
222 // -------------------- nC.toUpper();
223 if( nC == "@@GAGmodeJAVA" ) {
224 uiMode = java_mode;
225 G4cout << G4endl << "@@Version " << JVersion << G4endl;
226 SendCommandProperties(tree);
227 NotifyStateChange();
228 }
229 else if( nC == "@@GAGmodeTcl" ) {
230 uiMode = tcl_mode;
231 G4cout << G4endl << "@@Version " << TVersion << G4endl;
232 SendCommandProperties(tree);
233 NotifyStateChange();
234 }
235 else if( nC(0) == '#' )
236 { G4cout << nC << G4endl; }
237
238 else if( nC == "ls" || nC(0,3) == "ls " )
239 { ListDirectory( nC ); }
240 else if( nC == "pwd" )
241 { G4cout << "Current Working Directory : " << prefix << G4endl; }
242 else if( nC(0,2) == "cd" || nC(0,3) == "cd " )
243 { ChangeDirectory( nC ); }
244 else if( nC == "help" || nC(0,5) == "help ")
245 { TerminalHelp( nC ); }
246 else if( nC(0) == '?' )
247 { ShowCurrent( nC ); }
248 else if( nC(0,4) == "hist" || nC == "history")
249 {
250 G4int nh = UI->GetNumberOfHistory();
251 for(int i=0;i<nh;i++)
252 { G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl; }
253 }
254 else if( nC(0) == '!' )
255 {
256 G4String ss = nC(1,nC.length()-1);
257 G4int vl;
258 const char* tt = ss;
259 std::istringstream is((char*)tt);
260 is >> vl;
261 G4int nh = UI->GetNumberOfHistory();
262 if(vl>=0 && vl<nh)
263 {
264 newCommand = UI->GetPreviousCommand(vl);
265 G4cout << newCommand << G4endl;
266 break;
267 }
268 else
269 { G4cerr << "history " << vl << " is not found." << G4endl; }
270 }
271 else if( nC(0,4) == "exit" )
272 {
273 if( iCont )
274 {
275 if ( uiMode == terminal_mode){
276 G4cerr << "You are now processing RUN." << G4endl;
277 G4cerr << "Please abrot it using \"/run/abort\" command first" << G4endl;
278 G4cerr << " and use \"continue\" command until the application" << G4endl;
279 G4cerr << " becomes to Idle." << G4endl;
280 }else{
281 G4cout << "@@ErrResult \"You are now processing RUN.\"" << G4endl;
282 }
283 }
284 else
285 {
286 iExit = false;
287 newCommand = nullString;
288 break;
289 }
290 }
291 else if( nC == "cont" || nC == "continue" )
292 {
293 iCont = false;
294 newCommand = nullString;
295 break;
296 }
297 else
298 { break; }
299 }
300 return GetFullPath(newCommand);
301}
int G4int
Definition: G4Types.hh:66
@ tcl_mode
Definition: G4UIGAG.hh:44
@ java_mode
Definition: G4UIGAG.hh:44
#define G4endl
Definition: G4ios.hh:52
#define G4cin
Definition: G4ios.hh:51
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
G4String & remove(str_size)
G4String & append(const G4String &)
G4String strip(G4int strip_Type=trailing, char c=' ')
std::istream & readLine(std::istream &, G4bool skipWhite=true)
G4int GetNumberOfHistory() const
Definition: G4UImanager.hh:220
G4String GetPreviousCommand(G4int i) const
Definition: G4UImanager.hh:222
#define FALSE
Definition: globals.hh:52

Referenced by PauseSessionStart(), and SessionStart().

◆ PauseSessionStart()

void G4UIGAG::PauseSessionStart ( const G4String msg)
virtual

Reimplemented from G4UIsession.

Definition at line 87 of file G4UIGAG.cc.

88{
89 promptCharacter = msg;
90 G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl;
91 iCont = true;
92 G4String newCommand = GetCommand();
93 while( iCont )
94 {
95 ExecuteCommand(newCommand);
96 newCommand = GetCommand();
97 }
98}
G4String GetCommand()
Definition: G4UIGAG.cc:189

◆ Prompt()

void G4UIGAG::Prompt ( const G4String aPrompt)

Definition at line 184 of file G4UIGAG.cc.

185{
186 promptCharacter = aPrompt;
187}

◆ ReceiveG4cerr()

G4int G4UIGAG::ReceiveG4cerr ( const G4String cerrString)
virtual

Reimplemented from G4UIsession.

Definition at line 178 of file G4UIGAG.cc.

179{
180 std::cerr << cerrString << std::flush;
181 return 0;
182}

◆ ReceiveG4cout()

G4int G4UIGAG::ReceiveG4cout ( const G4String coutString)
virtual

Reimplemented from G4UIsession.

Definition at line 172 of file G4UIGAG.cc.

173{
174 std::cout << coutString << std::flush;
175 return 0;
176}

◆ SessionStart()

G4UIsession * G4UIGAG::SessionStart ( )
virtual

Reimplemented from G4UIsession.

Definition at line 72 of file G4UIGAG.cc.

73{
74 iExit = true;
76 promptCharacter = statM->GetStateString(statM->GetCurrentState());
77 G4String newCommand = GetCommand();
78 while( iExit )
79 {
80 ExecuteCommand(newCommand);
81 promptCharacter = statM->GetStateString(statM->GetCurrentState());
82 newCommand = GetCommand();
83 }
84 return NULL;
85}

◆ SessionTerminate()

void G4UIGAG::SessionTerminate ( )

Definition at line 337 of file G4UIGAG.cc.

338{
339 G4cout << "***** Terminal session end *****" << G4endl;
340}

The documentation for this class was generated from the following files: