CMS 3D CMS Logo

CustomUIsession.cc
Go to the documentation of this file.
2 
4  G4UImanager* UI = G4UImanager::GetUIpointer();
5  UI->SetCoutDestination(this);
6 }
7 
9  G4UImanager* UI = G4UImanager::GetUIpointer();
10  UI->SetCoutDestination(nullptr);
11 }
12 
13 G4int CustomUIsession::ReceiveG4cout(const G4String& coutString) {
14  //std::cout << coutString << std::flush;
15  if (fout) {
16  (*fout) << trim(coutString) << "\n";
17  } else {
18  edm::LogVerbatim("G4cout") << trim(coutString);
19  }
20  return 0;
21 }
22 
23 G4int CustomUIsession::ReceiveG4cerr(const G4String& cerrString) {
24  //std::cerr << cerrString << std::flush;
25  edm::LogWarning("G4cerr") << trim(cerrString);
26  return 0;
27 }
28 
30  if (!str.empty() && str.back() == '\n')
31  return str.substr(0, str.length() - 1);
32  return str;
33 }
34 
35 void CustomUIsession::sendToFile(std::ofstream* ptr) {
36  if (ptr && !ptr->fail()) {
37  fout = ptr;
38  }
39 }
std::ofstream * fout
#define nullptr
void sendToFile(std::ofstream *)
std::string trim(const std::string &str)
G4int ReceiveG4cerr(const G4String &cerrString) override
G4int ReceiveG4cout(const G4String &coutString) override
~CustomUIsession() override
#define str(s)