ATLAS Offline Software
CoraCoolDatabaseSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // CoraCoolDatabaseSvc.cxx
6 // implementation for CoraCoolDatabaseSvc
7 // Richard Hawkings, started 27/10/06
8 
12 #include "CoolKernel/IDatabaseSvc.h"
13 #include "RelationalAccess/IConnectionService.h"
14 
15 CoraCoolDatabaseSvc::CoraCoolDatabaseSvc(coral::IConnectionService& coralsvc,
16  cool::IDatabaseSvc& cooldb)
17  :
18  m_coralsvc(coralsvc), m_cooldb(cooldb) {}
19 
21  return m_cooldb; }
22 
24  const std::string& dbconn,cool::IDatabasePtr cooldb, bool readonly) {
26  cooldb,m_coralsvc,readonly));
27  return dbase;
28 }
29 
31  const std::string& dbconn,bool readonly) {
32  cool::IDatabasePtr cooldb;
33  try {
34  cooldb=m_cooldb.openDatabase(dbconn,readonly);
35  }
36  catch (cool::Exception& e) {
37  // try to create database - assuming it did not exist before
38  try {
39  if (readonly) throw std::exception();
40  cooldb=m_cooldb.createDatabase(dbconn);
41  }
42  catch (std::exception& e) {
43  throw CoraCoolException("Cannot connect to or create COOL database",
44  "CoraCoolDatabaseSvc::openDatabase");
45  }
46  }
47  CoraCoolDatabasePtr dbase(new CoraCoolDatabase(dbconn,cooldb,m_coralsvc,readonly));
48  return dbase;
49 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CoraCoolDatabaseSvc::m_coralsvc
coral::IConnectionService & m_coralsvc
Definition: CoraCoolDatabaseSvc.h:41
CoraCoolDatabase
Definition: CoraCoolDatabase.h:24
CoraCoolDatabaseSvc.h
CoraCoolDatabaseSvc::coolIDatabaseSvc
cool::IDatabaseSvc & coolIDatabaseSvc()
Definition: CoraCoolDatabaseSvc.cxx:20
calibdata.exception
exception
Definition: calibdata.py:496
CoraCoolDatabasePtr
boost::shared_ptr< CoraCoolDatabase > CoraCoolDatabasePtr
Definition: CoraCoolTypes.h:12
dumpBeamSpot.dbconn
dbconn
Definition: dumpBeamSpot.py:27
CoraCoolDatabaseSvc::m_cooldb
cool::IDatabaseSvc & m_cooldb
Definition: CoraCoolDatabaseSvc.h:42
CoraCoolDatabaseSvc::openDatabase
CoraCoolDatabasePtr openDatabase(const std::string &dbconn, cool::IDatabasePtr cooldb, bool readonly=false)
Definition: CoraCoolDatabaseSvc.cxx:23
CoraCoolException
Definition: CoraCoolException.h:13
CoraCoolDatabaseSvc::CoraCoolDatabaseSvc
CoraCoolDatabaseSvc(coral::IConnectionService &coralsvc, cool::IDatabaseSvc &cooldb)
Definition: CoraCoolDatabaseSvc.cxx:15
CoraCoolDatabase.h
CoraCoolException.h