Geant4  10.01.p02
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  void SetIgnoreInit(G4bool val=true) { ignoreInit = val; }
62  G4String GetPrefixString() const { return prefix; }
64  std::stringstream os;
65  os<<prefix<<id;
66  return os.str();
67  }
68 
69  private:
70 
71  void CloseCoutFile();
72  void CloseCerrFile();
73  void DumpBuffer();
74 
75  private:
76 
77  std::ostream& finalcout;
78  std::ostream& finalcerr;
79  const G4int id;
85 
86  std::ostringstream cout_buffer;
87  std::ostringstream cerr_buffer;
88  std::ofstream coutFile;
89  std::ofstream cerrFile;
91 };
92 
93 #endif
void SetCerrFileName(const G4String &fileN="G4cerr.txt", G4bool ifAppend=true)
G4String GetFullPrefixString() const
int G4int
Definition: G4Types.hh:78
std::ostringstream cout_buffer
void SetPrefixString(const G4String &wd="G4WT")
void SetCoutFileName(const G4String &fileN="G4cout.txt", G4bool ifAppend=true)
void SetIgnoreInit(G4bool val=true)
G4String GetPrefixString() const
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)
std::ostringstream cerr_buffer
virtual G4int ReceiveG4cerr(const G4String &)
virtual G4int ReceiveG4cout(const G4String &)