/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 00016 #ifndef ROOTOUTPUTFILEMANAGER 00017 #define ROOTOUTPUTFILEMANAGER 00018 00019 #include "RootIOSvc/RootIOIncident.h" 00020 00021 #include <map> 00022 #include <string> 00023 00024 class TFile; 00025 class IIncidentSvc; 00026 00027 class RootOutputFileManager 00028 { 00029 public: 00030 RootOutputFileManager(); 00031 virtual ~RootOutputFileManager(); 00032 00033 // singleton 00034 static RootOutputFileManager& get(); 00035 00036 // Set the IncidentSvc 00037 void setIncidentSvc(IIncidentSvc* incsvc); 00038 00039 typedef std::map<std::string,std::pair<int,TFile*> > FileMap; 00040 00041 // helpers 00042 TFile*& file(FileMap::iterator& it); 00043 int& count(FileMap::iterator& it); 00044 00045 // Get TFile of given name, increase file's ref count 00046 TFile* get_file(const std::string& filename); 00047 00048 // Decrease file's ref count, really close when it hits zero. 00049 // When a file is actually closed a Gaudi Incident will be emitted 00050 // just before and just afterwards. 00051 void close_file(TFile*& tfile); 00052 00053 private: 00054 FileMap m_filemap; 00055 IIncidentSvc* m_incsvc; 00056 00057 void fire(const std::string& filename, RootIOIncident::FileState state); 00058 }; 00059 00060 #endif // ROOTOUTPUTFILEMANAGER