CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Private Member Functions

cond::BasePayloadProxy Class Reference

#include <PayloadProxy.h>

Inheritance diagram for cond::BasePayloadProxy:
cond::PayloadProxy< DataT > cond::PayloadProxy< std::vector< cond::Time_t > > cond::PayloadProxy< cond::KeyList >

List of all members.

Classes

struct  ObjId
struct  Stats

Public Types

typedef std::vector< ObjIdObjIds

Public Member Functions

 BasePayloadProxy (cond::DbSession &session, bool errorPolicy)
 BasePayloadProxy (cond::DbSession &session, const std::string &token, bool errorPolicy)
virtual void invalidateCache ()=0
IOVProxy const & iov () const
bool isValid () const
cond::ValidityInterval loadFor (cond::Time_t time)
cond::ValidityInterval loadFor (size_t n)
void loadIov (const std::string iovToken)
virtual void loadMore (CondGetter const &)
void loadTag (const std::string tag)
void make ()
bool refresh (cond::DbSession &newSession)
bool refresh ()
cond::ValidityInterval setIntervalFor (cond::Time_t time)
TimeType timetype () const
std::string const & token () const
virtual ~BasePayloadProxy ()

Public Attributes

Stats stats

Static Public Attributes

static Stats gstats = {0,0,0,0,0,0,0}

Protected Attributes

bool m_doThrow
IOVElementProxy m_element
IOVProxy m_iov
DbSession m_session
std::string m_token

Private Member Functions

virtual bool load (cond::DbSession &session, std::string const &token)=0

Detailed Description

Definition at line 23 of file PayloadProxy.h.


Member Typedef Documentation

typedef std::vector<ObjId> cond::BasePayloadProxy::ObjIds

Definition at line 31 of file PayloadProxy.h.


Constructor & Destructor Documentation

cond::BasePayloadProxy::BasePayloadProxy ( cond::DbSession session,
bool  errorPolicy 
)

Definition at line 25 of file PayloadProxy.cc.

References gstats, cond::BasePayloadProxy::Stats::nProxy, alignCSCRings::s, and stats.

                                                       :
    m_doThrow(errorPolicy), m_iov(session),m_session(session) {
    ++gstats.nProxy;
    BasePayloadProxy::Stats s = {0,0,0,0,0,0,0,ObjIds()};
    stats = s;
  }
cond::BasePayloadProxy::BasePayloadProxy ( cond::DbSession session,
const std::string &  token,
bool  errorPolicy 
)

Definition at line 33 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), gstats, cond::IOVProxy::load(), m_iov, m_session, cond::BasePayloadProxy::Stats::nProxy, alignCSCRings::s, cond::DbTransaction::start(), stats, and cond::DbSession::transaction().

                                                       :
    m_doThrow(errorPolicy), m_iov(session),m_session(session) {
    m_session.transaction().start(true);
    m_iov.load( iovToken );
    m_session.transaction().commit();
    ++gstats.nProxy;
    BasePayloadProxy::Stats s = {0,0,0,0,0,0,0,ObjIds()};
    stats = s;
  }
cond::BasePayloadProxy::~BasePayloadProxy ( ) [virtual]

Definition at line 46 of file PayloadProxy.cc.

{}

Member Function Documentation

virtual void cond::BasePayloadProxy::invalidateCache ( ) [pure virtual]
IOVProxy const& cond::BasePayloadProxy::iov ( ) const [inline]

Definition at line 83 of file PayloadProxy.h.

References m_iov.

{ return m_iov;}
bool cond::BasePayloadProxy::isValid ( void  ) const
virtual bool cond::BasePayloadProxy::load ( cond::DbSession session,
std::string const &  token 
) [private, pure virtual]
cond::ValidityInterval cond::BasePayloadProxy::loadFor ( cond::Time_t  time)
cond::ValidityInterval cond::BasePayloadProxy::loadFor ( size_t  n)
void cond::BasePayloadProxy::loadIov ( const std::string  iovToken)

Definition at line 48 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), invalidateCache(), cond::IOVProxy::load(), m_iov, m_session, cond::DbTransaction::start(), and cond::DbSession::transaction().

                                                          {
    m_session.transaction().start(true);
    m_iov.load( iovToken );
    m_session.transaction().commit();
    invalidateCache();
  }
