BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
ConnectionDBBase Class Reference

#include <ConnectionDBBase.h>

Public Types

enum  eRet {
  RETOk = 0 , RETBadCnfFile = 1 , RETBadHost = 2 , RETNoConnect = 3 ,
  RETWrongState = 4 , RETBadValue = 5 , RETMySQLError = 6 , RETNoSchemaMatch = 7
}
 
enum  eLevel { LEVELProd = 1 , LEVELDev = 2 , LEVELTest = 4 , LEVELSuperseded = 8 }
 Used to form bit masks for dbs queries. More...
 

Public Member Functions

 ConnectionDBBase (const std::string &host, const std::string &table, const std::string &dbName)
 Constructor keeps track of table of interest.
 
 ConnectionDBBase (const std::string &host, const std::string &dbName, const std::string &userName, const std::string &password)
 
 ~ConnectionDBBase ()
 
bool connectRead (eRet &err)
 
rdbModel::ConnectiongetReadConnection ()
 
rdbModel::RdbgetRdb ()
 
const std::string & getTable ()
 
void disconnectRead ()
 
void disconnectWrite ()
 

Detailed Description

Definition at line 13 of file ConnectionDBBase.h.

Member Enumeration Documentation

◆ eLevel

Used to form bit masks for dbs queries.

Enumerator
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 

Definition at line 26 of file ConnectionDBBase.h.

◆ eRet

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 15 of file ConnectionDBBase.h.

Constructor & Destructor Documentation

◆ ConnectionDBBase() [1/2]

ConnectionDBBase::ConnectionDBBase ( const std::string &  host,
const std::string &  table,
const std::string &  dbName 
)

Constructor keeps track of table of interest.

Definition at line 20 of file ConnectionDBBase.cxx.

21 : m_readCxt(0), m_writeCxt(0),
22 m_host(host), m_table(table), m_dbName(dbName), m_userName("maqm"), m_password("12345"), m_man(0), m_rdb(0),
23 m_match(false) {
24 // if (table.compare("*") == 0) m_table = std::string("$(MYSQL_METATABLE)");
25 // if (host.compare("*") == 0) m_host = std::string("$(MYSQL_HOST)");
26
27 }

◆ ConnectionDBBase() [2/2]

ConnectionDBBase::ConnectionDBBase ( const std::string &  host,
const std::string &  dbName,
const std::string &  userName,
const std::string &  password 
)

Definition at line 28 of file ConnectionDBBase.cxx.

29 : m_readCxt(0), m_writeCxt(0),
30 m_host(host), m_dbName(dbName), m_userName(userName), m_password(password),
31 m_man(0), m_rdb(0), m_match(false) {
32 }

◆ ~ConnectionDBBase()

ConnectionDBBase::~ConnectionDBBase ( )

Definition at line 34 of file ConnectionDBBase.cxx.

34 {
37 if (m_man) delete m_man;
38 }

Member Function Documentation

◆ connectRead()

bool ConnectionDBBase::connectRead ( eRet err)

Definition at line 60 of file ConnectionDBBase.cxx.

60 {
61 if (m_readCxt == 0) {
62 // for now use std::cout, std::cerr
63 m_readCxt = new rdbModel::MysqlConnection();
64 bool ok = connect(m_readCxt, m_host, m_userName,
65 m_password, err, m_dbName);
66 if (!ok) {
67 delete m_readCxt;
68 m_readCxt = 0;
69 } else {
70 }
71 return ok;
72 }
73 else return true;
74 }

◆ disconnectRead()

void ConnectionDBBase::disconnectRead ( )

Definition at line 96 of file ConnectionDBBase.cxx.

96 {
97 if (m_readCxt) {
98 m_readCxt->close();
99 delete m_readCxt;
100 m_readCxt = 0;
101 }
102 }
virtual bool close()=0

Referenced by ~ConnectionDBBase().

◆ disconnectWrite()

void ConnectionDBBase::disconnectWrite ( )

Definition at line 104 of file ConnectionDBBase.cxx.

104 {
105 if (m_writeCxt) {
106 m_writeCxt->close();
107 delete m_writeCxt;
108 m_writeCxt = 0;
109 }
110 }

Referenced by ~ConnectionDBBase().

◆ getRdb()

rdbModel::Rdb * ConnectionDBBase::getRdb ( )
inline

Definition at line 51 of file ConnectionDBBase.h.

51{return m_rdb;}

◆ getReadConnection()

rdbModel::Connection * ConnectionDBBase::getReadConnection ( )
inline

Definition at line 48 of file ConnectionDBBase.h.

48{return m_readCxt;}

◆ getTable()

const std::string & ConnectionDBBase::getTable ( )
inline

Definition at line 52 of file ConnectionDBBase.h.

52{return m_table;}

The documentation for this class was generated from the following files: