CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

cond::DbSession Class Reference

#include <DbSession.h>

List of all members.

Public Member Functions

const std::string & blobStreamingService () const
void close ()
const DbConnectionconnection () const
const std::string & connectionString () const
 DbSession (const DbConnection &connection)
 DbSession (const DbSession &rhs)
 DbSession ()
bool deleteMapping (const std::string &mappingVersion)
bool deleteObject (const std::string &objectId)
void flush ()
ora::Object getObject (const std::string &objectId)
template<typename T >
boost::shared_ptr< T > getTypedObject (const std::string &objectId)
bool importMapping (const std::string &sourceConnectionString, const std::string &contName)
std::string importObject (cond::DbSession &fromDatabase, const std::string &objectId)
bool isOpen () const
bool isTransactional () const
coral::ISchema & nominalSchema ()
void open (const std::string &connectionString, bool readOnly=false)
DbSessionoperator= (const DbSession &rhs)
coral::ISchema & schema (const std::string &schemaName)
ora::Databasestorage ()
template<typename T >
std::string storeObject (const T *object, const std::string &containerName)
DbTransactiontransaction ()
template<typename T >
bool updateObject (const T *object, const std::string &objectId)
virtual ~DbSession ()

Private Member Functions

std::string storeObject (const ora::Object &objectRef, const std::string &containerName)

Private Attributes

boost::shared_ptr< SessionImplm_implementation

Detailed Description

Definition at line 36 of file DbSession.h.


Constructor & Destructor Documentation

DbSession::DbSession ( )

Definition at line 99 of file DbSession.cc.

                        :
  m_implementation( new SessionImpl ){ 
}
DbSession::DbSession ( const DbConnection connection) [explicit]

Definition at line 103 of file DbSession.cc.

                                                        :
  m_implementation( new SessionImpl ( connection ) ){
}
DbSession::DbSession ( const DbSession rhs)

Definition at line 107 of file DbSession.cc.

                                              :
  m_implementation( rhs.m_implementation ){ 
}
DbSession::~DbSession ( ) [virtual]

Definition at line 111 of file DbSession.cc.

                         {
}

Member Function Documentation

const std::string & DbSession::blobStreamingService ( ) const

Definition at line 148 of file DbSession.cc.

{
  return m_implementation->blobStreamingService;
}
void DbSession::close ( void  )
cond::DbConnection const & DbSession::connection ( ) const

Definition at line 139 of file DbSession.cc.

                                                         {
  return *(m_implementation->connection);
}
const std::string & DbSession::connectionString ( ) const

Definition at line 133 of file DbSession.cc.

Referenced by cond::IOVEditor::debugInfo().

                                                       {
  if(!m_implementation->database.get())
    throw cond::Exception("DbSession::connectionString: cannot get connection string. Session has not been open.");
  return m_implementation->database->connectionString();
}
bool DbSession::deleteMapping ( const std::string &  mappingVersion)

Definition at line 180 of file DbSession.cc.

References ora::DatabaseUtility::eraseMapping().

                                                                  {
  ora::DatabaseUtility utility = storage().utility();
  utility.eraseMapping( mappingVersion );
  return true;
}
bool DbSession::deleteObject ( const std::string &  objectId)

Definition at line 207 of file DbSession.cc.

References cont, ora::Container::erase(), ora::Container::flush(), and cond::parseToken().

Referenced by cond::IOVEditor::deleteEntries(), and cond::IOVEditor::truncate().

                                                           {
  std::pair<std::string,int> oidData = parseToken( objectId );
  ora::Container cont = storage().containerHandle(  oidData.first );
  cont.erase( oidData.second );
  cont.flush();
  return true;
}
void DbSession::flush ( )

Definition at line 223 of file DbSession.cc.

                         {
  storage().flush();
}
ora::Object DbSession::getObject ( const std::string &  objectId)

Definition at line 201 of file DbSession.cc.

References cont, ora::Container::fetchItem(), and cond::parseToken().