virtual void cond::BasePayloadProxy::loadMore ( CondGetter const &  ) [inline, virtual]

Reimplemented in cond::PayloadProxy< cond::KeyList >.

Definition at line 85 of file PayloadProxy.h.

{}
void cond::BasePayloadProxy::loadTag ( const std::string  tag)

Definition at line 55 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), cond::MetaData::getToken(), invalidateCache(), cond::IOVProxy::load(), m_iov, m_session, cond::DbTransaction::start(), and cond::DbSession::transaction().

                                                     {
    m_session.transaction().start(true);
    cond::MetaData metadata(m_session);
    std::string iovToken = metadata.getToken(tag);
    m_iov.load( iovToken );
    m_session.transaction().commit();
    invalidateCache();
  }
void cond::BasePayloadProxy::make ( )

Definition at line 77 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), alignCSCRings::e, Exception, gstats, cond::BasePayloadProxy::Stats::ids, cond::invalidTime(), isValid(), load(), m_doThrow, m_element, m_session, m_token, cond::BasePayloadProxy::Stats::nLoad, cond::BasePayloadProxy::Stats::nMake, convertSQLiteXML::ok, cond::IOVElementProxy::set(), cond::IOVElementProxy::since(), cond::DbTransaction::start(), stats, cond::IOVElementProxy::token(), token(), cond::DbSession::transaction(), and cms::Exception::what().

Referenced by loadFor().

                               {
    ++gstats.nMake;
    ++stats.nMake;
    bool ok = false;
    if ( isValid()) {
      // check if (afterall) the payload is still the same...
      if (m_element.token()==token()) return;
      try {
        m_session.transaction().start(true);
        ok = load( m_session ,m_element.token());
        m_session.transaction().commit();
        if (ok) m_token = m_element.token();
      } catch( const ora::Exception& e) {
        if (m_doThrow) throw cond::Exception(std::string("Condition Payload loader: ")+ e.what());
        ok = false;
      }
    }

    if (!ok) {
      m_element.set(cond::invalidTime,cond::invalidTime,"");
      m_token.clear();
      if (m_doThrow){
        throw cond::Exception("Condition Payload loader: invalid data");
      }
    }
    if (ok) { 
      ++gstats.nLoad; ++stats.nLoad;
      stats.ids.push_back(ObjId());
      fillIt(stats.ids.back(),m_token, m_element.since());
    }
  }
bool cond::BasePayloadProxy::refresh ( )
bool cond::BasePayloadProxy::refresh ( cond::DbSession newSession)
cond::ValidityInterval cond::BasePayloadProxy::setIntervalFor ( cond::Time_t  time)

Definition at line 110 of file PayloadProxy.cc.

References cond::IOVProxy::find(), m_element, m_iov, cond::IOVElementProxy::since(), and cond::IOVElementProxy::till().

                                                                       {
    //FIXME: shall handle truncation...
    if ( (!(time<m_element.till())) || time<m_element.since() ){
      m_element = *m_iov.find(time);
    }
    return cond::ValidityInterval(m_element.since(),m_element.till());
  }
TimeType cond::BasePayloadProxy::timetype ( ) const [inline]

Definition at line 81 of file PayloadProxy.h.

References m_iov, and cond::IOVProxy::timetype().

{ return m_iov.timetype();}
std::string const& cond::BasePayloadProxy::token ( ) const [inline]

Definition at line 65 of file PayloadProxy.h.

References m_token.

Referenced by make().

{ return m_token;}

Member Data Documentation

Definition at line 44 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), make(), refresh(), and CondDBESSource::~CondDBESSource().

Definition at line 97 of file PayloadProxy.h.

Referenced by make().

Definition at line 99 of file PayloadProxy.h.

Referenced by isValid(), loadFor(), make(), refresh(), and setIntervalFor().

Definition at line 100 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), loadIov(), loadTag(), make(), and refresh().

std::string cond::BasePayloadProxy::m_token [protected]

Definition at line 46 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), make(), and refresh().