Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VFileManager.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// Base class for File manager.
28//
29// Author: Ivana Hrivnacova, 18/06/2013 ([email protected])
30
31#ifndef G4VFileManager_h
32#define G4VFileManager_h 1
33
34#include "G4BaseFileManager.hh"
35#include "G4VTHnFileManager.hh"
36#include "globals.hh"
37
38namespace tools {
39namespace histo {
40class h1d;
41class h2d;
42class h3d;
43class p1d;
44class p2d;
45}
46}
47
49{
50 public:
51 explicit G4VFileManager(const G4AnalysisManagerState& state);
52 virtual ~G4VFileManager();
53
54 // Method to open default file
55 virtual G4bool OpenFile(const G4String& fileName) = 0;
56
57 // Methods applied to file per name
58 virtual G4bool CreateFile(const G4String& fileName) = 0;
59 virtual G4bool WriteFile(const G4String& fileName) = 0;
60 virtual G4bool CloseFile(const G4String& fileName) = 0;
61 virtual G4bool SetIsEmpty(const G4String& fileName, G4bool isEmpty) = 0;
62
63 // Methods applied to all registered files
64 virtual G4bool WriteFiles() = 0;
65 virtual G4bool CloseFiles() = 0;
66 virtual G4bool DeleteEmptyFiles() = 0;
67
68 // Methods for handling files and directories names
69 virtual G4bool SetFileName(const G4String& fileName) final;
72
73 void LockDirectoryNames();
74
75 G4bool IsOpenFile() const;
78
79 // Access to helpers
80 template <typename HT>
81 std::shared_ptr<G4VTHnFileManager<HT>> GetHnFileManager() const;
82
83 protected:
84 // data members
89
90 // FileManagers per object type
91 std::shared_ptr<G4VTHnFileManager<tools::histo::h1d>> fH1FileManager;
92 std::shared_ptr<G4VTHnFileManager<tools::histo::h2d>> fH2FileManager;
93 std::shared_ptr<G4VTHnFileManager<tools::histo::h3d>> fH3FileManager;
94 std::shared_ptr<G4VTHnFileManager<tools::histo::p1d>> fP1FileManager;
95 std::shared_ptr<G4VTHnFileManager<tools::histo::p2d>> fP2FileManager;
96};
97
98// inline functions
99
101{ fLockDirectoryNames = true; }
102
104{ return fIsOpenFile; }
105
107{ return fHistoDirectoryName; }
108
110{ return fNtupleDirectoryName; }
111
112template <>
113inline
114std::shared_ptr<G4VTHnFileManager<tools::histo::h1d>>
115G4VFileManager::GetHnFileManager<tools::histo::h1d>() const
116{ return fH1FileManager; }
117
118template <>
119inline
120std::shared_ptr<G4VTHnFileManager<tools::histo::h2d>>
121G4VFileManager::GetHnFileManager<tools::histo::h2d>() const
122{ return fH2FileManager; }
123
124template <>
125inline
126std::shared_ptr<G4VTHnFileManager<tools::histo::h3d>>
127G4VFileManager::GetHnFileManager<tools::histo::h3d>() const
128{ return fH3FileManager; }
129
130template <>
131inline
132std::shared_ptr<G4VTHnFileManager<tools::histo::p1d>>
133G4VFileManager::GetHnFileManager<tools::histo::p1d>() const
134{ return fP1FileManager; }
135
136template <>
137inline
138std::shared_ptr<G4VTHnFileManager<tools::histo::p2d>>
139G4VFileManager::GetHnFileManager<tools::histo::p2d>() const
140{ return fP2FileManager; }
141
142#endif
bool G4bool
Definition: G4Types.hh:86
virtual G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty)=0
virtual G4bool CloseFile(const G4String &fileName)=0
G4String GetNtupleDirectoryName() const
virtual G4bool WriteFile(const G4String &fileName)=0
virtual ~G4VFileManager()
std::shared_ptr< G4VTHnFileManager< tools::histo::h3d > > fH3FileManager
G4String GetHistoDirectoryName() const
G4bool SetHistoDirectoryName(const G4String &dirName)
std::shared_ptr< G4VTHnFileManager< tools::histo::h1d > > fH1FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::p1d > > fP1FileManager
G4bool IsOpenFile() const
G4String fNtupleDirectoryName
std::shared_ptr< G4VTHnFileManager< HT > > GetHnFileManager() const
std::shared_ptr< G4VTHnFileManager< tools::histo::p2d > > fP2FileManager
G4bool fLockDirectoryNames
virtual G4bool SetFileName(const G4String &fileName) final
virtual G4bool CloseFiles()=0
G4bool SetNtupleDirectoryName(const G4String &dirName)
void LockDirectoryNames()
virtual G4bool OpenFile(const G4String &fileName)=0
std::shared_ptr< G4VTHnFileManager< tools::histo::h2d > > fH2FileManager
virtual G4bool DeleteEmptyFiles()=0
virtual G4bool CreateFile(const G4String &fileName)=0
G4String fHistoDirectoryName
virtual G4bool WriteFiles()=0