BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Database/ReadDBBase/include/ReadDBBase/ConnectionDBBase.h
Go to the documentation of this file.
1#ifndef REALDBUTIL_CONNECTIONBASE_H
2#define REALDBUTIL_CONNECTIONBASE_H
3
4#include "rdbModel/Db/Connection.h"
5#include "rdbModel/Tables/Assertion.h"
6
7namespace rdbModel {
8 class Rdb;
9 class Manager;
10} // namespace rdbModel
11
12// namespace RealDBUtil {
14public:
25 /// Used to form bit masks for dbs queries
26 enum eLevel { LEVELProd = 1, LEVELDev = 2, LEVELTest = 4, LEVELSuperseded = 8 };
27
28 /* Someday provide option of reading in description of table. In case
29 it is used, can check that it matches dbs we're connected to, and
30 can check column values.
31 */
32
33 /// Constructor keeps track of table of interest
34 ConnectionDBBase( const std::string& host, const std::string& table,
35 const std::string& dbName );
36
37 ConnectionDBBase( const std::string& host, const std::string& dbName,
38 const std::string& userName, const std::string& password );
39
41
42 bool connectRead( eRet& err );
43
44 rdbModel::Connection* getReadConnection() { return m_readCxt; }
45
46 // Should probably be const
47 rdbModel::Rdb* getRdb() { return m_rdb; }
48 const std::string& getTable() { return m_table; }
49
50 // Might make these private
51 void disconnectRead();
52 void disconnectWrite();
53
54private:
55 rdbModel::Connection* m_readCxt;
56 rdbModel::Connection* m_writeCxt;
57
58 // these could be static
59 rdbModel::Assertion* m_findBest;
60 rdbModel::Assertion* m_findSoonest;
61
62 // static bool connect(rdbModel::MysqlConnection* conn,
63 static bool connect( rdbModel::Connection* conn, std::string& host, const std::string& user,
64 const std::string& pw, eRet& err, const std::string& dbName );
65
66 bool connectWrite( eRet& err );
67
68 std::string m_host;
69 std::string m_table;
70 std::string m_dbName;
71 std::string m_userName;
72 std::string m_password;
73
74 rdbModel::Manager* m_man;
75 rdbModel::Rdb* m_rdb;
76 bool m_match; // true if succeeded. If not attempted, m_rdb is 0
77};
78//}
79#endif
bool connectRead(eRet &err)
ConnectionDBBase(const std::string &host, const std::string &table, const std::string &dbName)
Constructor keeps track of table of interest.
eLevel
Used to form bit masks for dbs queries.