File indexing completed on 2025-01-18 09:58:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef G4MTcoutDestination_hh
0033 #define G4MTcoutDestination_hh
0034
0035 #include <fstream>
0036 #include <iostream>
0037 #include <sstream>
0038
0039 #include "G4MulticoutDestination.hh"
0040 #include "G4StateManager.hh"
0041 #include "globals.hh"
0042
0043 class G4LockcoutDestination;
0044
0045 class G4MTcoutDestination : public G4MulticoutDestination
0046 {
0047 public:
0048 explicit G4MTcoutDestination(const G4int& threadId);
0049 ~G4MTcoutDestination() override;
0050
0051 virtual void Reset();
0052
0053 void SetDefaultOutput(G4bool addMasterDestination = true,
0054 G4bool formatAlsoMaster = true);
0055
0056 void SetCoutFileName(const G4String& fileN = "G4cout.txt",
0057 G4bool ifAppend = true);
0058 void AddCoutFileName(const G4String& fileN = "G4cout.txt",
0059 G4bool ifAppend = true);
0060 void SetCerrFileName(const G4String& fileN = "G4cerr.txt",
0061 G4bool ifAppend = true);
0062 void AddCerrFileName(const G4String& fileN = "G4cerr.txt",
0063 G4bool ifAppend = true);
0064
0065 void EnableBuffering(G4bool flag = true);
0066
0067 inline void SetPrefixString(const G4String& wd = "G4WT") { prefix = wd; }
0068
0069 void SetIgnoreCout(G4int tid = 0);
0070 inline void SetIgnoreInit(G4bool val = true) { ignoreInit = val; }
0071
0072 inline G4String GetPrefixString() const { return prefix; }
0073 inline G4String GetFullPrefixString() const
0074 {
0075 std::stringstream os;
0076 os << prefix << id;
0077 return os.str();
0078 }
0079
0080 protected:
0081 void AddMasterOutput(G4bool formatAlsoMaster);
0082 void HandleFileCout(const G4String& fileN, G4bool appendFlag,
0083 G4bool suppressDefault);
0084 void HandleFileCerr(const G4String& fileN, G4bool appendFlag,
0085 G4bool suppressDefault);
0086
0087 private:
0088 void DumpBuffer();
0089
0090 private:
0091
0092 G4coutDestination* ref_defaultOut = nullptr;
0093
0094
0095 G4coutDestination* ref_masterOut = nullptr;
0096 G4bool masterDestinationFlag = true;
0097 G4bool masterDestinationFmtFlag = true;
0098
0099 const G4int id;
0100 G4bool useBuffer = false;
0101 G4bool ignoreCout = false;
0102 G4bool ignoreInit = true;
0103
0104 G4String prefix = "G4WT";
0105 G4StateManager* stateMgr = nullptr;
0106 };
0107
0108 #endif