CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
CustomUIsession Class Reference

#include <CustomUIsession.h>

Inheritance diagram for CustomUIsession:
CustomUIsessionThreadPrefix CustomUIsessionToFile

Public Member Functions

 CustomUIsession ()
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int ReceiveG4cout (const G4String &coutString) override
 
void sendToFile (std::ofstream *)
 
void stopSendToFile ()
 
 ~CustomUIsession () override
 

Protected Member Functions

std::string trim (const std::string &str)
 

Private Attributes

std::ofstream * fout
 

Detailed Description

Definition at line 9 of file CustomUIsession.h.

Constructor & Destructor Documentation

◆ CustomUIsession()

CustomUIsession::CustomUIsession ( )

Definition at line 3 of file CustomUIsession.cc.

3 : fout(nullptr) {}
std::ofstream * fout

◆ ~CustomUIsession()

CustomUIsession::~CustomUIsession ( )
override

Definition at line 5 of file CustomUIsession.cc.

5 {}

Member Function Documentation

◆ ReceiveG4cerr()

G4int CustomUIsession::ReceiveG4cerr ( const G4String &  cerrString)
override

Definition at line 16 of file CustomUIsession.cc.

References trim().

16  {
17  edm::LogWarning("G4cerr") << trim(cerrString);
18  return 0;
19 }
std::string trim(const std::string &str)
Log< level::Warning, false > LogWarning

◆ ReceiveG4cout()

G4int CustomUIsession::ReceiveG4cout ( const G4String &  coutString)
override

Definition at line 7 of file CustomUIsession.cc.

References fout, and trim().

7  {
8  if (fout) {
9  (*fout) << trim(coutString) << "\n";
10  } else {
11  edm::LogVerbatim("G4cout") << trim(coutString);
12  }
13  return 0;
14 }
Log< level::Info, true > LogVerbatim
std::ofstream * fout
std::string trim(const std::string &str)

◆ sendToFile()

void CustomUIsession::sendToFile ( std::ofstream *  ptr)

Definition at line 27 of file CustomUIsession.cc.

References fout.

27  {
28  if (ptr && !ptr->fail()) {
29  fout = ptr;
30  }
31 }
std::ofstream * fout

◆ stopSendToFile()

void CustomUIsession::stopSendToFile ( )
inline

Definition at line 18 of file CustomUIsession.h.

References fout.

18 { fout = nullptr; }
std::ofstream * fout

◆ trim()

std::string CustomUIsession::trim ( const std::string &  str)
protected

Definition at line 21 of file CustomUIsession.cc.

References str.

Referenced by ReceiveG4cerr(), CustomUIsessionThreadPrefix::ReceiveG4cerr(), ReceiveG4cout(), and CustomUIsessionThreadPrefix::ReceiveG4cout().

21  {
22  if (!str.empty() && str.back() == '\n')
23  return str.substr(0, str.length() - 1);
24  return str;
25 }
#define str(s)

Member Data Documentation

◆ fout

std::ofstream* CustomUIsession::fout
private

Definition at line 24 of file CustomUIsession.h.

Referenced by ReceiveG4cout(), sendToFile(), and stopSendToFile().