BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DbInterface.h
Go to the documentation of this file.
1#ifndef DbInterface_h
2#define DbInterface_h
3
4#include <map>
5#include <string>
6#include <vector>
7
8#include "DatabaseSvc/DatabaseRecord.h"
9
11public:
13 virtual ~DbInterface();
14
15 // Connect to db
16 virtual int connect() = 0;
17 // Select database to be used
18 virtual int select_db( std::string dbname ) = 0;
19 // Query which returns data (SELECT, SHOW etc.)
20 virtual int query( std::string dbname, std::string query,
21 DatabaseRecordVector& records ) = 0;
22 // Query wich does not return data (INSERT, UPDATE etc.)
23 virtual int query( std::string dbname, std::string query ) = 0;
24 // Disconnect from db
25 virtual int disconnect() = 0;
26
27 bool is_connected() { return m_isConnected; }
28
29 void set_host( std::string host ) { m_dbHost = host; };
30 void set_user( std::string user ) { m_dbUser = user; };
31 void set_passwd( std::string passwd ) { m_dbPasswd = passwd; };
32 void set_dbpath( std::string path ) { m_dbPath = path; };
33 void set_port( int port ) { m_dbPort = port; };
35
36protected:
39
40 std::string m_dbName;
41
42 std::string m_dbHost;
44 std::string m_dbUser;
45 std::string m_dbPasswd;
46 std::string m_dbPath;
47};
48
49#endif
void set_dbpath(std::string path)
Definition DbInterface.h:32
virtual int select_db(std::string dbname)=0
void set_host(std::string host)
Definition DbInterface.h:29
bool is_connected()
Definition DbInterface.h:27
virtual ~DbInterface()
virtual int disconnect()=0
std::string m_dbUser
Definition DbInterface.h:44
std::string m_dbName
Definition DbInterface.h:40
virtual int query(std::string dbname, std::string query)=0
void set_passwd(std::string passwd)
Definition DbInterface.h:31
void set_port(int port)
Definition DbInterface.h:33
bool m_reuseConnection
Definition DbInterface.h:38
std::string m_dbPath
Definition DbInterface.h:46
bool m_isConnected
Definition DbInterface.h:37
virtual int query(std::string dbname, std::string query, DatabaseRecordVector &records)=0
void set_reuse_connection(bool flag)
Definition DbInterface.h:34
std::string m_dbPasswd
Definition DbInterface.h:45
virtual int connect()=0
void set_user(std::string user)
Definition DbInterface.h:30
std::string m_dbHost
Definition DbInterface.h:42