ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MTcoutDestination.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4MTcoutDestination.hh
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 //
28 //
29 // ---------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 // G4MTcoutDestination.hh
33 //
34 // ---------------------------------------------------------------
35 #ifndef G4MTcoutDestination_H
36 #define G4MTcoutDestination_H
37 
38 #include <iostream>
39 #include <sstream>
40 #include <fstream>
41 
42 #include "globals.hh"
44 #include "G4StateManager.hh"
45 
47 
49 {
50  public:
51 
52  explicit G4MTcoutDestination(const G4int& threadId);
53  virtual ~G4MTcoutDestination();
54 
55  virtual void Reset();
56 
57  void SetDefaultOutput( G4bool addMasterDestination = true ,
58  G4bool formatAlsoMaster = true );
59 
60  void SetCoutFileName(const G4String& fileN = "G4cout.txt",
61  G4bool ifAppend = true);
62  void AddCoutFileName(const G4String& fileN = "G4cout.txt",
63  G4bool ifAppend = true);
64  void SetCerrFileName(const G4String& fileN = "G4cerr.txt",
65  G4bool ifAppend = true);
66  void AddCerrFileName(const G4String& fileN = "G4cerr.txt",
67  G4bool ifAppend = true);
68 
69  void EnableBuffering(G4bool flag=true);
70 
71  inline void SetPrefixString(const G4String& wd = "G4WT") { prefix = wd; }
72 
73  void SetIgnoreCout(G4int tid = 0);
74  inline void SetIgnoreInit(G4bool val=true) { ignoreInit = val; }
75 
76  inline G4String GetPrefixString() const { return prefix; }
78  {
79  std::stringstream os;
80  os<<prefix<<id;
81  return os.str();
82  }
83 
84  protected:
85 
86  void AddMasterOutput( G4bool formatAlsoMaster);
87  void HandleFileCout( G4String fileN, G4bool appendFlag,
88  G4bool suppressDefault);
89  void HandleFileCerr( G4String fileN, G4bool appendFlag,
90  G4bool suppressDefault);
91  private:
92 
93  void DumpBuffer();
94 
95  private:
96 
97  // Reference to the default destination
99 
100  // Reference to the master destination
104 
105  const G4int id;
109 
112 };
113 
114 #endif