1 #ifndef CondCore_CondDB_Session_h 2 #define CondCore_CondDB_Session_h 39 namespace persistency {
41 class SessionConfiguration;
50 void start(
bool readOnly=
true );
68 explicit Session(
const std::shared_ptr<SessionImpl>& sessionImpl );
86 bool existsDatabase();
89 void createDatabase();
98 const boost::posix_time::ptime& snapshottime,
110 std::vector<std::tuple<cond::Time_t,cond::Hash> >& range );
115 template <
typename T>
128 const boost::posix_time::ptime& creationTime );
142 const boost::posix_time::ptime& creationTime = boost::posix_time::microsec_clock::universal_time() );
144 template <
typename T> std::unique_ptr<T> fetchPayload(
const cond::Hash& payloadHash );
147 const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
148 const boost::posix_time::ptime& creationTime );
150 bool fetchPayloadData(
const cond::Hash& payloadHash,
178 coral::ISessionProxy& coralSession();
180 coral::ISchema& nominalSchema();
189 return createIov( cond::demangledName(
typeid(
T) ), tag, timeType, synchronizationType );
192 template <
typename T>
inline cond::Hash Session::storePayload(
const T&
payload,
const boost::posix_time::ptime& creationTime ){
194 std::string payloadObjectType = cond::demangledName(
typeid(payload));
197 ret = storePayloadData( payloadObjectType,
serialize( payload ), creationTime );
200 throwException(
"Payload of type "+payloadObjectType+
" could not be stored. "+em,
"Session::storePayload");
210 ret = storePayloadData( payloadObjectType,
serialize( payload ), creationTime );
213 throwException(
"Payload of type "+payloadObjectType+
" could not be stored. "+em,
"Session::storePayload");
218 template <
typename T>
inline std::unique_ptr<T> Session::fetchPayload(
const cond::Hash& payloadHash ){
222 if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
223 throwException(
"Payload with id "+payloadHash+
" has not been found in the database.",
224 "Session::fetchPayload" );
225 std::unique_ptr<T> ret;
227 ret = deserialize<T>( payloadType, payloadData, streamerInfoData );
230 throwException(
"Payload of type "+payloadType+
" with id "+payloadHash+
" could not be loaded. "+em,
"Session::fetchPayload");
241 void start(
bool readOnly=
true );
Base exception class for the object to relational access.
std::pair< Binary, Binary > serialize(const T &payload)
Transaction & m_transaction
char const * what() const override
unsigned long long Time_t
Transaction m_transaction
void throwException(const std::string &message, const std::string &methodName)
std::shared_ptr< SessionImpl > m_session