CMS 3D CMS Logo

Session.cc
Go to the documentation of this file.
2 #include "SessionImpl.h"
3 //
4 
5 namespace cond {
6 
7  namespace persistency {
8 
10  m_session( &session ){
11  }
12 
14  m_session( rhs.m_session ){
15  }
16 
18  m_session = rhs.m_session;
19  return *this;
20  }
21 
22  void Transaction::start( bool readOnly ){
23  m_session->startTransaction( readOnly );
24  }
25 
28  }
29 
32  }
33 
36  }
37 
39  m_session( new SessionImpl ),
40  m_transaction( *m_session ){
41  }
42 
43  Session::Session( const std::shared_ptr<SessionImpl>& sessionImpl ):
44  m_session( sessionImpl ),
46  }
47 
48  Session::Session( const Session& rhs ):
49  m_session( rhs.m_session ),
51  }
52 
54  }
55 
57  m_session = rhs.m_session;
59  return *this;
60  }
61 
63  m_session->close();
64  }
65 
67  return m_transaction;
68  }
69 
70  //
73  return m_session->transaction->iovDbExists;
74  }
75 
76  //
78  m_session->openDb();
79  }
80 
82  m_session->openIovDb();
83  IOVProxy proxy( m_session );
84  proxy.load( tag, full );
85  return proxy;
86  }
87 
89  const boost::posix_time::ptime& snapshottime,
90  bool full ){
91  m_session->openIovDb();
92  IOVProxy proxy( m_session );
93  proxy.load( tag, snapshottime, full );
94  return proxy;
95  }
96 
98  m_session->openIovDb();
99  return m_session->iovSchema().tagTable().select( tag );
100  }
101 
103  m_session->openIovDb();
104  IOVProxy proxy( m_session );
105  return proxy;
106  }
107 
109  cond::SynchronizationType synchronizationType ){
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  }
116 
118  const std::string& tag,
119  cond::TimeType timeType,
120  cond::SynchronizationType synchronizationType,
121  const boost::posix_time::ptime& creationTime ){
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  }
128 
130  cond::SynchronizationType synchronizationType ){
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  }
140 
142  m_session->openIovDb();
144  editor.load( tag );
145  return editor;
146  }
147 
149  m_session->openIovDb();
150  m_session->iovSchema().iovTable().erase( tag );
151  }
152 
154  m_session->openGTDb();
155  return m_session->gtSchema().gtTable().select( name );
156  }
157 
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");
162  GTEditor editor( m_session, name );
163  return editor;
164  }
165 
167  m_session->openGTDb();
169  editor.load( name );
170  return editor;
171  }
172 
174  m_session->openGTDb();
175  GTProxy proxy( m_session );
176  proxy.load( name );
177  return proxy;
178  }
179 
180  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name, preFix, postFix );
184  return proxy;
185  }
186 
188  const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
189  const boost::posix_time::ptime& creationTime ){
190  m_session->openDb();
191  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
192  payloadAndStreamerInfoData.second, creationTime );
193  }
194 
195  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
197  cond::Binary& payloadData,
198  cond::Binary& streamerInfoData ){
199  m_session->openIovDb();
200  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
201  }
202 
204  if(!m_session->transaction.get())
205  throwException( "The transaction is not active.","Session::getRunInfo" );
206  RunInfoProxy proxy( m_session );
207  proxy.load( start, end );
208  return proxy;
209  }
210 
213  editor.init();
214  return editor;
215  }
216 
218  return m_session->connectionString;
219  }
220 
221  coral::ISessionProxy& Session::coralSession(){
222  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
223  return *m_session->coralSession;
224  }
225 
226  coral::ISchema& Session::nominalSchema(){
227  return coralSession().nominalSchema();
228  }
229 
231  m_transaction(transaction),m_status(true){
233  }
234 
236  if(!m_status && m_transaction.isActive() ) {
238  }
239  }
240 
241  void TransactionScope::start( bool readOnly ){
242  m_transaction.start( readOnly );
243  m_status = false;
244  }
245 
248  m_status = true;
249  }
250 
252  m_status = true;
253  }
254 
255  }
256 }
Definition: start.py:1
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:166
Transaction(SessionImpl &session)
Definition: Session.cc:9
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:153
void clearIov(const std::string &tag)
Definition: Session.cc:148
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:132
void start(bool readOnly=true)
Definition: Session.cc:22
RunInfoEditor editRunInfo()
Definition: Session.cc:211
void load(Time_t low, Time_t up)
Definition: RunInfoProxy.cc:86
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:180
void load(const std::string &tag)
Definition: IOVEditor.cc:75
TransactionScope(Transaction &transaction)
Definition: Session.cc:230
Transaction & transaction()
Definition: Session.cc:66
TimeType
Definition: Time.h:21
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
unsigned long long Time_t
Definition: Time.h:16
Transaction & operator=(const Transaction &rhs)
Definition: Session.cc:17
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:130
coral::ISchema & nominalSchema()
Definition: Session.cc:226
Definition: GenABIO.cc:180
void start(bool readOnly=true)
Definition: Session.cc:241
std::string Hash
Definition: Types.h:45
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:195
#define end
Definition: vmac.h:37
std::string connectionString()
Definition: Session.cc:217
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:187
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:141
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:63
bool existsIov(const std::string &tag)
Definition: Session.cc:97
coral::ISessionProxy & coralSession()
Definition: Session.cc:221
Definition: plugin.cc:24
SynchronizationType
Definition: Types.h:29
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:100
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.cc:129
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:158
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:173
void load(const std::string &gtName)
Definition: GTEditor.cc:60
Transaction m_transaction
Definition: Session.h:177
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:176
RunInfoProxy getRunInfo(cond::Time_t start, cond::Time_t end)
Definition: Session.cc:203