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

In This Package:

RootIOFileStateSvc.cc

Go to the documentation of this file.
00001 #include "RootIOSvc/RootIOFileStateSvc.h"
00002 
00003 #include "RootIOSvc/RootIOIncident.h"
00004 
00005 #include "GaudiKernel/IIncidentSvc.h"
00006 
00007 #include <algorithm>
00008 
00009 RootIOFileStateSvc::RootIOFileStateSvc(const std::string& name, ISvcLocator* svc)
00010     : Service(name,svc)
00011 {
00012 }
00013 
00014 RootIOFileStateSvc::~RootIOFileStateSvc()
00015 {
00016 }
00017     
00018 StatusCode RootIOFileStateSvc::initialize()
00019 {
00020     MsgStream log(msgSvc(), "RootIOFileStateSvc");
00021 
00022     StatusCode sc = this->Service::initialize();
00023     if (sc.isFailure()) return sc;
00024 
00025     sc = this->service("IncidentSvc",m_incsvc,true);
00026     if (sc.isFailure()) {
00027         log << MSG::ERROR
00028             << "Failed to get IncidentSvc" << endreq;
00029         return sc;
00030     }
00031     m_incsvc->addListener(this,"RootIOIncident");
00032 
00033     return sc;
00034 }
00035 
00036 StatusCode RootIOFileStateSvc::finalize()
00037 {
00038     m_incsvc->removeListener(this,"RootIOIncident");
00039     m_incsvc->release();
00040 
00041     return this->Service::finalize();
00042 }
00043 
00044 StatusCode RootIOFileStateSvc::queryInterface(const InterfaceID& riid, void** ppint)
00045 {
00046     if (IRootIOFileStateSvc::interfaceID().versionMatch(riid)) {
00047         *ppint = (IRootIOFileStateSvc*)this;
00048         this->addRef();
00049         return StatusCode::SUCCESS;
00050     }
00051     return this->Service::queryInterface(riid,ppint);
00052 }
00053 
00054 void RootIOFileStateSvc::handle(const Incident& incident)
00055 {
00056     MsgStream log(msgSvc(), "RootIOFileStateSvc");
00057 
00058     // Handle the incident in a trivial manner
00059 
00060     const RootIOIncident* rioinc = dynamic_cast<const RootIOIncident*>(&incident);
00061     if (!rioinc) {
00062         log << MSG::WARNING
00063             << "Ignoring unexpected incident not of class RootIOIncident" 
00064             << endreq;
00065         return;
00066     }
00067     
00068     if (rioinc->state() == RootIOIncident::opened_output) {
00069         std::string fn = rioinc->filename();
00070         log << MSG::DEBUG
00071             << "Adding opened output \"" << fn
00072             << "\" to " << m_open.size() << " others"
00073             << endreq;
00074         m_open.push_back(fn);
00075         return;
00076     }
00077 
00078     if (rioinc->state() == RootIOIncident::closed_output) {
00079         std::string fn = rioinc->filename();
00080         log << MSG::DEBUG
00081             << "Adding closed output \"" << fn
00082             << "\" to " << m_closed.size() << " others"
00083             << endreq;
00084         m_closed.push_back(fn);
00085 
00086 
00087         std::list<std::string>::iterator it = std::find(m_open.begin(),m_open.end(),fn);
00088         if (it != m_open.end()) {
00089             m_open.erase(it);
00090             log << MSG::DEBUG
00091                 << "Erased \"" << *it << "\" from open list, " << m_open.size() << " left" 
00092                 << endreq;
00093         }
00094     }
00095 }
00096 
00097 IRootIOFileStateSvc::FileList_t RootIOFileStateSvc::closedOutput()
00098 {
00099     return FileList_t(m_closed.begin(),m_closed.end());
00100 }
00101 
00102 IRootIOFileStateSvc::FileList_t RootIOFileStateSvc::openOutput()
00103 {
00104     return FileList_t(m_open.begin(),m_open.end());
00105 }
00106 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

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