Geant4_10
G4MTcoutDestination.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4MTcoutDestination.hh 66241 2012-12-13 18:34:42Z gunter $
28 //
29 //
30 // ---------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // G4MTcoutDestination.hh
34 //
35 // ---------------------------------------------------------------
36 #ifndef G4MTcoutDestination_H
37 #define G4MTcoutDestination_H
38 
39 #include "globals.hh"
40 #include "G4coutDestination.hh"
41 #include <iostream>
42 #include <sstream>
43 #include <fstream>
44 
46 {
47  public:
48 
49  G4MTcoutDestination(const G4int& threadId,
50  std::ostream& co=std::cout, std::ostream& ce=std::cerr);
51  virtual ~G4MTcoutDestination();
52 
53  virtual G4int ReceiveG4cout(const G4String&);
54  virtual G4int ReceiveG4cerr(const G4String&);
55 
56  void SetCoutFileName(const G4String& fileN = "G4cout.txt", G4bool ifAppend = true);
57  void SetCerrFileName(const G4String& fileN = "G4cerr.txt", G4bool ifAppend = true);
58  void EnableBuffering(G4bool flag=true);
59  void SetPrefixString(const G4String& wd = "G4WT");
60  void SetIgnoreCout(G4int tid = 0);
61 
62  private:
63 
64  void CloseCoutFile();
65  void CloseCerrFile();
66  void DumpBuffer();
67 
68  private:
69 
70  std::ostream& finalcout;
71  std::ostream& finalcerr;
72  const G4int id;
73  G4bool useBuffer;
74  G4bool threadCoutToFile;
75  G4bool threadCerrToFile;
76  G4bool ignoreCout;
77 
78  std::ostringstream cout_buffer;
79  std::ostringstream cerr_buffer;
80  std::ofstream coutFile;
81  std::ofstream cerrFile;
83 };
84 
85 #endif
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
int G4int
Definition: G4Types.hh:78
void SetPrefixString(const G4String &wd="G4WT")
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
bool G4bool
Definition: G4Types.hh:79
G4MTcoutDestination(const G4int &threadId, std::ostream &co=std::cout, std::ostream &ce=std::cerr)
void EnableBuffering(G4bool flag=true)
void SetIgnoreCout(G4int tid=0)
virtual G4int ReceiveG4cerr(const G4String &)
virtual G4int ReceiveG4cout(const G4String &)