diff options
author | randomdan <randomdan@localhost> | 2013-12-11 16:37:46 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2013-12-11 16:37:46 +0000 |
commit | d4bb166d7806fc984a27ec9cb64d14543576e835 (patch) | |
tree | ca7dac1b5f353651de84f0d7528d873bf26547b0 | |
parent | Add pre-compiled header support (diff) | |
download | p2pvr-d4bb166d7806fc984a27ec9cb64d14543576e835.tar.bz2 p2pvr-d4bb166d7806fc984a27ec9cb64d14543576e835.tar.xz p2pvr-d4bb166d7806fc984a27ec9cb64d14543576e835.zip |
Move the txHelper into dbClient
-rw-r--r-- | p2pvr/lib/dbClient.cpp | 14 | ||||
-rw-r--r-- | p2pvr/lib/dbClient.h | 13 | ||||
-rw-r--r-- | p2pvr/lib/maintenance.cpp | 15 | ||||
-rw-r--r-- | 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<VariableType> & 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 <variableType.h> #include <list> #include <selectcommand.h> +#include <scopeObject.h> class DatabaseClient : public virtual CommonObjects { public: typedef boost::shared_ptr<DB::SelectCommand> 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<VariableType> &) const; + + private: + friend class TxHelper; + typedef boost::function<void(DataSourcePtr)> 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 <p2pvr.h> -#include <commonObjects.h> -#include <scopeObject.h> +#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<void(DataSourcePtr)> DataSourceCall; - void onAllDatasources(const DataSourceCall &) const; }; #endif |