ATLAS Offline Software
CalibDbConnection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CALIBDBCONNECTION_H
6 #define CALIBDBCONNECTION_H
7 
8 // c - c++
9 #include "set"
10 #include "string"
11 
12 namespace coral {
13  class IRelationalDomain;
14  class ISessionProxy;
15  class Context;
16  class IQuery;
17  class ITableDataEditor;
18 } // namespace coral
19 
20 namespace MuonCalib {
21 
23  public:
24  //==================constructor - destructor====================================
25  CalibDbConnection(const std::string& ConnectionString, const std::string& WorkingSchema);
26  virtual ~CalibDbConnection();
27  //==================public member functions=====================================
28  // connection control
29  bool OpenConnection();
30  inline void SetLogin(const std::string& username, const std::string& password) {
31  m_username = username;
33  }
34  inline void GetLogin(std::string& username, std::string& password) const {
35  username = m_username;
37  }
38  inline const std::string& GetConnectionString() const { return m_connection_string; }
39  // set target user - the given login will be used as proxy
40  inline void SetTargetUser(const std::string& target_user) { m_target_user = target_user; }
41  // transaction control
42  void OpenTransaction();
43  void Commit();
44  void Rollback();
45  // get table editor - for insert and update ueries
46  coral::ITableDataEditor& GetTableEditor(const std::string& table_name);
47  // get query
48  coral::IQuery* GetQuery();
49  void DestroyQuery(coral::IQuery* query);
50  // get latest header id
51  private:
52  //==================private data members========================================
53  // connection strings
56  // pointer to the open query;
57  std::set<coral::IQuery*> m_queries;
58  // The application context
59  coral::Context* m_context;
60  // session proxy
61  coral::ISessionProxy* m_session;
62  // username
63  std::string m_username;
64  // password
65  std::string m_password;
66  // target user
67  std::string m_target_user;
68  // is true if transaction is open
70  //================private member functions=====================================
71  // Returns a reference to the domain object for a given connection
72  coral::IRelationalDomain& domain(const std::string& connectionString);
73  };
74 
75 } // namespace MuonCalib
76 
77 #endif
MuonCalib::CalibDbConnection::Commit
void Commit()
Definition: CalibDbConnection.cxx:109
MuonCalib::CalibDbConnection::Rollback
void Rollback()
Definition: CalibDbConnection.cxx:119
MuonCalib::CalibDbConnection::~CalibDbConnection
virtual ~CalibDbConnection()
Definition: CalibDbConnection.cxx:57
MuonCalib::CalibDbConnection::m_working_schema
std::string m_working_schema
Definition: CalibDbConnection.h:54
MuonCalib::CalibDbConnection::m_transaction
bool m_transaction
Definition: CalibDbConnection.h:69
MuonCalib::CalibDbConnection::m_username
std::string m_username
Definition: CalibDbConnection.h:63
MuonCalib::CalibDbConnection::domain
coral::IRelationalDomain & domain(const std::string &connectionString)
Definition: CalibDbConnection.cxx:158
MuonCalib::CalibDbConnection::SetTargetUser
void SetTargetUser(const std::string &target_user)
Definition: CalibDbConnection.h:40
MuonCalib::CalibDbConnection::SetLogin
void SetLogin(const std::string &username, const std::string &password)
Definition: CalibDbConnection.h:30
MuonCalib::CalibDbConnection::m_password
std::string m_password
Definition: CalibDbConnection.h:65
coral
Definition: ISecondaryEventSelector.h:19
query
Definition: query.py:1
MuonCalib::CalibDbConnection::DestroyQuery
void DestroyQuery(coral::IQuery *query)
Definition: CalibDbConnection.cxx:151
MuonCalib::CalibDbConnection::GetQuery
coral::IQuery * GetQuery()
Definition: CalibDbConnection.cxx:136
MuonCalib::CalibDbConnection::m_context
coral::Context * m_context
Definition: CalibDbConnection.h:59
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::CalibDbConnection::m_target_user
std::string m_target_user
Definition: CalibDbConnection.h:67
GetLBsToIgnore.password
password
Definition: GetLBsToIgnore.py:13
MuonCalib::CalibDbConnection::OpenTransaction
void OpenTransaction()
Definition: CalibDbConnection.cxx:99
MuonCalib::CalibDbConnection::CalibDbConnection
CalibDbConnection(const std::string &ConnectionString, const std::string &WorkingSchema)
Definition: CalibDbConnection.cxx:38
MuonCalib::CalibDbConnection::GetConnectionString
const std::string & GetConnectionString() const
Definition: CalibDbConnection.h:38
MuonCalib::CalibDbConnection::m_queries
std::set< coral::IQuery * > m_queries
Definition: CalibDbConnection.h:57
MuonCalib::CalibDbConnection::m_connection_string
std::string m_connection_string
Definition: CalibDbConnection.h:54
MuonCalib::CalibDbConnection::m_session
coral::ISessionProxy * m_session
Definition: CalibDbConnection.h:61
MuonCalib::CalibDbConnection::GetLogin
void GetLogin(std::string &username, std::string &password) const
Definition: CalibDbConnection.h:34
MuonCalib::CalibDbConnection::m_comp_loaded
bool m_comp_loaded
Definition: CalibDbConnection.h:55
MuonCalib::CalibDbConnection
Definition: CalibDbConnection.h:22
MuonCalib::CalibDbConnection::OpenConnection
bool OpenConnection()
Definition: CalibDbConnection.cxx:68
MuonCalib::CalibDbConnection::GetTableEditor
coral::ITableDataEditor & GetTableEditor(const std::string &table_name)
Definition: CalibDbConnection.cxx:129