Geant4  10.00.p02
G4ofstreamDestination.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: G4coutDestination.hh 66241 2014-05-16 00:00:42Z adotti $
28 //
29 //
30 // ---------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // G4ofstreamDestination.hh
34 // Sends G4cout and G4cerr to a file.
35 //
36 // To send G4cout to a file instantiate an instance of
37 // G4CoutToFile
38 // To send G4cerr to a file use instead
39 // G4CerrToFile
40 //
41 // Example:
42 // #include "G4ofstreamDestination.hh"
43 // #include "G4ios.hh"
44 // int main(int,char**) {
45 // G4UImanager::GetUIpointer();
46 // G4iosInitialization();
47 // G4CoutToFile myout("MyOut_out.log"); // G4cout to file
48 // G4CerrToFile myout("MyOut_err.log"); // G4cerr to file
49 // ---------------------------------------------------------------
50 #ifndef G4OFSTREAMDESTINATION_HH
51 #define G4OFSTREAMDESTINATION_HH
52 
53 #include "G4coutDestination.hh"
54 #include <fstream>
55 
56 
58 {
59 public:
60  G4ofstreamDestinationBase(const G4String& defaultName , G4bool append);
62 
63  virtual G4int ReceiveG4cout( const G4String& ) = 0;
64  virtual G4int ReceiveG4cerr( const G4String& ) = 0;
65 
66  void SetFileName( const G4String& name , G4bool append = true );
67  void Close();
68  void Open();
69 private:
72 protected:
73  std::ofstream g4file;
74 };
75 
77 {
78 public:
79  G4CoutToFile(const G4String& deafaultName = "Geant4_cout.txt", G4bool append = true);
80  virtual G4int ReceiveG4cout( const G4String& msg );
81  virtual G4int ReceiveG4cerr( const G4String& ) { return 0;}
82 };
83 
85 {
86 public:
87  G4CerrToFile(const G4String& deafaultName = "Geant4_cerr.txt", G4bool append = true);
88  virtual G4int ReceiveG4cout( const G4String& ) { return 0; }
89  virtual G4int ReceiveG4cerr( const G4String& msg );
90 
91 };
92 #endif //G4OFSTREAMDESTINATION_HH
virtual G4int ReceiveG4cerr(const G4String &)
virtual G4int ReceiveG4cerr(const G4String &msg)
G4CerrToFile(const G4String &deafaultName="Geant4_cerr.txt", G4bool append=true)
G4String name
Definition: TRTMaterials.hh:40
int G4int
Definition: G4Types.hh:78
G4ofstreamDestinationBase(const G4String &defaultName, G4bool append)
bool G4bool
Definition: G4Types.hh:79
void SetFileName(const G4String &name, G4bool append=true)
virtual G4int ReceiveG4cerr(const G4String &)=0
G4CoutToFile(const G4String &deafaultName="Geant4_cout.txt", G4bool append=true)
virtual G4int ReceiveG4cout(const G4String &)=0
virtual G4int ReceiveG4cout(const G4String &)
virtual G4int ReceiveG4cout(const G4String &msg)