Geant4-11
source
visualization
FukuiRenderer
include
G4FRofstream.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
//
28
29
#ifndef G4_FR_OFSTREAM_HH
30
#define G4_FR_OFSTREAM_HH
31
32
#include <fstream>
33
34
#include "
globals.hh
"
35
36
class
G4FRofstream
37
{
38
public
:
39
enum
40
{
41
SEND_BUFMAX
= 1024
42
};
43
44
public
:
45
// constructors
46
G4FRofstream
() {
flag_file_open
=
false
; }
47
G4FRofstream
(
const
char
* filename);
48
49
// destructor
50
virtual
~G4FRofstream
();
51
52
// open and close
53
void
Open
(
const
char
* filename);
54
void
Close
();
55
G4bool
IsOpen
() {
return
flag_file_open
; }
56
57
// utilities
58
void
SendLine
(
const
char
*
string
);
// save string with new line
59
60
// static functions
61
static
G4bool
DoesFileExist
(
const
char
* filename);
62
63
protected
:
64
G4bool
flag_file_open
;
65
std::ofstream
fout
;
66
};
67
68
inline
void
G4FRofstream::Open
(
const
char
* filename)
69
{
70
if
(!
IsOpen
())
71
{
72
fout
.open(filename);
73
flag_file_open
=
true
;
74
}
75
}
76
77
inline
void
G4FRofstream::Close
()
78
{
79
if
(
IsOpen
())
80
{
81
fout
.close();
82
flag_file_open
=
false
;
83
}
84
}
85
86
inline
void
G4FRofstream::SendLine
(
const
char
* message)
87
{
88
if
(
IsOpen
())
89
{
90
fout
<< message <<
G4endl
;
91
}
92
}
93
94
inline
G4bool
G4FRofstream::DoesFileExist
(
const
char
* filename)
95
{
96
G4bool
status =
false
;
97
98
std::ifstream fout_tmp(filename);
99
if
(fout_tmp)
100
{
101
status =
true
;
102
}
103
fout_tmp.close();
104
105
return
status;
106
}
107
108
inline
G4FRofstream::G4FRofstream
(
const
char
* filename)
109
{
110
flag_file_open
=
false
;
111
Open
(filename);
112
}
113
114
inline
G4FRofstream::~G4FRofstream
() {
Close
(); }
115
116
#endif
G4bool
bool G4bool
Definition:
G4Types.hh:86
G4endl
#define G4endl
Definition:
G4ios.hh:57
G4FRofstream
Definition:
G4FRofstream.hh:37
G4FRofstream::flag_file_open
G4bool flag_file_open
Definition:
G4FRofstream.hh:64
G4FRofstream::~G4FRofstream
virtual ~G4FRofstream()
Definition:
G4FRofstream.hh:114
G4FRofstream::SendLine
void SendLine(const char *string)
Definition:
G4FRofstream.hh:86
G4FRofstream::Open
void Open(const char *filename)
Definition:
G4FRofstream.hh:68
G4FRofstream::IsOpen
G4bool IsOpen()
Definition:
G4FRofstream.hh:55
G4FRofstream::SEND_BUFMAX
@ SEND_BUFMAX
Definition:
G4FRofstream.hh:41
G4FRofstream::G4FRofstream
G4FRofstream()
Definition:
G4FRofstream.hh:46
G4FRofstream::DoesFileExist
static G4bool DoesFileExist(const char *filename)
Definition:
G4FRofstream.hh:94
G4FRofstream::Close
void Close()
Definition:
G4FRofstream.hh:77
G4FRofstream::fout
std::ofstream fout
Definition:
G4FRofstream.hh:65
globals.hh
Generated by
1.9.3