Referenced by importObject(), and cond::PayLoadInspector< DataT >::load().

                                                              {
  std::pair<std::string,int> oidData = parseToken( objectId );
  ora::Container cont = storage().containerHandle(  oidData.first );
  return cont.fetchItem( oidData.second );
}
template<typename T >
boost::shared_ptr< T > DbSession::getTypedObject ( const std::string &  objectId) [inline]
bool DbSession::importMapping ( const std::string &  sourceConnectionString,
const std::string &  contName 
)

Definition at line 186 of file DbSession.cc.

References cond::buildTechnologyProxy(), and ora::DatabaseUtility::importContainerSchema().

                                                                { 
  ora::DatabaseUtility utility = storage().utility();
  std::auto_ptr<cond::TechnologyProxy> technologyProxy = buildTechnologyProxy(sourceConnectionString, *(m_implementation->connection));
  utility.importContainerSchema( (*technologyProxy).getRealConnectString(), contName );
  return true;
}
std::string DbSession::importObject ( cond::DbSession fromDatabase,
const std::string &  objectId 
)

Definition at line 215 of file DbSession.cc.

References runTheMatrix::data, ora::Object::destruct(), getObject(), and cond::parseToken().

Referenced by cond::IOVService::exportIOVRangeWithPayload(), and cond::IOVService::exportIOVWithPayload().

                                                                                             {
  std::pair<std::string,int> oidData = parseToken( objectId );
  ora::Object data = fromDatabase.getObject( objectId );
  std::string tok = storeObject( data, oidData.first );
  data.destruct();
  return tok;
}
bool DbSession::isOpen ( ) const

Definition at line 129 of file DbSession.cc.

Referenced by popcon::PopConSourceHandler< T >::Ref::~Ref().

                                 {
  return m_implementation->isOpen;
}
bool DbSession::isTransactional ( ) const

Definition at line 144 of file DbSession.cc.

Referenced by CondDBESSource::CondDBESSource().

                                          {
  return m_implementation->technologyProxy->isTransactional();
}
coral::ISchema & DbSession::nominalSchema ( )
void DbSession::open ( const std::string &  connectionString,
bool  readOnly = false 
)
cond::DbSession & DbSession::operator= ( const DbSession rhs)

Definition at line 114 of file DbSession.cc.

References m_implementation.

                                                                 {
  if(this!=&rhs) m_implementation = rhs.m_implementation;
  return *this;
}
coral::ISchema & DbSession::schema ( const std::string &  schemaName)
ora::Database & DbSession::storage ( )

Definition at line 162 of file DbSession.cc.

Referenced by getTypedObject(), storeObject(), and updateObject().

                                   {
  if(!m_implementation->connection.get() || !m_implementation->connection->isOpen())
    throw cond::Exception("DbSession::storage: cannot access the storage. Underlying connection is closed.");
  if(!m_implementation->database.get())
    throw cond::Exception("DbSession::storage: cannot access the database. Session has not been open.");
  return *m_implementation->database;
}
template<typename T >
std::string DbSession::storeObject ( const T *  object,
const std::string &  containerName 
) [inline]
std::string DbSession::storeObject ( const ora::Object objectRef,
const std::string &  containerName 
) [private]

Definition at line 194 of file DbSession.cc.

References ora::OId::containerId(), ora::OId::itemId(), and cond::writeToken().

                                                                                              {
  ora::OId oid = storage().insertItem( containerName, object );
  storage().flush();
  int oid0 = oid.containerId(); // no clue why in POOL contId does not start from 0...
  return writeToken( containerName, oid0, oid.itemId(), object.typeName() );
}
cond::DbTransaction & DbSession::transaction ( )
template<typename T >
bool DbSession::updateObject ( const T *  object,
const std::string &  objectId 
) [inline]

Member Data Documentation

boost::shared_ptr<SessionImpl> cond::DbSession::m_implementation [private]

Definition at line 95 of file DbSession.h.

Referenced by operator=().