Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4UIbatch Class Reference

#include <G4UIbatch.hh>

Inheritance diagram for G4UIbatch:
G4UIsession G4coutDestination

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 G4int ReceiveG4cout (const G4String &coutString)
 
virtual G4int ReceiveG4cerr (const G4String &cerrString)
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()
 
virtual ~G4coutDestination ()
 

Detailed Description

Definition at line 51 of file G4UIbatch.hh.

Constructor & Destructor Documentation

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

Definition at line 69 of file G4UIbatch.cc.

References G4cerr, G4endl, and G4UImanager::GetUIpointer().

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 }
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
G4UIbatch::~G4UIbatch ( )

Definition at line 87 of file G4UIbatch.cc.

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

Member Function Documentation

G4UIsession * G4UIbatch::GetPreviousSession ( ) const
inline

Definition at line 81 of file G4UIbatch.hh.

82 {
83  return previousSession;
84 }
void G4UIbatch::PauseSessionStart ( const G4String Prompt)
virtual

Reimplemented from G4UIsession.

Definition at line 227 of file G4UIbatch.cc.

References G4cout, G4endl, and SessionStart().

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

Reimplemented from G4UIsession.

Definition at line 194 of file G4UIbatch.cc.

References fCommandSucceeded, G4cerr, G4cout, G4endl, and G4UImanager::GetUIpointer().

Referenced by PauseSessionStart().

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:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

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