| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

RootOutputFileManager Class Reference

Manage output files. More...

#include <RootOutputFileManager.h>

Collaboration diagram for RootOutputFileManager:

[legend]
List of all members.

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 RootOutputFileManagerget ()

Private Member Functions

void fire (const std::string &filename, RootIOIncident::FileState state)

Private Attributes

FileMap m_filemap
IIncidentSvcm_incsvc

Detailed Description

Manage output files.

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.


Member Typedef Documentation

typedef std::map<std::string,std::pair<int,TFile*> > RootOutputFileManager::FileMap

Definition at line 39 of file RootOutputFileManager.h.


Constructor & Destructor Documentation

RootOutputFileManager::RootOutputFileManager (  ) 

Definition at line 9 of file RootOutputFileManager.cc.

00010     : m_incsvc(0)
00011 {
00012 }

RootOutputFileManager::~RootOutputFileManager (  )  [virtual]

Definition at line 14 of file RootOutputFileManager.cc.

00015 {
00016     if (m_incsvc) {
00017         m_incsvc->release();
00018     }
00019     m_incsvc = 0;
00020 }


Member Function Documentation

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  ) 

Definition at line 42 of file RootOutputFileManager.cc.

00043 {
00044     return it->second.second; 
00045 }

int & RootOutputFileManager::count ( FileMap::iterator &  it  ) 

Definition at line 47 of file RootOutputFileManager.cc.

00048 {
00049     return it->second.first; 
00050 }

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 }


Member Data Documentation

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.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:18:22 2011 for RootIOSvc by doxygen 1.4.7