Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-16 23:25:22

0001 // -*- C++ -*-
0002 //
0003 // Package:     ESSources
0004 // Class  :     ProxyFactory
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Sat Jul 23 19:14:11 EDT 2005
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "CondCore/ESSources/interface/ProxyFactory.h"
0017 #include "CondCore/ESSources/interface/DataProxy.h"
0018 
0019 cond::DataProxyWrapperBase::DataProxyWrapperBase() {}
0020 
0021 cond::DataProxyWrapperBase::~DataProxyWrapperBase() {}
0022 
0023 void cond::DataProxyWrapperBase::addInfo(std::string const& il, std::string const& cs, std::string const& tag) {
0024   m_label = il;
0025   m_connString = cs;
0026   m_tag = tag;
0027 }
0028 
0029 void cond::DataProxyWrapperBase::loadTag(std::string const& tag) {
0030   m_session.transaction().start(true);
0031   m_iovProxy = m_session.readIov(tag);
0032   m_session.transaction().commit();
0033   m_currentIov.clear();
0034   m_requests = std::make_shared<std::vector<cond::Iov_t>>();
0035 }
0036 
0037 void cond::DataProxyWrapperBase::loadTag(std::string const& tag, boost::posix_time::ptime const& snapshotTime) {
0038   m_session.transaction().start(true);
0039   m_iovProxy = m_session.readIov(tag, snapshotTime);
0040   m_session.transaction().commit();
0041   m_currentIov.clear();
0042   m_requests = std::make_shared<std::vector<cond::Iov_t>>();
0043 }
0044 
0045 void cond::DataProxyWrapperBase::reload() {
0046   std::string tag = m_iovProxy.tagInfo().name;
0047   if (!tag.empty())
0048     loadTag(tag);
0049 }
0050 
0051 cond::ValidityInterval cond::DataProxyWrapperBase::setIntervalFor(Time_t time) {
0052   if (!m_currentIov.isValidFor(time)) {
0053     m_currentIov.clear();
0054     m_session.transaction().start(true);
0055     m_currentIov = m_iovProxy.getInterval(time);
0056     m_session.transaction().commit();
0057   }
0058   return cond::ValidityInterval(m_currentIov.since, m_currentIov.till);
0059 }
0060 
0061 EDM_REGISTER_PLUGINFACTORY(cond::ProxyFactory, cond::pluginCategory());
0062 
0063 namespace cond {
0064   const char* pluginCategory() { return "CondProxyFactory"; }
0065 }  // namespace cond