BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DatabaseSvc.h
Go to the documentation of this file.
1#ifndef DATABASESVC_H
2#define DATABASESVC_H
3
4#ifndef BEAN
5# include "DatabaseSvc/IDatabaseSvc.h"
6# include "GaudiKernel/Service.h"
7
8# include <mysql.h>
9
10class DbInterface;
11
12class DatabaseSvc : public extends<Service, IDatabaseSvc> {
13 // maqm protected:
14public:
15 // Constructor
16 DatabaseSvc( const std::string& name, ISvcLocator* sl );
17
18 // Destructor
20
21public:
22 // IInterface: query
23 // virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
24
25 // Service: initialize
26 virtual StatusCode initialize();
27
28 // Service: finalize
29 virtual StatusCode finalize();
30
31#else
32// -------------------------- BEAN ------------------------------------
33# include "DatabaseRecord.h"
34# include "DbInterface.h"
35
36class DatabaseSvc {
37public:
38 static DatabaseSvc* instance() { return ( m_db ) ? m_db : ( m_db = new DatabaseSvc() ); }
39
40private:
42 virtual ~DatabaseSvc();
43
44 bool initialize();
45 void finalize();
46
47public:
48 void SetDBFilePath( std::string dbFilePath );
49 std::string GetDBFilePath() const { return m_dbFilePath; }
50#endif
51
52 // make query
53 int query( const std::string& dbName, const std::string& sql );
54 int query( const std::string& dbName, const std::string& sql, DatabaseRecordVector& res );
55 std::string& serviceInUse() { return m_serviceInuse; }
56
57private:
58 DbInterface* dbInterface;
59 std::string m_dbName;
60
61 std::string m_dbHost;
62 int m_dbPort;
63 std::string m_dbUser;
64 std::string m_dbPasswd;
65 std::string m_dbFilePath;
66 std::string m_dbType;
67 bool m_dbReuseConnection;
68
69 std::string m_serviceInuse;
70
71#ifdef BEAN
72 static DatabaseSvc* m_db;
73#endif
74};
75
76#endif
int query(const std::string &dbName, const std::string &sql)
virtual StatusCode finalize()
DatabaseSvc(const std::string &name, ISvcLocator *sl)
virtual StatusCode initialize()
std::string & serviceInUse()
Definition DatabaseSvc.h:55