From d4bb166d7806fc984a27ec9cb64d14543576e835 Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 11 Dec 2013 16:37:46 +0000 Subject: Move the txHelper into dbClient --- p2pvr/lib/dbClient.cpp | 14 ++++++++++++++ p2pvr/lib/dbClient.h | 13 +++++++++++++ p2pvr/lib/maintenance.cpp | 15 --------------- p2pvr/lib/maintenance.h | 17 ++--------------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/p2pvr/lib/dbClient.cpp b/p2pvr/lib/dbClient.cpp index b123a0a..5252e5b 100644 --- a/p2pvr/lib/dbClient.cpp +++ b/p2pvr/lib/dbClient.cpp @@ -20,4 +20,18 @@ DatabaseClient::Select(const std::string & sql, const std::list & return sel; } +void +DatabaseClient::onAllDatasources(const DataSourceCall & call) const +{ + BOOST_FOREACH(const CommonObjects::DataSources::value_type & ds, CommonObjects::datasources) { + call(ds.second); + } +} + +DatabaseClient::TxHelper::TxHelper(const DatabaseClient * dbc) : + so(NULL, + boost::bind(&DatabaseClient::onAllDatasources, dbc, DataSourceCall(boost::bind(&DataSource::commit, _1))), + boost::bind(&DatabaseClient::onAllDatasources, dbc, DataSourceCall(boost::bind(&DataSource::rollback, _1)))) +{ +} diff --git a/p2pvr/lib/dbClient.h b/p2pvr/lib/dbClient.h index 62dafef..aef2bf2 100644 --- a/p2pvr/lib/dbClient.h +++ b/p2pvr/lib/dbClient.h @@ -5,13 +5,26 @@ #include #include #include +#include class DatabaseClient : public virtual CommonObjects { public: typedef boost::shared_ptr SelectPtr; protected: + class TxHelper { + public: + TxHelper(const DatabaseClient *); + private: + ScopeObject so; + }; + SelectPtr Select(const std::string &) const; SelectPtr Select(const std::string &, const std::list &) const; + + private: + friend class TxHelper; + typedef boost::function DataSourceCall; + void onAllDatasources(const DataSourceCall &) const; }; #endif diff --git a/p2pvr/lib/maintenance.cpp b/p2pvr/lib/maintenance.cpp index 1dbeba5..275951e 100644 --- a/p2pvr/lib/maintenance.cpp +++ b/p2pvr/lib/maintenance.cpp @@ -32,18 +32,3 @@ Maintenance::UpdateAll(short type, const Ice::Current & ice) UpdateEvents(type, ice); } -void -Maintenance::onAllDatasources(const DataSourceCall & call) const -{ - BOOST_FOREACH(const CommonObjects::DataSources::value_type & ds, CommonObjects::datasources) { - call(ds.second); - } -} - -Maintenance::TxHelper::TxHelper(const Maintenance * m) : - so(NULL, - boost::bind(&Maintenance::onAllDatasources, m, DataSourceCall(boost::bind(&DataSource::commit, _1))), - boost::bind(&Maintenance::onAllDatasources, m, DataSourceCall(boost::bind(&DataSource::rollback, _1)))) -{ -} - diff --git a/p2pvr/lib/maintenance.h b/p2pvr/lib/maintenance.h index d1b36e1..edb5070 100644 --- a/p2pvr/lib/maintenance.h +++ b/p2pvr/lib/maintenance.h @@ -2,20 +2,12 @@ #define P2PVR_MAINTENANCE_H #include -#include -#include +#include "dbClient.h" class SqlMergeTask; -class Maintenance : public P2PVR::Maintenance, public virtual CommonObjects { +class Maintenance : public P2PVR::Maintenance, public DatabaseClient { public: - class TxHelper { - public: - TxHelper(const Maintenance *); - private: - ScopeObject so; - }; - void UpdateAll(const Ice::Current &); void UpdateAll(short type, const Ice::Current &); void UpdateNetwork(short type, const Ice::Current &); @@ -25,11 +17,6 @@ class Maintenance : public P2PVR::Maintenance, public virtual CommonObjects { void UpdateEvents(short type, const Ice::Current &); static void SqlMergeColumnsInserter(SqlMergeTask * merge, const std::string & name, bool key); - - private: - friend class TxHelper; - typedef boost::function DataSourceCall; - void onAllDatasources(const DataSourceCall &) const; }; #endif -- cgit v1.2.3