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

In This Package:

ArchiveTrimSvc.cpp

Go to the documentation of this file.
00001 #include "ArchiveTrimSvc.h"
00002 #include "TrimmingAgent.h"
00003 
00004 #include "GaudiKernel/GaudiException.h"
00005 #include "GaudiKernel/IDataManagerSvc.h"
00006 #include "GaudiKernel/MsgStream.h"
00007 #include "GaudiKernel/SystemOfUnits.h"
00008 
00009 ArchiveTrimSvc::ArchiveTrimSvc(const std::string& name,
00010                                ISvcLocator* svc) :
00011                                  Service(name,
00012                                          svc),
00013                                  m_agent(0) {
00014   declareProperty("DefaultWindowSeconds",
00015                   m_defaultWindowSeconds=0,
00016                   "The default length of the trim window in seconds.");
00017   m_defaultWindowSeconds.declareUpdateHandler(&ArchiveTrimSvc::updateWindow,
00018                                               this);
00019 }
00020 
00021 StatusCode ArchiveTrimSvc::queryInterface(const InterfaceID& id,
00022                                           void** interface) {
00023   if (IArchiveTrimSvc::interfaceID().versionMatch(id)) {
00024     // If good enough match return this object.
00025     *interface = (IArchiveTrimSvc*)this;
00026     addRef();
00027   } else {
00028     // Interface is not directly available: try out a base class.
00029     return Service::queryInterface(id,
00030                                    interface);
00031   }
00032 
00033   return StatusCode::SUCCESS;
00034 }
00035 
00036 StatusCode ArchiveTrimSvc::initialize() {
00037   StatusCode status = Service::initialize();
00038   if (status.isFailure()) {
00039     throw GaudiException("Could not initialize super class",
00040                          name(),
00041                          status);
00042   }
00043 
00044   m_agent = new TrimmingAgent(new MsgStream(msgSvc(),
00045                                             name()));
00046   this->_update();
00047   return StatusCode::SUCCESS;
00048 }
00049 
00050 StatusCode ArchiveTrimSvc::finalize() {
00051   if (0 != m_agent) {
00052     delete m_agent;
00053   }
00054   
00055   return Service::finalize();
00056 }
00057 
00058 void ArchiveTrimSvc::updateWindow(Property& ) {
00059     if (! m_agent) return;
00060     this->_update();
00061 }
00062 
00063 void ArchiveTrimSvc::_update() 
00064 {
00065     MsgStream log(msgSvc(), name());
00066 
00067     TimeStamp dt(m_defaultWindowSeconds);
00068 
00069     log << MSG::INFO
00070         << "Setting default AES window to "
00071         << double(dt)
00072         << " seconds" << endreq;
00073     
00074     m_agent->setWindow(dt);
00075 }
00076 
00077 StatusCode ArchiveTrimSvc::trim(IDataManagerSvc* dataStore,
00078                                 TimeStamp latest) {
00079   m_agent->setLatest(latest);
00080   return dataStore->traverseTree(m_agent);
00081 }
00082 
00083 const TimeStamp& ArchiveTrimSvc::window(const std::string& path) {
00084   if ( 0 == m_agent) {
00085     throw GaudiException("Service not yet initialized",
00086                          name(),
00087                          StatusCode::FAILURE);
00088   }
00089   return m_agent->window(path);
00090 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:40:07 2011 for DybEventMgr by doxygen 1.4.7