From 7760c2c7bc604f33fdf0b2b74654c3745b192524 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 16 Aug 2013 11:15:05 +0200 Subject: [PATCH] ido: Rename component with ido prefix. This marks the configuration object as ido specific mysql db connection. refs #3307 --- components/ido_mysql/Makefile.am | 4 +- components/ido_mysql/ido_mysql-type.conf | 2 +- ...onnection.cpp => idomysqldbconnection.cpp} | 38 +++++++++---------- ...ldbconnection.h => idomysqldbconnection.h} | 16 ++++---- 4 files changed, 30 insertions(+), 30 deletions(-) rename components/ido_mysql/{mysqldbconnection.cpp => idomysqldbconnection.cpp} (90%) rename components/ido_mysql/{mysqldbconnection.h => idomysqldbconnection.h} (88%) diff --git a/components/ido_mysql/Makefile.am b/components/ido_mysql/Makefile.am index 8e48e0e43..65ee462f1 100644 --- a/components/ido_mysql/Makefile.am +++ b/components/ido_mysql/Makefile.am @@ -12,8 +12,8 @@ EXTRA_DIST = \ libido_mysql_la_SOURCES = \ ido_mysql-type.cpp \ - mysqldbconnection.cpp \ - mysqldbconnection.h + idomysqldbconnection.cpp \ + idomysqldbconnection.h libido_mysql_la_CPPFLAGS = \ $(LTDLINCL) \ diff --git a/components/ido_mysql/ido_mysql-type.conf b/components/ido_mysql/ido_mysql-type.conf index 4e8d16df9..d5bb20726 100644 --- a/components/ido_mysql/ido_mysql-type.conf +++ b/components/ido_mysql/ido_mysql-type.conf @@ -17,7 +17,7 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -type MysqlDbConnection inherits DbConnection { +type IdoMysqlDbConnection inherits DbConnection { %attribute string "host", %attribute number "port", diff --git a/components/ido_mysql/mysqldbconnection.cpp b/components/ido_mysql/idomysqldbconnection.cpp similarity index 90% rename from components/ido_mysql/mysqldbconnection.cpp rename to components/ido_mysql/idomysqldbconnection.cpp index 36a97dbf8..8dd322f40 100644 --- a/components/ido_mysql/mysqldbconnection.cpp +++ b/components/ido_mysql/idomysqldbconnection.cpp @@ -23,16 +23,16 @@ #include "base/utility.h" #include "ido/dbtype.h" #include "ido/dbvalue.h" -#include "ido_mysql/mysqldbconnection.h" +#include "ido_mysql/idomysqldbconnection.h" #include #include #include using namespace icinga; -REGISTER_TYPE(MysqlDbConnection); +REGISTER_TYPE(IdoMysqlDbConnection); -MysqlDbConnection::MysqlDbConnection(const Dictionary::Ptr& serializedUpdate) +IdoMysqlDbConnection::IdoMysqlDbConnection(const Dictionary::Ptr& serializedUpdate) : DbConnection(serializedUpdate), m_Connected(false) { RegisterAttribute("host", Attribute_Config, &m_Host); @@ -46,18 +46,18 @@ MysqlDbConnection::MysqlDbConnection(const Dictionary::Ptr& serializedUpdate) m_TxTimer = boost::make_shared(); m_TxTimer->SetInterval(5); - m_TxTimer->OnTimerExpired.connect(boost::bind(&MysqlDbConnection::TxTimerHandler, this)); + m_TxTimer->OnTimerExpired.connect(boost::bind(&IdoMysqlDbConnection::TxTimerHandler, this)); m_TxTimer->Start(); m_ReconnectTimer = boost::make_shared(); m_ReconnectTimer->SetInterval(10); - m_ReconnectTimer->OnTimerExpired.connect(boost::bind(&MysqlDbConnection::ReconnectTimerHandler, this)); + m_ReconnectTimer->OnTimerExpired.connect(boost::bind(&IdoMysqlDbConnection::ReconnectTimerHandler, this)); m_ReconnectTimer->Start(); ASSERT(mysql_thread_safe()); } -void MysqlDbConnection::Stop(void) +void IdoMysqlDbConnection::Stop(void) { boost::mutex::scoped_lock lock(m_ConnectionMutex); @@ -68,7 +68,7 @@ void MysqlDbConnection::Stop(void) mysql_close(&m_Connection); } -void MysqlDbConnection::TxTimerHandler(void) +void IdoMysqlDbConnection::TxTimerHandler(void) { boost::mutex::scoped_lock lock(m_ConnectionMutex); @@ -79,7 +79,7 @@ void MysqlDbConnection::TxTimerHandler(void) Query("BEGIN"); } -void MysqlDbConnection::ReconnectTimerHandler(void) +void IdoMysqlDbConnection::ReconnectTimerHandler(void) { { boost::mutex::scoped_lock lock(m_ConnectionMutex); @@ -160,7 +160,7 @@ void MysqlDbConnection::ReconnectTimerHandler(void) UpdateAllObjects(); } -void MysqlDbConnection::ClearConfigTables(void) +void IdoMysqlDbConnection::ClearConfigTables(void) { /* TODO make hardcoded table names modular */ ClearConfigTable("commands"); @@ -187,12 +187,12 @@ void MysqlDbConnection::ClearConfigTables(void) ClearConfigTable("timeperiods"); } -void MysqlDbConnection::ClearConfigTable(const String& table) +void IdoMysqlDbConnection::ClearConfigTable(const String& table) { Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Convert::ToString(static_cast(m_InstanceID))); } -Array::Ptr MysqlDbConnection::Query(const String& query) +Array::Ptr IdoMysqlDbConnection::Query(const String& query) { Log(LogDebug, "ido_mysql", "Query: " + query); @@ -224,12 +224,12 @@ Array::Ptr MysqlDbConnection::Query(const String& query) return rows; } -DbReference MysqlDbConnection::GetLastInsertID(void) +DbReference IdoMysqlDbConnection::GetLastInsertID(void) { return DbReference(mysql_insert_id(&m_Connection)); } -String MysqlDbConnection::Escape(const String& s) +String IdoMysqlDbConnection::Escape(const String& s) { ssize_t length = s.GetLength(); char *to = new char[s.GetLength() * 2 + 1]; @@ -243,7 +243,7 @@ String MysqlDbConnection::Escape(const String& s) return result; } -Dictionary::Ptr MysqlDbConnection::FetchRow(MYSQL_RES *result) +Dictionary::Ptr IdoMysqlDbConnection::FetchRow(MYSQL_RES *result) { MYSQL_ROW row; MYSQL_FIELD *field; @@ -274,13 +274,13 @@ Dictionary::Ptr MysqlDbConnection::FetchRow(MYSQL_RES *result) return dict; } -void MysqlDbConnection::ActivateObject(const DbObject::Ptr& dbobj) +void IdoMysqlDbConnection::ActivateObject(const DbObject::Ptr& dbobj) { boost::mutex::scoped_lock lock(m_ConnectionMutex); InternalActivateObject(dbobj); } -void MysqlDbConnection::InternalActivateObject(const DbObject::Ptr& dbobj) +void IdoMysqlDbConnection::InternalActivateObject(const DbObject::Ptr& dbobj) { if (!m_Connected) return; @@ -300,7 +300,7 @@ void MysqlDbConnection::InternalActivateObject(const DbObject::Ptr& dbobj) } } -void MysqlDbConnection::DeactivateObject(const DbObject::Ptr& dbobj) +void IdoMysqlDbConnection::DeactivateObject(const DbObject::Ptr& dbobj) { boost::mutex::scoped_lock lock(m_ConnectionMutex); @@ -321,7 +321,7 @@ void MysqlDbConnection::DeactivateObject(const DbObject::Ptr& dbobj) } /* caller must hold m_ConnectionMutex */ -bool MysqlDbConnection::FieldToEscapedString(const String& key, const Value& value, Value *result) +bool IdoMysqlDbConnection::FieldToEscapedString(const String& key, const Value& value, Value *result) { if (key == "instance_id") { *result = static_cast(m_InstanceID); @@ -372,7 +372,7 @@ bool MysqlDbConnection::FieldToEscapedString(const String& key, const Value& val return true; } -void MysqlDbConnection::ExecuteQuery(const DbQuery& query) +void IdoMysqlDbConnection::ExecuteQuery(const DbQuery& query) { boost::mutex::scoped_lock lock(m_ConnectionMutex); diff --git a/components/ido_mysql/mysqldbconnection.h b/components/ido_mysql/idomysqldbconnection.h similarity index 88% rename from components/ido_mysql/mysqldbconnection.h rename to components/ido_mysql/idomysqldbconnection.h index 196dce320..61fb8f593 100644 --- a/components/ido_mysql/mysqldbconnection.h +++ b/components/ido_mysql/idomysqldbconnection.h @@ -17,8 +17,8 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************/ -#ifndef MYSQLDBCONNECTION_H -#define MYSQLDBCONNECTION_H +#ifndef IDOMYSQLDBCONNECTION_H +#define IDOMYSQLDBCONNECTION_H #include "base/array.h" #include "base/dynamictype.h" @@ -30,17 +30,17 @@ namespace icinga { /** - * A MySQL database connection. + * An IDO MySQL database connection. * * @ingroup ido */ -class MysqlDbConnection : public DbConnection +class IdoMysqlDbConnection : public DbConnection { public: - typedef shared_ptr Ptr; - typedef weak_ptr WeakPtr; + typedef shared_ptr Ptr; + typedef weak_ptr WeakPtr; - MysqlDbConnection(const Dictionary::Ptr& serializedUpdate); + IdoMysqlDbConnection(const Dictionary::Ptr& serializedUpdate); virtual void Stop(void); //virtual void UpdateObject(const DbObject::Ptr& dbobj, DbUpdateType kind); @@ -85,4 +85,4 @@ private: } -#endif /* MYSQLDBCONNECTION_H */ +#endif /* IDOMYSQLDBCONNECTION_H */ -- 2.40.0