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, 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)
virtual void loadMore (CondGetter const &)
void make ()
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}

Protected Attributes

bool m_doThrow
IOVElementProxy m_element
IOVProxy m_iov
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,
const std::string &  token,
bool  errorPolicy 
)

Definition at line 24 of file PayloadProxy.cc.

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

                                                       :
    m_doThrow(errorPolicy), m_iov(session,token,true,false) {
    ++gstats.nProxy;
    BasePayloadProxy::Stats s = {0,0,0,ObjIds()};
    stats = s;
  }
cond::BasePayloadProxy::~BasePayloadProxy ( ) [virtual]

Definition at line 34 of file PayloadProxy.cc.

{}

Member Function Documentation

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

Definition at line 72 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 ( size_t  n)
cond::ValidityInterval cond::BasePayloadProxy::loadFor ( cond::Time_t  time)
virtual void cond::BasePayloadProxy::loadMore ( CondGetter const &  ) [inline, virtual]

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

Definition at line 74 of file PayloadProxy.h.

{}
void cond::BasePayloadProxy::make ( )

Definition at line 49 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), cond::IOVElementProxy::db(), ExpressReco_HICollisions_FallBack::e, Exception, gstats, cond::BasePayloadProxy::Stats::ids, cond::invalidTime(), isValid(), load(), m_doThrow, m_element, 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;
      cond::DbTransaction& trans = m_element.db().transaction();
      trans.start(true);
      try {
        ok = load( m_element.db(),m_element.token());
        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;
      }
      trans.commit();
    }

    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 ( )

Definition at line 95 of file PayloadProxy.cc.

References m_element, m_iov, and cond::IOVProxy::refresh().

                                  {
    bool anew = m_iov.refresh();
    if (anew)  m_element = IOVElementProxy();
    return anew;
  }
cond::ValidityInterval cond::BasePayloadProxy::setIntervalFor ( cond::Time_t  time)

Definition at line 82 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 70 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 54 of file PayloadProxy.h.

References m_token.

Referenced by make().

{ return m_token;}

Member Data Documentation

Definition at line 40 of file PayloadProxy.h.

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

Definition at line 85 of file PayloadProxy.h.

Referenced by make().

Definition at line 87 of file PayloadProxy.h.

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

Definition at line 86 of file PayloadProxy.h.

Referenced by iov(), loadFor(), refresh(), setIntervalFor(), and timetype().

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

Definition at line 42 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), and make().