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

#include <G4UIbatch.hh>

+ Inheritance diagram for G4UIbatch:

Public Member Functions

 G4UIbatch (const char *fileName, G4UIsession *prevSession=0)
 
 ~G4UIbatch ()
 
G4UIsessionGetPreviousSession () const
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
- 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 51 of file G4UIbatch.hh.

Constructor & Destructor Documentation

◆ G4UIbatch()

G4UIbatch::G4UIbatch ( const char *  fileName,
G4UIsession prevSession = 0 
)

Definition at line 69 of file G4UIbatch.cc.

70 : previousSession(prevSession), isOpened(false)
71////////////////////////////////////////////////////////////////////
72{
73 macroStream.open(fileName, std::ios::in);
74 if(macroStream.fail()) {
75 G4cerr << "***** Can not open a macro file <"
76 << fileName << ">"
77 << G4endl;
78 } else {
79 isOpened= true;
80 }
81
82 G4UImanager::GetUIpointer()-> SetSession(this);
83}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:51

◆ ~G4UIbatch()

G4UIbatch::~G4UIbatch ( )

Definition at line 87 of file G4UIbatch.cc.

89{
90 if(isOpened) macroStream.close();
91}

Member Function Documentation

◆ GetPreviousSession()

G4UIsession * G4UIbatch::GetPreviousSession ( ) const
inline

Definition at line 81 of file G4UIbatch.hh.

82{
83 return previousSession;
84}

◆ PauseSessionStart()

void G4UIbatch::PauseSessionStart ( const G4String Prompt)
virtual

Reimplemented from G4UIsession.

Definition at line 227 of file G4UIbatch.cc.

229{
230 G4cout << "Pause session <" << Prompt << "> start." << G4endl;
231
232 SessionStart();
233
234 G4cout << "Pause session <" << Prompt << "> Terminate." << G4endl;
235}
G4DLLIMPORT std::ostream G4cout
virtual G4UIsession * SessionStart()
Definition: G4UIbatch.cc:194

◆ SessionStart()

G4UIsession * G4UIbatch::SessionStart ( )
virtual

Reimplemented from G4UIsession.

Definition at line 194 of file G4UIbatch.cc.

196{
197 if(!isOpened) return previousSession;
198
199 while(1) {
200 G4String newCommand = ReadCommand();
201
202 if(newCommand == "exit") {
203 break;
204 }
205
206 // just echo something
207 if( newCommand[(size_t)0] == '#') {
208 if(G4UImanager::GetUIpointer()-> GetVerboseLevel()==2) {
209 G4cout << newCommand << G4endl;
210 }
211 continue;
212 }
213
214 // execute command
215 G4int rc= ExecCommand(newCommand);
216 if(rc != fCommandSucceeded) {
217 G4cerr << G4endl << "***** Batch is interrupted!! *****" << G4endl;
218 break;
219 }
220 }
221
222 return previousSession;
223}
int G4int
Definition: G4Types.hh:66
@ fCommandSucceeded

Referenced by PauseSessionStart().


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