CGEM BOSS 6.6.5.i
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 "GaudiKernel/Service.h"
7
8#include <mysql.h>
9
10class DbInterface;
11
12template <class TYPE> class SvcFactory;
13
14class DatabaseSvc : virtual public IDatabaseSvc,
15 virtual public Service
16{
17
18 // Allow SvcFactory to instantiate the service.
19 friend class SvcFactory<DatabaseSvc>;
20
21 //maqm protected:
22 public:
23 // Constructor
24 DatabaseSvc( const std::string& name, ISvcLocator* sl );
25
26 // Destructor
27 virtual ~DatabaseSvc();
28
29 public:
30
31 // IInterface: query
32 virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
33
34 // Service: initialize
35 virtual StatusCode initialize();
36
37 // Service: finalize
38 virtual StatusCode finalize();
39
40#else
41// -------------------------- BEAN ------------------------------------
44
45class DatabaseSvc
46{
47 public:
48 static DatabaseSvc* instance() {
49 return (m_db) ? m_db : (m_db = new DatabaseSvc());
50 }
51
52 private:
54 virtual ~DatabaseSvc();
55
56 bool initialize();
57 void finalize();
58
59 public:
60 void SetDBFilePath(std::string dbFilePath);
61 std::string GetDBFilePath() const {return m_dbFilePath;}
62#endif
63
64 // make query
65 int query(const std::string& dbName, const std::string& sql);
66 int query(const std::string& dbName, const std::string& sql,
68
69 private:
70
71 DbInterface * dbInterface;
72 std::string m_dbName;
73
74 std::string m_dbHost;
75 std::string m_dbUser;
76 std::string m_dbPasswd;
77 std::string m_dbFilePath;
78 std::string m_dbType;
79 bool m_dbReuseConnection;
80
81#ifdef BEAN
82 static DatabaseSvc* m_db;
83#endif
84};
85
86#endif
int query(const std::string &dbName, const std::string &sql)
virtual StatusCode finalize()
DatabaseSvc(const std::string &name, ISvcLocator *sl)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual StatusCode initialize()
virtual ~DatabaseSvc()
Forward and external declarations.