/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
RootOutputFileManager Class Reference

Manage output files. More...

#include <RootOutputFileManager.h>

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
IIncidentSvc * m_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.

    : m_incsvc(0)
{
}
RootOutputFileManager::~RootOutputFileManager ( ) [virtual]

Definition at line 14 of file RootOutputFileManager.cc.

{
    if (m_incsvc) {
        m_incsvc->release();
    }
    m_incsvc = 0;
}

Member Function Documentation

RootOutputFileManager & RootOutputFileManager::get ( ) [static]

Definition at line 22 of file RootOutputFileManager.cc.

{
    static RootOutputFileManager* me = 0;
    if (!me) me = new RootOutputFileManager;
    return *me;
}
void RootOutputFileManager::setIncidentSvc ( IIncidentSvc *  incsvc)

Definition at line 30 of file RootOutputFileManager.cc.

{
    if (m_incsvc) {
        m_incsvc->release();
        m_incsvc = 0;
    }
    m_incsvc = incsvc;
    if (m_incsvc) {
        m_incsvc->addRef();
    }
}
TFile *& RootOutputFileManager::file ( FileMap::iterator &  it)

Definition at line 42 of file RootOutputFileManager.cc.

{
    return it->second.second; 
}
int & RootOutputFileManager::count ( FileMap::iterator &  it)

Definition at line 47 of file RootOutputFileManager.cc.

{
    return it->second.first; 
}
TFile * RootOutputFileManager::get_file ( const std::string &  filename)

Definition at line 61 of file RootOutputFileManager.cc.

                                                             {
    FileMap::iterator it = m_filemap.find(filename);
    if (it == m_filemap.end()) {  // miss
 
        TFile* file = TFile::Open(filename.c_str(),"recreate","RootOutputStream file");
        m_filemap[filename] = pair<int,TFile*>(1,file);
        this->fire(filename,RootIOIncident::opened_output);
        return file;
    }
    // hit
    ++count(it);
    return file(it);
}
void RootOutputFileManager::close_file ( TFile *&  tfile)

Definition at line 75 of file RootOutputFileManager.cc.

                                                    {
    string filename = tfile->GetName();
    tfile = 0;
    FileMap::iterator it = m_filemap.find(filename);
    if (it == m_filemap.end()) {  // miss, already closed?
        return;
    }

    --count(it);
    if (count(it)) return;  // still more references

    this->fire(filename,RootIOIncident::closing_output);
    file(it)->Close();
    this->fire(filename,RootIOIncident::closed_output);
    delete file(it);
    file(it) = 0;
    m_filemap.erase(it);
}
void RootOutputFileManager::fire ( const std::string &  filename,
RootIOIncident::FileState  state 
) [private]

Definition at line 52 of file RootOutputFileManager.cc.

{
    if (!m_incsvc) {
        return;                 // error message?
    }

    m_incsvc->fireIncident(RootIOIncident("RootOutputFileManager","RootIOIncident",filename,state));    
}

Member Data Documentation

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 Fri May 16 2014 09:58:18 for RootIOSvc by doxygen 1.7.4