ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DbConnection Class Reference
Collaboration diagram for DbConnection:

Public Member Functions

 DbConnection (const std::string &sourceDb)
 
 ~DbConnection ()
 
bool isOpen () const
 
cool::IDatabasePtr dbPtr () const
 
 DbConnection (const std::string &sourceDb, const bool isCoraCool=false)
 
 ~DbConnection ()
 
bool isOpen () const
 
cool::IDatabasePtr dbPtr () const
 
CoraCoolDatabasePtr coraCoolPtr () const
 

Private Attributes

coral::ConnectionService m_coralsvc {}
 
cool::Application m_coolapp
 
const cool::IDatabaseSvc & m_dbSvc
 
cool::IDatabasePtr m_sourceDbPtr {}
 
bool m_isOpen {}
 
CoraCoolDatabasePtr m_sourceCoraPtr
 

Detailed Description

Definition at line 41 of file MakeReferenceFile.cxx.

Constructor & Destructor Documentation

◆ DbConnection() [1/2]

DbConnection::DbConnection ( const std::string &  sourceDb)

Definition at line 58 of file MakeReferenceFile.cxx.

59  m_dbSvc(m_coolapp.databaseService())
60 {
61  bool readOnly(true);
62  const std::string dbConnectionString{sourceDb};
63  try
64  {
65  m_sourceDbPtr = m_dbSvc.openDatabase(dbConnectionString, readOnly);
66  }
67  catch (std::exception &e)
68  {
69  std::cout << "Cool exception caught: " << e.what() << std::endl;
70  if (not readOnly)
71  {
72  try
73  {
74  std::cout << "creating " << dbConnectionString << std::endl;
75  m_sourceDbPtr = m_dbSvc.createDatabase(dbConnectionString);
76  }
77  catch (std::exception &e)
78  {
79  std::cout << "Cool exception caught: " << e.what() << std::endl;
80  }
81  }
82  }
83  m_isOpen = (m_sourceDbPtr != nullptr);
84 }

◆ ~DbConnection() [1/2]

DbConnection::~DbConnection ( )

Definition at line 87 of file MakeReferenceFile.cxx.

88 {
89  if (isOpen())
90  {
91  m_sourceDbPtr->closeDatabase();
92  }
93 }

◆ DbConnection() [2/2]

DbConnection::DbConnection ( const std::string &  sourceDb,
const bool  isCoraCool = false 
)

Definition at line 356 of file openCoraCool.cxx.

356  :
357  m_coralsvc{},
359  m_dbSvc(m_coolapp.databaseService()),
360  m_sourceDbPtr(nullptr),
361  m_sourceCoraPtr(nullptr),
362  m_isOpen(false){
363  bool readOnly(true);
364  const std::string dbConnectionString=transConn(sourceDb);
365  readOnly= (dbConnectionString.find ("sqlite")==std::string::npos);
366  try {
367  m_sourceDbPtr=m_dbSvc.openDatabase(dbConnectionString,readOnly);
368  if (isCoraCool) m_sourceCoraPtr=CoraCoolDatabasePtr(new CoraCoolDatabase(sourceDb,
369  m_sourceDbPtr,m_coralsvc,readOnly));
370  }
371  catch (std::exception& e) {
372  std::cout << "Cool exception caught: " << e.what() << std::endl;
373  if (not readOnly){
374  try {
375  std::cout<<"creating "<<dbConnectionString<<std::endl;
376  m_sourceDbPtr=m_dbSvc.createDatabase(dbConnectionString);
377  } catch (std::exception& e){
378  std::cout << "Cool exception caught: " << e.what() << std::endl;
379  }
380  }
381  }
382  m_isOpen=(m_sourceDbPtr!=nullptr);
383 }

◆ ~DbConnection() [2/2]

DbConnection::~DbConnection ( )

Member Function Documentation

◆ coraCoolPtr()

CoraCoolDatabasePtr DbConnection::coraCoolPtr ( ) const

Definition at line 400 of file openCoraCool.cxx.

400  {
401  return m_sourceCoraPtr;
402 }

◆ dbPtr() [1/2]

cool::IDatabasePtr DbConnection::dbPtr ( ) const

Definition at line 97 of file MakeReferenceFile.cxx.

98 {
99  return m_sourceDbPtr;
100 }

◆ dbPtr() [2/2]

cool::IDatabasePtr DbConnection::dbPtr ( ) const

◆ isOpen() [1/2]

bool DbConnection::isOpen ( ) const

Definition at line 102 of file MakeReferenceFile.cxx.

103 {
104  return m_isOpen;
105 }

◆ isOpen() [2/2]

bool DbConnection::isOpen ( ) const

Member Data Documentation

◆ m_coolapp

cool::Application DbConnection::m_coolapp
private

Definition at line 51 of file MakeReferenceFile.cxx.

◆ m_coralsvc

coral::ConnectionService DbConnection::m_coralsvc {}
private

Definition at line 50 of file MakeReferenceFile.cxx.

◆ m_dbSvc

const cool::IDatabaseSvc & DbConnection::m_dbSvc
private

Definition at line 52 of file MakeReferenceFile.cxx.

◆ m_isOpen

bool DbConnection::m_isOpen {}
private

Definition at line 54 of file MakeReferenceFile.cxx.

◆ m_sourceCoraPtr

CoraCoolDatabasePtr DbConnection::m_sourceCoraPtr
private

Definition at line 345 of file openCoraCool.cxx.

◆ m_sourceDbPtr

cool::IDatabasePtr DbConnection::m_sourceDbPtr {}
private

Definition at line 53 of file MakeReferenceFile.cxx.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CoraCoolDatabase
Definition: CoraCoolDatabase.h:24
DbConnection::m_dbSvc
const cool::IDatabaseSvc & m_dbSvc
Definition: MakeReferenceFile.cxx:52
transConn
std::string transConn(const std::string &inconn)
Definition: openCoraCool.cxx:323
DbConnection::m_isOpen
bool m_isOpen
Definition: MakeReferenceFile.cxx:54
DbConnection::m_sourceDbPtr
cool::IDatabasePtr m_sourceDbPtr
Definition: MakeReferenceFile.cxx:53
DbConnection::isOpen
bool isOpen() const
Definition: MakeReferenceFile.cxx:102
calibdata.exception
exception
Definition: calibdata.py:496
CoraCoolDatabasePtr
boost::shared_ptr< CoraCoolDatabase > CoraCoolDatabasePtr
Definition: CoraCoolTypes.h:12
DbConnection::m_coralsvc
coral::ConnectionService m_coralsvc
Definition: MakeReferenceFile.cxx:50
DbConnection::m_coolapp
cool::Application m_coolapp
Definition: MakeReferenceFile.cxx:51
DbConnection::m_sourceCoraPtr
CoraCoolDatabasePtr m_sourceCoraPtr
Definition: openCoraCool.cxx:345