Geant4 11.2.2
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 () override
 
G4UIsessionGetPreviousSession () const
 
G4UIsessionSessionStart () override
 
void PauseSessionStart (const G4String &Prompt) override
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
 G4UIsession (G4int iBatch)
 
 ~G4UIsession () override
 
G4int ReceiveG4debug (const G4String &debugString) override
 
G4int ReceiveG4cout (const G4String &coutString) override
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
 
virtual ~G4coutDestination ()=default
 
void AddDebugTransformer (const Transformer &t)
 
void AddDebugTransformer (Transformer &&t)
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
G4int ReceiveG4debug_ (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< TransformertransformersDebug
 
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 67 of file G4UIbatch.cc.

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

◆ ~G4UIbatch()

G4UIbatch::~G4UIbatch ( )
override

Definition at line 84 of file G4UIbatch.cc.

85{
86 if (isOpened) {
87 macroStream.close();
88 }
89}

Member Function Documentation

◆ GetPreviousSession()

G4UIsession * G4UIbatch::GetPreviousSession ( ) const
inline

Definition at line 76 of file G4UIbatch.hh.

77{
78 return previousSession;
79}

◆ PauseSessionStart()

void G4UIbatch::PauseSessionStart ( const G4String & Prompt)
overridevirtual

Reimplemented from G4UIsession.

Definition at line 235 of file G4UIbatch.cc.

236{
237 G4cout << "Pause session <" << Prompt << "> start." << G4endl;
238
239 SessionStart();
240
241 G4cout << "Pause session <" << Prompt << "> Terminate." << G4endl;
242}
G4GLOB_DLL std::ostream G4cout
G4UIsession * SessionStart() override
Definition G4UIbatch.cc:201

◆ SessionStart()

G4UIsession * G4UIbatch::SessionStart ( )
overridevirtual

Reimplemented from G4UIsession.

Definition at line 201 of file G4UIbatch.cc.

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

Referenced by PauseSessionStart().


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