BOSS 7.0.5
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 ,
  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 ,
  LEVELProd = 1 , LEVELDev = 2 , LEVELTest = 4 , LEVELSuperseded = 8
}
 Used to form bit masks for dbs queries. More...
 
enum  eRet {
  RETOk = 0 , RETBadCnfFile = 1 , RETBadHost = 2 , RETNoConnect = 3 ,
  RETWrongState = 4 , RETBadValue = 5 , RETMySQLError = 6 , RETNoSchemaMatch = 7 ,
  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 ,
  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 ()
 
 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

Member Enumeration Documentation

◆ eLevel [1/2]

◆ eLevel [2/2]

Used to form bit masks for dbs queries.

Enumerator
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 

Definition at line 26 of file InstallArea/include/ReadDBBase/ReadDBBase/ConnectionDBBase.h.

26 {
27 LEVELProd = 1,
28 LEVELDev = 2,
29 LEVELTest = 4,
31 };

◆ eRet [1/2]

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 15 of file Database/ReadDBBase/ReadDBBase-00-00-02/ReadDBBase/ConnectionDBBase.h.

◆ eRet [2/2]

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 15 of file InstallArea/include/ReadDBBase/ReadDBBase/ConnectionDBBase.h.

15 {
16 RETOk = 0,
17 RETBadCnfFile = 1,
18 RETBadHost = 2,
19 RETNoConnect = 3,
20 RETWrongState = 4,
21 RETBadValue = 5,
22 RETMySQLError = 6,
24 };

Constructor & Destructor Documentation

◆ ConnectionDBBase() [1/4]

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/4]

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() [1/2]

ConnectionDBBase::~ConnectionDBBase ( )

Definition at line 34 of file ConnectionDBBase.cxx.

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

◆ ConnectionDBBase() [3/4]

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

Constructor keeps track of table of interest.

◆ ConnectionDBBase() [4/4]

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

◆ ~ConnectionDBBase() [2/2]

ConnectionDBBase::~ConnectionDBBase ( )

Member Function Documentation

◆ connectRead() [1/2]

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 }

◆ connectRead() [2/2]

bool ConnectionDBBase::connectRead ( eRet err)

◆ disconnectRead() [1/2]

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().

◆ disconnectRead() [2/2]

void ConnectionDBBase::disconnectRead ( )

◆ disconnectWrite() [1/2]

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().

◆ disconnectWrite() [2/2]

void ConnectionDBBase::disconnectWrite ( )

◆ getRdb() [1/2]

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

Definition at line 51 of file Database/ReadDBBase/ReadDBBase-00-00-02/ReadDBBase/ConnectionDBBase.h.

51{return m_rdb;}

◆ getRdb() [2/2]

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

Definition at line 51 of file InstallArea/include/ReadDBBase/ReadDBBase/ConnectionDBBase.h.

51{return m_rdb;}

◆ getReadConnection() [1/2]

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

Definition at line 48 of file Database/ReadDBBase/ReadDBBase-00-00-02/ReadDBBase/ConnectionDBBase.h.

48{return m_readCxt;}

◆ getReadConnection() [2/2]

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

Definition at line 48 of file InstallArea/include/ReadDBBase/ReadDBBase/ConnectionDBBase.h.

48{return m_readCxt;}

◆ getTable() [1/2]

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

Definition at line 52 of file Database/ReadDBBase/ReadDBBase-00-00-02/ReadDBBase/ConnectionDBBase.h.

52{return m_table;}

◆ getTable() [2/2]

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

Definition at line 52 of file InstallArea/include/ReadDBBase/ReadDBBase/ConnectionDBBase.h.

52{return m_table;}

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