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

#include <G4MTcoutDestination.hh>

Inheritance diagram for G4MTcoutDestination:
G4coutDestination

Public Member Functions

 G4MTcoutDestination (const G4int &threadId, std::ostream &co=std::cout, std::ostream &ce=std::cerr)
 
virtual ~G4MTcoutDestination ()
 
virtual G4int ReceiveG4cout (const G4String &)
 
virtual G4int ReceiveG4cerr (const G4String &)
 
void SetCoutFileName (const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
 
void SetCerrFileName (const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
 
void EnableBuffering (G4bool flag=true)
 
void SetPrefixString (const G4String &wd="G4WT")
 
void SetIgnoreCout (G4int tid=0)
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()
 
virtual ~G4coutDestination ()
 

Detailed Description

Definition at line 45 of file G4MTcoutDestination.hh.

Constructor & Destructor Documentation

G4MTcoutDestination::G4MTcoutDestination ( const G4int threadId,
std::ostream &  co = std::cout,
std::ostream &  ce = std::cerr 
)

Definition at line 38 of file G4MTcoutDestination.cc.

References G4cerrbuf, G4coutbuf, and G4strstreambuf::SetDestination().

40 : finalcout(co), finalcerr(ce), id(threadId), useBuffer(false),
41  threadCoutToFile(false), threadCerrToFile(false), ignoreCout(false)
42 {
45  prefix = "G4WT";
46 }
G4strstreambuf G4coutbuf
Definition: G4ios.cc:82
void SetDestination(G4coutDestination *dest)
G4strstreambuf G4cerrbuf
Definition: G4ios.cc:83
G4MTcoutDestination::~G4MTcoutDestination ( )
virtual

Definition at line 48 of file G4MTcoutDestination.cc.

49 {
50  if( useBuffer ) DumpBuffer();
51  if( threadCoutToFile ) CloseCoutFile();
52  if( threadCerrToFile ) CloseCerrFile();
53 }

Member Function Documentation

void G4MTcoutDestination::EnableBuffering ( G4bool  flag = true)

Definition at line 105 of file G4MTcoutDestination.cc.

Referenced by G4UImanager::SetThreadUseBuffer().

106 {
107  if(useBuffer && !flag) DumpBuffer();
108  useBuffer = flag;
109 }
G4int G4MTcoutDestination::ReceiveG4cerr ( const G4String msg)
virtual

Reimplemented from G4coutDestination.

Definition at line 68 of file G4MTcoutDestination.cc.

69 {
70  if( threadCerrToFile )
71  { cerrFile<<msg<<std::flush; }
72  if( useBuffer )
73  { cerr_buffer<<msg; }
74  else
75  { G4AutoLock l(&coutm); finalcerr<<prefix<<id<<" > "<<msg; }
76  return 0;
77 }
G4int G4MTcoutDestination::ReceiveG4cout ( const G4String msg)
virtual

Reimplemented from G4coutDestination.

Definition at line 57 of file G4MTcoutDestination.cc.

58 {
59  if( threadCoutToFile )
60  { coutFile<<msg<<std::flush; }
61  else if( useBuffer )
62  { cout_buffer<<msg; }
63  else if( !ignoreCout )
64  { G4AutoLock l(&coutm); finalcout<<prefix<<id<<" > "<<msg; }
65  return 0;
66 }
void G4MTcoutDestination::SetCerrFileName ( const G4String fileN = "G4cerr.txt",
G4bool  ifAppend = true 
)

Definition at line 92 of file G4MTcoutDestination.cc.

References testem0::app.

Referenced by G4UImanager::SetCerrFileName().

93 {
94  if( threadCerrToFile ) CloseCerrFile();
95  if( fileN == "**Screen**" ) return;
96  if( ! cerrFile.is_open() )
97  {
98  std::ios::openmode mode = std::ios::out;
99  if ( ifAppend ) mode |= std::ios::app;
100  cerrFile.open(fileN,mode);
101  }
102  threadCerrToFile = true;
103 }
void G4MTcoutDestination::SetCoutFileName ( const G4String fileN = "G4cout.txt",
G4bool  ifAppend = true 
)

Definition at line 79 of file G4MTcoutDestination.cc.

References testem0::app.

Referenced by G4UImanager::SetCoutFileName().

80 {
81  if( threadCoutToFile ) CloseCoutFile();
82  if( fileN == "**Screen**" ) return;
83  if( ! coutFile.is_open() )
84  {
85  std::ios::openmode mode = std::ios::out;
86  if ( ifAppend ) mode |= std::ios::app;
87  coutFile.open(fileN,mode);
88  }
89  threadCoutToFile = true;
90 }
void G4MTcoutDestination::SetIgnoreCout ( G4int  tid = 0)

Definition at line 114 of file G4MTcoutDestination.cc.

Referenced by G4UImanager::SetThreadIgnore(), and G4UImanager::SetUpForAThread().

115 {
116  if(tid<0)
117  { ignoreCout = false; }
118  else
119  { ignoreCout = (tid!=id); }
120 }
void G4MTcoutDestination::SetPrefixString ( const G4String wd = "G4WT")

Definition at line 111 of file G4MTcoutDestination.cc.

Referenced by G4UImanager::SetThreadPrefixString().

112 { prefix = wd; }

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