Geant4 10.7.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=nullptr)
 
 ~G4UIbatch ()
 
G4UIsessionGetPreviousSession () const
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
- 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 46 of file G4UIbatch.hh.

Constructor & Destructor Documentation

◆ G4UIbatch()

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

Definition at line 66 of file G4UIbatch.cc.

67 : G4UIsession(1)
68 , previousSession(prevSession)
69{
70 macroStream.open(fileName, std::ios::in);
71 if(macroStream.fail())
72 {
73 G4cerr << "ERROR: Can not open a macro file <" << fileName
74 << ">. Set macro path with \"/control/macroPath\" if needed."
75 << G4endl;
77 }
78 else
79 {
80 isOpened = true;
81 }
82
84}
@ fParameterUnreadable
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:183
G4int lastRC
Definition: G4UIsession.hh:69

◆ ~G4UIbatch()

G4UIbatch::~G4UIbatch ( )

Definition at line 87 of file G4UIbatch.cc.

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

Member Function Documentation

◆ GetPreviousSession()

G4UIsession * G4UIbatch::GetPreviousSession ( ) const
inline

Definition at line 77 of file G4UIbatch.hh.

78{
79 return previousSession;
80}

◆ PauseSessionStart()

void G4UIbatch::PauseSessionStart ( const G4String Prompt)
virtual

Reimplemented from G4UIsession.

Definition at line 243 of file G4UIbatch.cc.

244{
245 G4cout << "Pause session <" << Prompt << "> start." << G4endl;
246
247 SessionStart();
248
249 G4cout << "Pause session <" << Prompt << "> Terminate." << G4endl;
250}
G4GLOB_DLL std::ostream G4cout
virtual G4UIsession * SessionStart()
Definition: G4UIbatch.cc:205

◆ SessionStart()

G4UIsession * G4UIbatch::SessionStart ( )
virtual

Reimplemented from G4UIsession.

Definition at line 205 of file G4UIbatch.cc.

206{
207 if(!isOpened)
208 return previousSession;
209
210 while(1)
211 {
212 G4String newCommand = ReadCommand();
213
214 if(newCommand == "exit")
215 {
216 break;
217 }
218
219 // just echo something
220 if(newCommand[(std::size_t) 0] == '#')
221 {
222 if(G4UImanager::GetUIpointer()->GetVerboseLevel() == 2)
223 {
224 G4cout << newCommand << G4endl;
225 }
226 continue;
227 }
228
229 // execute command
230 G4int rc = ExecCommand(newCommand);
231 if(rc != fCommandSucceeded)
232 {
233 G4cerr << G4endl << "***** Batch is interrupted!! *****" << G4endl;
234 lastRC = rc;
235 break;
236 }
237 }
238
239 return previousSession;
240}
int G4int
Definition: G4Types.hh:85
@ fCommandSucceeded

Referenced by PauseSessionStart().


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