File indexing completed on 2025-01-18 09:59:27
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 #ifndef G4VTFileManager_h
0032 #define G4VTFileManager_h 1
0033
0034 #include "G4VFileManager.hh"
0035 #include "G4TNtupleDescription.hh"
0036 #include "G4TFileManager.hh"
0037 #include "globals.hh"
0038
0039 #include "tools/wcsv_ntuple"
0040
0041 template <typename FT>
0042 class G4VTFileManager : public G4VFileManager,
0043 public G4TFileManager<FT>
0044 {
0045 public:
0046 explicit G4VTFileManager(const G4AnalysisManagerState& state)
0047 : G4VFileManager(state), G4TFileManager<FT>(state) {}
0048 ~G4VTFileManager() override = default;
0049
0050 using G4VFileManager::WriteFile;
0051 using G4VFileManager::CloseFile;
0052
0053
0054 G4bool CreateFile(const G4String& fileName) final;
0055 G4bool WriteFile(const G4String& fileName) final;
0056 G4bool CloseFile(const G4String& fileName) final;
0057 G4bool SetIsEmpty(const G4String& fileName, G4bool isEmpty) final;
0058
0059
0060 G4bool OpenFiles() final;
0061 G4bool WriteFiles() final;
0062 G4bool CloseFiles() final;
0063 G4bool DeleteEmptyFiles() final;
0064
0065
0066 void Clear() final;
0067
0068
0069 std::shared_ptr<FT> GetFile() const;
0070
0071 protected:
0072
0073
0074 std::shared_ptr<FT> fFile { nullptr };
0075 };
0076
0077
0078 template <typename FT>
0079 inline
0080 G4bool G4VTFileManager<FT>::CreateFile(const G4String& fileName)
0081 {
0082 return (G4TFileManager<FT>::CreateTFile(fileName) != nullptr);
0083 }
0084
0085
0086 template <typename FT>
0087 inline
0088 G4bool G4VTFileManager<FT>::WriteFile(const G4String& fileName)
0089 {
0090 return G4TFileManager<FT>::WriteTFile(fileName);
0091 }
0092
0093
0094 template <typename FT>
0095 inline
0096 G4bool G4VTFileManager<FT>::CloseFile(const G4String& fileName)
0097 {
0098 return G4TFileManager<FT>::CloseTFile(fileName);
0099 }
0100
0101
0102 template <typename FT>
0103 inline
0104 G4bool G4VTFileManager<FT>::SetIsEmpty(const G4String& fileName, G4bool isEmpty)
0105 {
0106 return G4TFileManager<FT>::SetIsEmpty(fileName, isEmpty);
0107 }
0108
0109
0110 template <typename FT>
0111 inline
0112 G4bool G4VTFileManager<FT>::OpenFiles()
0113 {
0114 return G4TFileManager<FT>::OpenFiles();
0115 }
0116
0117
0118 template <typename FT>
0119 inline
0120 G4bool G4VTFileManager<FT>::WriteFiles()
0121 {
0122 return G4TFileManager<FT>::WriteFiles();
0123 }
0124
0125
0126 template <typename FT>
0127 inline
0128 G4bool G4VTFileManager<FT>::CloseFiles()
0129 {
0130 auto result = G4TFileManager<FT>::CloseFiles();
0131
0132 fIsOpenFile = false;
0133 fFile.reset();
0134
0135 return result;
0136 }
0137
0138
0139 template <typename FT>
0140 inline
0141 G4bool G4VTFileManager<FT>::DeleteEmptyFiles()
0142 {
0143 auto result = G4TFileManager<FT>::DeleteEmptyFiles();
0144
0145
0146 Clear();
0147
0148 return result;
0149 }
0150
0151
0152 template <typename FT>
0153 inline
0154 void G4VTFileManager<FT>::Clear()
0155 {
0156 G4TFileManager<FT>::ClearData();
0157 G4BaseFileManager::ClearData();
0158 UnlockDirectoryNames();
0159 }
0160
0161
0162 template <typename FT>
0163 inline std::shared_ptr<FT> G4VTFileManager<FT>::GetFile() const
0164 {
0165 return fFile;
0166 }
0167
0168 #endif