#include <RootOutputFileManager.h>
Collaboration diagram for RootOutputFileManager:
Public Types | |
typedef std::map< std::string, std::pair< int, TFile * > > | FileMap |
Public Member Functions | |
RootOutputFileManager () | |
virtual | ~RootOutputFileManager () |
void | setIncidentSvc (IIncidentSvc *incsvc) |
TFile *& | file (FileMap::iterator &it) |
int & | count (FileMap::iterator &it) |
TFile * | get_file (const std::string &filename) |
void | close_file (TFile *&tfile) |
Static Public Member Functions | |
static RootOutputFileManager & | get () |
Private Member Functions | |
void | fire (const std::string &filename, RootIOIncident::FileState state) |
Private Attributes | |
FileMap | m_filemap |
IIncidentSvc * | m_incsvc |
Many streams may share the same output file. This manages openning and closing the actual file.
This is not a user servicable class.
Brett Viren <bv@bnl.gov> Fri Feb 18 13:17:40 2011
Definition at line 27 of file RootOutputFileManager.h.
typedef std::map<std::string,std::pair<int,TFile*> > RootOutputFileManager::FileMap |
Definition at line 39 of file RootOutputFileManager.h.
RootOutputFileManager::RootOutputFileManager | ( | ) |
RootOutputFileManager::~RootOutputFileManager | ( | ) | [virtual] |
RootOutputFileManager & RootOutputFileManager::get | ( | ) | [static] |
Definition at line 22 of file RootOutputFileManager.cc.
00023 { 00024 static RootOutputFileManager* me = 0; 00025 if (!me) me = new RootOutputFileManager; 00026 return *me; 00027 }
void RootOutputFileManager::setIncidentSvc | ( | IIncidentSvc * | incsvc | ) |
Definition at line 30 of file RootOutputFileManager.cc.
00031 { 00032 if (m_incsvc) { 00033 m_incsvc->release(); 00034 m_incsvc = 0; 00035 } 00036 m_incsvc = incsvc; 00037 if (m_incsvc) { 00038 m_incsvc->addRef(); 00039 } 00040 }
TFile *& RootOutputFileManager::file | ( | FileMap::iterator & | it | ) |
int & RootOutputFileManager::count | ( | FileMap::iterator & | it | ) |
TFile* RootOutputFileManager::get_file | ( | const std::string & | filename | ) |
void RootOutputFileManager::close_file | ( | TFile *& | tfile | ) |
Definition at line 75 of file RootOutputFileManager.cc.
00075 { 00076 string filename = tfile->GetName(); 00077 tfile = 0; 00078 FileMap::iterator it = m_filemap.find(filename); 00079 if (it == m_filemap.end()) { // miss, already closed? 00080 return; 00081 } 00082 00083 --count(it); 00084 if (count(it)) return; // still more references 00085 00086 this->fire(filename,RootIOIncident::closing_output); 00087 file(it)->Close(); 00088 this->fire(filename,RootIOIncident::closed_output); 00089 delete file(it); 00090 file(it) = 0; 00091 m_filemap.erase(it); 00092 }
void RootOutputFileManager::fire | ( | const std::string & | filename, | |
RootIOIncident::FileState | state | |||
) | [private] |
Definition at line 52 of file RootOutputFileManager.cc.
00053 { 00054 if (!m_incsvc) { 00055 return; // error message? 00056 } 00057 00058 m_incsvc->fireIncident(RootIOIncident("RootOutputFileManager","RootIOIncident",filename,state)); 00059 }
FileMap RootOutputFileManager::m_filemap [private] |
Definition at line 54 of file RootOutputFileManager.h.
IIncidentSvc* RootOutputFileManager::m_incsvc [private] |
Definition at line 55 of file RootOutputFileManager.h.