#include <ConnectionDBBase.h>
Definition at line 13 of file ConnectionDBBase.h.
Used to form bit masks for dbs queries.
Definition at line 26 of file ConnectionDBBase.h.
00026 { 00027 LEVELProd = 1, 00028 LEVELDev = 2, 00029 LEVELTest = 4, 00030 LEVELSuperseded = 8 00031 };
RETOk | |
RETBadCnfFile | |
RETBadHost | |
RETNoConnect | |
RETWrongState | |
RETBadValue | |
RETMySQLError | |
RETNoSchemaMatch |
Definition at line 15 of file ConnectionDBBase.h.
00015 { 00016 RETOk = 0, 00017 RETBadCnfFile = 1, 00018 RETBadHost = 2, 00019 RETNoConnect = 3, 00020 RETWrongState = 4, 00021 RETBadValue = 5, 00022 RETMySQLError = 6, 00023 RETNoSchemaMatch = 7 00024 };
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.
00021 : m_readCxt(0), m_writeCxt(0), 00022 m_host(host), m_table(table), m_dbName(dbName), m_userName("maqm"), m_password("12345"), m_man(0), m_rdb(0), 00023 m_match(false) { 00024 // if (table.compare("*") == 0) m_table = std::string("$(MYSQL_METATABLE)"); 00025 // if (host.compare("*") == 0) m_host = std::string("$(MYSQL_HOST)"); 00026 00027 }
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.
00029 : m_readCxt(0), m_writeCxt(0), 00030 m_host(host), m_dbName(dbName), m_userName(userName), m_password(password), 00031 m_man(0), m_rdb(0), m_match(false) { 00032 }
ConnectionDBBase::~ConnectionDBBase | ( | ) |
Definition at line 34 of file ConnectionDBBase.cxx.
References disconnectRead(), disconnectWrite(), and m_man.
00034 { 00035 disconnectRead(); 00036 disconnectWrite(); 00037 if (m_man) delete m_man; 00038 }
bool ConnectionDBBase::connect | ( | rdbModel::Connection * | conn, | |
std::string & | host, | |||
const std::string & | user, | |||
const std::string & | pw, | |||
eRet & | err, | |||
const std::string & | dbName | |||
) | [static, private] |
Definition at line 43 of file ConnectionDBBase.cxx.
References rdbModel::Connection::open(), RETNoConnect, and RETOk.
Referenced by connectRead(), and connectWrite().
00046 { 00047 00048 00049 bool connected = cxt->open(host, user, pw, dbName); 00050 if (connected) { 00051 err = RETOk; 00052 return true; 00053 } 00054 else { 00055 err = RETNoConnect; 00056 return false; 00057 } 00058 }
Definition at line 60 of file ConnectionDBBase.cxx.
References connect(), m_dbName, m_host, m_password, m_readCxt, and m_userName.
00060 { 00061 if (m_readCxt == 0) { 00062 // for now use std::cout, std::cerr 00063 m_readCxt = new rdbModel::MysqlConnection(); 00064 bool ok = connect(m_readCxt, m_host, m_userName, 00065 m_password, err, m_dbName); 00066 if (!ok) { 00067 delete m_readCxt; 00068 m_readCxt = 0; 00069 } else { 00070 } 00071 return ok; 00072 } 00073 else return true; 00074 }
Definition at line 76 of file ConnectionDBBase.cxx.
References connect(), m_dbName, m_host, m_password, m_readCxt, m_userName, and m_writeCxt.
00076 { 00077 if (m_writeCxt == 0) { 00078 m_writeCxt = new rdbModel::MysqlConnection(); 00079 bool ok; 00080 00081 ok = connect(m_writeCxt, m_host, m_userName, 00082 m_password, err, m_dbName); 00083 00084 if (!ok) { 00085 delete m_readCxt; 00086 m_readCxt = 0; 00087 } else { 00088 00089 } 00090 00091 return ok; 00092 } 00093 else return true; 00094 }
void ConnectionDBBase::disconnectRead | ( | ) |
Definition at line 96 of file ConnectionDBBase.cxx.
References rdbModel::Connection::close(), and m_readCxt.
Referenced by ~ConnectionDBBase().
00096 { 00097 if (m_readCxt) { 00098 m_readCxt->close(); 00099 delete m_readCxt; 00100 m_readCxt = 0; 00101 } 00102 }
void ConnectionDBBase::disconnectWrite | ( | ) |
Definition at line 104 of file ConnectionDBBase.cxx.
References rdbModel::Connection::close(), and m_writeCxt.
Referenced by ~ConnectionDBBase().
00104 { 00105 if (m_writeCxt) { 00106 m_writeCxt->close(); 00107 delete m_writeCxt; 00108 m_writeCxt = 0; 00109 } 00110 }
rdbModel::Rdb* ConnectionDBBase::getRdb | ( | ) | [inline] |
rdbModel::Connection* ConnectionDBBase::getReadConnection | ( | ) | [inline] |
const std::string& ConnectionDBBase::getTable | ( | ) | [inline] |
std::string ConnectionDBBase::m_dbName [private] |
rdbModel::Assertion* ConnectionDBBase::m_findBest [private] |
Definition at line 64 of file ConnectionDBBase.h.
Definition at line 65 of file ConnectionDBBase.h.
std::string ConnectionDBBase::m_host [private] |
rdbModel::Manager* ConnectionDBBase::m_man [private] |
bool ConnectionDBBase::m_match [private] |
Definition at line 87 of file ConnectionDBBase.h.
std::string ConnectionDBBase::m_password [private] |
rdbModel::Rdb* ConnectionDBBase::m_rdb [private] |
rdbModel::Connection* ConnectionDBBase::m_readCxt [private] |
Definition at line 60 of file ConnectionDBBase.h.
Referenced by connectRead(), connectWrite(), disconnectRead(), and getReadConnection().
std::string ConnectionDBBase::m_table [private] |
std::string ConnectionDBBase::m_userName [private] |
rdbModel::Connection* ConnectionDBBase::m_writeCxt [private] |
Definition at line 61 of file ConnectionDBBase.h.
Referenced by connectWrite(), and disconnectWrite().