CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::Session Class Reference

#include <Session.h>

Public Member Functions

void clearIov (const std::string &tag)
 
void close ()
 
std::string connectionString ()
 
coral::ISessionProxy & coralSession ()
 
void createDatabase ()
 
GTEditor createGlobalTag (const std::string &name)
 
template<typename T >
IOVEditor createIov (const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType, const boost::posix_time::ptime &creationTime)
 
IOVEditor createIovForPayload (const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
GTEditor editGlobalTag (const std::string &name)
 
IOVEditor editIov (const std::string &tag)
 
bool existsDatabase ()
 
bool existsGlobalTag (const std::string &name)
 
bool existsIov (const std::string &tag)
 
template<typename T >
boost::shared_ptr< TfetchPayload (const cond::Hash &payloadHash)
 
bool fetchPayloadData (const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
 
IOVProxy iovProxy ()
 
coral::ISchema & nominalSchema ()
 
Sessionoperator= (const Session &rhs)
 
GTProxy readGlobalTag (const std::string &name)
 
GTProxy readGlobalTag (const std::string &name, const std::string &preFix, const std::string &postFix)
 
IOVProxy readIov (const std::string &tag, bool full=false)
 
IOVProxy readIov (const std::string &tag, const boost::posix_time::ptime &snapshottime, bool full=false)
 
 Session ()
 
 Session (const std::shared_ptr< SessionImpl > &sessionImpl)
 
 Session (const Session &rhs)
 
template<typename T >
cond::Hash storePayload (const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
 
Transactiontransaction ()
 
virtual ~Session ()
 

Private Member Functions

cond::Hash storePayloadData (const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
 

Private Attributes

std::shared_ptr< SessionImplm_session
 
Transaction m_transaction
 

Detailed Description

Definition at line 59 of file Session.h.

Constructor & Destructor Documentation

Session::Session ( )

Definition at line 38 of file Session.cc.

38  :
39  m_session( new SessionImpl ),
41  }
Transaction m_transaction
Definition: Session.h:170
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
Session::Session ( const std::shared_ptr< SessionImpl > &  sessionImpl)
explicit

Definition at line 43 of file Session.cc.

43  :
44  m_session( sessionImpl ),
46  }
Transaction m_transaction
Definition: Session.h:170
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
Session::Session ( const Session rhs)

Definition at line 48 of file Session.cc.

48  :
49  m_session( rhs.m_session ),
50  m_transaction( rhs.m_transaction ){
51  }
Transaction m_transaction
Definition: Session.h:170
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
Session::~Session ( )
virtual

Definition at line 53 of file Session.cc.

53  {
54  }

Member Function Documentation

void Session::clearIov ( const std::string &  tag)

Definition at line 148 of file Session.cc.

References m_session.

Referenced by cond::persistency::copyTag().

148  {
149  m_session->openIovDb();
150  m_session->iovSchema().iovTable().erase( tag );
151  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
void Session::close ( void  )
std::string Session::connectionString ( )

Definition at line 203 of file Session.cc.

References m_session.

Referenced by cond::persistency::copyTag(), PCLMetadataWriter::endRun(), cond::persistency::PayloadReader::fetch(), cond::persistency::importIovs(), and popcon::PopCon::initialize().

203  {
204  return m_session->connectionString;
205  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
coral::ISessionProxy & Session::coralSession ( )

Definition at line 207 of file Session.cc.

References m_session, and cond::persistency::throwException().

Referenced by l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryGenericKey(), l1t::OMDSReader::basicQueryView(), l1t::OMDSReader::columnNames(), l1t::OMDSReader::columnNamesView(), SiStripCoralIface::doNameQuery(), SiStripCoralIface::doQuery(), SiStripCoralIface::doSettingsQuery(), FillInfoPopConSourceHandler::getNewObjects(), L1CaloHcalScaleConfigOnlineProd::newObject(), and nominalSchema().

207  {
208  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
209  return *m_session->coralSession;
210  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
void Session::createDatabase ( )

Definition at line 77 of file Session.cc.

References m_session.

Referenced by cond::persistency::copyTag(), and cond::persistency::importIovs().

77  {
78  m_session->openDb();
79  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 158 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

158  {
159  m_session->openGTDb();
160  if( m_session->gtSchema().gtTable().select( name ) )
161  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
163  return editor;
164  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)
inline

Definition at line 173 of file Session.h.

References ora::ClassUtils::demangledName().

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), cond::persistency::copyIov(), cond::persistency::copyTag(), and cond::persistency::importIovs().

173  {
174  return createIov( cond::demangledName( typeid(T) ), tag, timeType, synchronizationType );
175  }
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:173
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:159
long double T
IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 108 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

109  {
110  m_session->openDb();
111  if( m_session->iovSchema().tagTable().select( tag ) )
112  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
113  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
114  return editor;
115  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 117 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

121  {
122  m_session->openDb();
123  if( m_session->iovSchema().tagTable().select( tag ) )
124  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
125  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
126  return editor;
127  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 129 of file Session.cc.

References idDealer::editor, m_session, HLT_25ns10e33_v2_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

130  {
131  m_session->openDb();
132  if( m_session->iovSchema().tagTable().select( tag ) )
133  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
135  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
136  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
137  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
138  return editor;
139  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 166 of file Session.cc.

References idDealer::editor, cond::persistency::GTEditor::load(), and m_session.

166  {
167  m_session->openGTDb();
169  editor.load( name );
170  return editor;
171  }
tuple editor
Definition: idDealer.py:73
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
IOVEditor Session::editIov ( const std::string &  tag)
bool Session::existsDatabase ( )

Definition at line 71 of file Session.cc.

References cond::persistency::SessionImpl::DO_NOT_THROW, and m_session.

Referenced by SiStripDetVOffHandler::analyze(), cond::persistency::copyTag(), and cond::persistency::importIovs().

71  {
73  return m_session->transaction->iovDbExists;
74  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 153 of file Session.cc.

References m_session.

153  {
154  m_session->openGTDb();
155  return m_session->gtSchema().gtTable().select( name );
156  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
bool Session::existsIov ( const std::string &  tag)

Definition at line 97 of file Session.cc.

References m_session.

Referenced by SiStripDetVOffHandler::analyze(), cond::persistency::copyIov(), cond::persistency::copyTag(), cond::persistency::importIovs(), and popcon::PopCon::initialize().

97  {
98  m_session->openIovDb();
99  return m_session->iovSchema().tagTable().select( tag );
100  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
template<typename T >
boost::shared_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 190 of file Session.h.

References alignCSCRings::e, fetchPayloadData(), HLT_25ns10e33_v2_cff::payloadType, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and cms::Exception::what().

Referenced by SiStripDetVOffHandler::analyze(), SiStripDetVOffTkMapPlotter::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), SiStripDetVOffTrendPlotter::analyze(), cond::persistency::PayloadReader::fetch(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), l1t::DataWriter::readObject(), and popcon::PopConSourceHandler< T >::Ref::Ref().

190  {
191  cond::Binary payloadData;
192  cond::Binary streamerInfoData;
194  if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
195  throwException( "Payload with id "+payloadHash+" has not been found in the database.",
196  "Session::fetchPayload" );
197  boost::shared_ptr<T> ret;
198  try{
199  ret = deserialize<T>( payloadType, payloadData, streamerInfoData );
200  } catch ( const cond::persistency::Exception& e ){
201  std::string em(e.what());
202  throwException( "Payload of type "+payloadType+" with id "+payloadHash+" could not be loaded. "+em,"Session::fetchPayload");
203  }
204  return ret;
205  }
virtual char const * what() const
Definition: Exception.cc:141
tuple ret
prodAgent to be discontinued
Base exception class for the object to relational access.
Definition: Exception.h:11
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:195
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
bool Session::fetchPayloadData ( const cond::Hash payloadHash,
std::string &  payloadType,
cond::Binary payloadData,
cond::Binary streamerInfoData 
)

Definition at line 195 of file Session.cc.

References m_session.

Referenced by cond::persistency::fetch(), cond::persistency::fetchIfExists(), fetchPayload(), and cond::persistency::KeyList::load().

198  {
199  m_session->openIovDb();
200  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
201  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
IOVProxy Session::iovProxy ( )

Definition at line 102 of file Session.cc.

References m_session.

102  {
103  m_session->openIovDb();
104  IOVProxy proxy( m_session );
105  return proxy;
106  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
coral::ISchema & Session::nominalSchema ( )
Session & Session::operator= ( const Session rhs)

Definition at line 56 of file Session.cc.

References m_session, and m_transaction.

56  {
57  m_session = rhs.m_session;
58  m_transaction = rhs.m_transaction;
59  return *this;
60  }
Transaction m_transaction
Definition: Session.h:170
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 173 of file Session.cc.

References cond::persistency::GTProxy::load(), and m_session.

Referenced by CondDBESSource::fillTagCollectionFromGT().

173  {
174  m_session->openGTDb();
175  GTProxy proxy( m_session );
176  proxy.load( name );
177  return proxy;
178  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 180 of file Session.cc.

References cond::persistency::GTProxy::load(), and m_session.

180  {
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name, preFix, postFix );
184  return proxy;
185  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
IOVProxy Session::readIov ( const std::string &  tag,
bool  full = false 
)
IOVProxy Session::readIov ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime,
bool  full = false 
)

Definition at line 88 of file Session.cc.

References cond::persistency::IOVProxy::load(), and m_session.

90  {
91  m_session->openIovDb();
92  IOVProxy proxy( m_session );
93  proxy.load( tag, snapshottime, full );
94  return proxy;
95  }
Definition: GenABIO.cc:180
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
template<typename T >
cond::Hash Session::storePayload ( const T payload,
const boost::posix_time::ptime &  creationTime = boost::posix_time::microsec_clock::universal_time() 
)
inline

Definition at line 177 of file Session.h.

References ora::ClassUtils::demangledName(), alignCSCRings::e, runTheMatrix::ret, cond::serialize(), storePayloadData(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and cms::Exception::what().

Referenced by SiStripDetVOffHandler::analyze(), SiStripPayloadHandler< SiStripPayload >::analyze(), cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::createNewIOV(), l1t::WriterProxyT< Record, Type >::save(), l1t::DataWriter::writeKeyList(), and cond::service::PoolDBOutputService::writeOne().

177  {
178 
179  std::string payloadObjectType = cond::demangledName(typeid(payload));
180  cond::Hash ret;
181  try{
182  ret = storePayloadData( payloadObjectType, serialize( payload ), creationTime );
183  } catch ( const cond::persistency::Exception& e ){
184  std::string em(e.what());
185  throwException( "Payload of type "+payloadObjectType+" could not be stored. "+em,"Session::storePayload");
186  }
187  return ret;
188  }
virtual char const * what() const
Definition: Exception.cc:141
tuple ret
prodAgent to be discontinued
Base exception class for the object to relational access.
Definition: Exception.h:11
std::pair< Binary, Binary > serialize(const T &payload)
Definition: Serialization.h:54
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:159
std::string Hash
Definition: Types.h:45
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:187
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
cond::Hash Session::storePayloadData ( const std::string &  payloadObjectType,
const std::pair< Binary, Binary > &  payloadAndStreamerInfoData,
const boost::posix_time::ptime &  creationTime 
)
private

Definition at line 187 of file Session.cc.

References m_session.

Referenced by storePayload().

189  {
190  m_session->openDb();
191  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
192  payloadAndStreamerInfoData.second, creationTime );
193  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169
Transaction & Session::transaction ( )

Member Data Documentation

std::shared_ptr<SessionImpl> cond::persistency::Session::m_session
private
Transaction cond::persistency::Session::m_transaction
private

Definition at line 170 of file Session.h.

Referenced by operator=(), and transaction().