Geant4 10.7.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 ()
 
 G4UIsession (G4int iBatch)
 
virtual ~G4UIsession ()
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
virtual G4int ReceiveG4cout (const G4String &coutString)
 
virtual G4int ReceiveG4cerr (const G4String &cerrString)
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
 
virtual ~G4coutDestination ()
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
virtual G4int ReceiveG4cout (const G4String &msg)
 
virtual G4int ReceiveG4cerr (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 

Additional Inherited Members

- Public Types inherited from G4coutDestination
using Transformer = std::function< G4bool(G4String &)>
 
- Static Public Member Functions inherited from G4UIsession
static G4int InSession ()
 
- Protected Attributes inherited from G4UIsession
G4int ifBatch = 0
 
G4int lastRC = 0
 
- Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 
- Static Protected Attributes inherited from G4UIsession
static G4ICOMS_DLL G4int inSession = 0
 
- Static Protected Attributes inherited from G4coutDestination
static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr
 

Detailed Description

Definition at line 52 of file G4UIGAG.hh.

Constructor & Destructor Documentation

◆ G4UIGAG()

G4UIGAG::G4UIGAG ( )

Definition at line 38 of file G4UIGAG.cc.

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

◆ ~G4UIGAG()

G4UIGAG::~G4UIGAG ( )

Definition at line 61 of file G4UIGAG.cc.

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

Member Function Documentation

◆ GetCommand()

G4String G4UIGAG::GetCommand ( )

Definition at line 188 of file G4UIGAG.cc.

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

Referenced by PauseSessionStart(), and SessionStart().

◆ PauseSessionStart()

void G4UIGAG::PauseSessionStart ( const G4String msg)
virtual

Reimplemented from G4UIsession.

Definition at line 86 of file G4UIGAG.cc.

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

◆ Prompt()

void G4UIGAG::Prompt ( const G4String aPrompt)

Definition at line 183 of file G4UIGAG.cc.

184{
185 promptCharacter = aPrompt;
186}

◆ ReceiveG4cerr()

G4int G4UIGAG::ReceiveG4cerr ( const G4String cerrString)
virtual

Reimplemented from G4UIsession.

Definition at line 177 of file G4UIGAG.cc.

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

◆ ReceiveG4cout()

G4int G4UIGAG::ReceiveG4cout ( const G4String coutString)
virtual

Reimplemented from G4UIsession.

Definition at line 171 of file G4UIGAG.cc.

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

◆ SessionStart()

G4UIsession * G4UIGAG::SessionStart ( )
virtual

Reimplemented from G4UIsession.

Definition at line 71 of file G4UIGAG.cc.

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

◆ SessionTerminate()

void G4UIGAG::SessionTerminate ( )

Definition at line 336 of file G4UIGAG.cc.

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

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