File indexing completed on 2025-01-18 09:59:29
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 G4XmlFileManager_h
0032 #define G4XmlFileManager_h 1
0033
0034 #include "G4VTFileManager.hh"
0035 #include "G4TNtupleDescription.hh"
0036 #include "G4TFileManager.hh"
0037 #include "globals.hh"
0038
0039 #include "tools/waxml/ntuple"
0040
0041 #include <fstream>
0042 #include <memory>
0043 #include <string_view>
0044
0045
0046 using XmlNtupleDescription = G4TNtupleDescription<tools::waxml::ntuple, std::ofstream>;
0047
0048 class G4AnalysisManagerState;
0049
0050 class G4XmlFileManager : public G4VTFileManager<std::ofstream>
0051 {
0052 public:
0053 explicit G4XmlFileManager(const G4AnalysisManagerState& state);
0054 G4XmlFileManager() = delete;
0055 ~G4XmlFileManager() override = default;
0056
0057 using G4BaseFileManager::GetNtupleFileName;
0058 using G4VTFileManager<std::ofstream>::WriteFile;
0059 using G4VTFileManager<std::ofstream>::CloseFile;
0060
0061
0062 G4bool OpenFile(const G4String& fileName) final;
0063
0064 G4String GetFileType() const final { return "xml"; }
0065
0066
0067 G4bool CreateNtupleFile(XmlNtupleDescription* ntupleDescription);
0068 G4bool CloseNtupleFile(XmlNtupleDescription* ntupleDescription);
0069
0070 protected:
0071
0072 std::shared_ptr<std::ofstream> CreateFileImpl(const G4String& fileName) final;
0073 G4bool WriteFileImpl(std::shared_ptr<std::ofstream> file) final;
0074 G4bool CloseFileImpl(std::shared_ptr<std::ofstream> file) final;
0075
0076 private:
0077
0078 G4String GetNtupleFileName(XmlNtupleDescription* ntupleDescription);
0079
0080
0081 static constexpr std::string_view fkClass { "G4XmlFileManager" };
0082 };
0083
0084 #endif