Geant4 11.1.1
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
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
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 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 70 of file G4UIbatch.cc.

71 : G4UIsession(1)
72 , previousSession(prevSession)
73{
74 macroStream.open(fileName, std::ios::in);
75 if(macroStream.fail())
76 {
77 G4cerr << "ERROR: Can not open a macro file <" << fileName
78 << ">. Set macro path with \"/control/macroPath\" if needed."
79 << G4endl;
81 }
82 else
83 {
84 isOpened = true;
85 }
86
88}
@ 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:190
G4int lastRC
Definition: G4UIsession.hh:69

◆ ~G4UIbatch()

G4UIbatch::~G4UIbatch ( )
override

Definition at line 91 of file G4UIbatch.cc.

92{
93 if(isOpened)
94 {
95 macroStream.close();
96 }
97}

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)
overridevirtual

Reimplemented from G4UIsession.

Definition at line 265 of file G4UIbatch.cc.

266{
267 G4cout << "Pause session <" << Prompt << "> start." << G4endl;
268
269 SessionStart();
270
271 G4cout << "Pause session <" << Prompt << "> Terminate." << G4endl;
272}
G4GLOB_DLL std::ostream G4cout
G4UIsession * SessionStart() override
Definition: G4UIbatch.cc:225

◆ SessionStart()

G4UIsession * G4UIbatch::SessionStart ( )
overridevirtual

Reimplemented from G4UIsession.

Definition at line 225 of file G4UIbatch.cc.

226{
227 if(!isOpened)
228 {
229 return previousSession;
230 }
231
232 while(true)
233 {
234 G4String newCommand = ReadCommand();
235
236 if(newCommand == "exit")
237 {
238 break;
239 }
240
241 // just echo something
242 if(newCommand[(std::size_t) 0] == '#')
243 {
244 if(G4UImanager::GetUIpointer()->GetVerboseLevel() == 2)
245 {
246 G4cout << newCommand << G4endl;
247 }
248 continue;
249 }
250
251 // execute command
252 G4int rc = ExecCommand(newCommand);
253 if(rc != fCommandSucceeded)
254 {
255 G4cerr << G4endl << "***** Batch is interrupted!! *****" << G4endl;
256 lastRC = rc;
257 break;
258 }
259 }
260
261 return previousSession;
262}
int G4int
Definition: G4Types.hh:85
@ fCommandSucceeded

Referenced by PauseSessionStart().


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