// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // The common implementaion of G4VFileManager functions via G4TFileManager. // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr) #ifndef G4VTFileManager_h #define G4VTFileManager_h 1 #include "G4VFileManager.hh" #include "G4TNtupleDescription.hh" #include "G4TFileManager.hh" #include "globals.hh" #include "tools/wcsv_ntuple" template class G4VTFileManager : public G4VFileManager, public G4TFileManager { public: explicit G4VTFileManager(const G4AnalysisManagerState& state) : G4VFileManager(state), G4TFileManager(state) {} virtual ~G4VTFileManager() = default; using G4VFileManager::WriteFile; using G4VFileManager::CloseFile; // Methods applied to file per name virtual G4bool CreateFile(const G4String& fileName) final; virtual G4bool WriteFile(const G4String& fileName) final; virtual G4bool CloseFile(const G4String& fileName) final; virtual G4bool SetIsEmpty(const G4String& fileName, G4bool isEmpty) final; // Methods applied to all registered files virtual G4bool WriteFiles() final; virtual G4bool CloseFiles() final; virtual G4bool DeleteEmptyFiles() final; // Clear all data virtual void Clear() final; // Get method std::shared_ptr GetFile() const; protected: // Data members // Default file - created at OpenFile call std::shared_ptr fFile { nullptr }; }; //_____________________________________________________________________________ template inline G4bool G4VTFileManager::CreateFile(const G4String& fileName) { return (G4TFileManager::CreateTFile(fileName) != nullptr); } //_____________________________________________________________________________ template inline G4bool G4VTFileManager::WriteFile(const G4String& fileName) { return G4TFileManager::WriteTFile(fileName); } //_____________________________________________________________________________ template inline G4bool G4VTFileManager::CloseFile(const G4String& fileName) { return G4TFileManager::CloseTFile(fileName); } //_____________________________________________________________________________ template inline G4bool G4VTFileManager::SetIsEmpty(const G4String& fileName, G4bool isEmpty) { return G4TFileManager::SetIsEmpty(fileName, isEmpty); } //_____________________________________________________________________________ template inline G4bool G4VTFileManager::WriteFiles() { return G4TFileManager::WriteFiles(); } //_____________________________________________________________________________ template inline G4bool G4VTFileManager::CloseFiles() { auto result = G4TFileManager::CloseFiles(); fIsOpenFile = false; fFile.reset(); return result; } //_____________________________________________________________________________ template inline G4bool G4VTFileManager::DeleteEmptyFiles() { return G4TFileManager::DeleteEmptyFiles(); } //_____________________________________________________________________________ template inline void G4VTFileManager::Clear() { G4TFileManager::ClearData(); UnlockDirectoryNames(); } //_____________________________________________________________________________ template inline std::shared_ptr G4VTFileManager::GetFile() const { return fFile; } #endif