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,
107 std::vector<std::tuple<cond::Time_t,cond::Hash> >& range );
112 template <
typename T>
125 const boost::posix_time::ptime& creationTime );
139 const boost::posix_time::ptime& creationTime = boost::posix_time::microsec_clock::universal_time() );
141 template <
typename T> std::shared_ptr<T> fetchPayload(
const cond::Hash& payloadHash );
144 const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
145 const boost::posix_time::ptime& creationTime );
147 bool fetchPayloadData(
const cond::Hash& payloadHash,
175 coral::ISessionProxy& coralSession();
177 coral::ISchema& nominalSchema();
186 return createIov( cond::demangledName(
typeid(
T) ), tag, timeType, synchronizationType );
189 template <
typename T>
inline cond::Hash Session::storePayload(
const T&
payload,
const boost::posix_time::ptime& creationTime ){
191 std::string payloadObjectType = cond::demangledName(
typeid(payload));
194 ret = storePayloadData( payloadObjectType,
serialize( payload ), creationTime );
197 throwException(
"Payload of type "+payloadObjectType+
" could not be stored. "+em,
"Session::storePayload");
207 ret = storePayloadData( payloadObjectType,
serialize( payload ), creationTime );
210 throwException(
"Payload of type "+payloadObjectType+
" could not be stored. "+em,
"Session::storePayload");
215 template <
typename T>
inline std::shared_ptr<T> Session::fetchPayload(
const cond::Hash& payloadHash ){
219 if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
220 throwException(
"Payload with id "+payloadHash+
" has not been found in the database.",
221 "Session::fetchPayload" );
222 std::shared_ptr<T> ret;
224 ret = deserialize<T>(
payloadType, payloadData, streamerInfoData );
227 throwException(
"Payload of type "+payloadType+
" with id "+payloadHash+
" could not be loaded. "+em,
"Session::fetchPayload");
238 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
payload
payload postfix for testing
unsigned long long Time_t
Transaction m_transaction
void throwException(const std::string &message, const std::string &methodName)
std::shared_ptr< SessionImpl > m_session