BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/DatabaseSvc/DatabaseSvc/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"
6#include "DatabaseSvc/IDatabaseSvc.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 ------------------------------------
42#include "DatabaseSvc/DatabaseRecord.h"
43#include "DatabaseSvc/DbInterface.h"
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 int m_dbPort;
76 std::string m_dbUser;
77 std::string m_dbPasswd;
78 std::string m_dbFilePath;
79 std::string m_dbType;
80 bool m_dbReuseConnection;
81
82#ifdef BEAN
83 static DatabaseSvc* m_db;
84#endif
85};
86
87#endif
int query(const std::string &dbName, const std::string &sql)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
virtual StatusCode initialize()
virtual StatusCode finalize()
DatabaseSvc(const std::string &name, ISvcLocator *sl)
virtual StatusCode finalize()
int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)
virtual StatusCode initialize()
Definition: DatabaseSvc.cxx:67
virtual ~DatabaseSvc()
Definition: DatabaseSvc.cxx:45
virtual ~DatabaseSvc()