diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-01-18 17:26:30 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-06-13 17:29:47 +0100 |
commit | 2efa9433971f1e43aa9ce408f37ca0e6d4ebb468 (patch) | |
tree | d1a79293f2fa284eb53f3a1abe4c7e7367894029 /p2pvr/daemon | |
parent | Switch to run as unit-test is deprecated (diff) | |
download | p2pvr-2efa9433971f1e43aa9ce408f37ca0e6d4ebb468.tar.bz2 p2pvr-2efa9433971f1e43aa9ce408f37ca0e6d4ebb468.tar.xz p2pvr-2efa9433971f1e43aa9ce408f37ca0e6d4ebb468.zip |
Merge all delivery methods
Diffstat (limited to 'p2pvr/daemon')
-rw-r--r-- | p2pvr/daemon/maintenance/network.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/p2pvr/daemon/maintenance/network.cpp b/p2pvr/daemon/maintenance/network.cpp index 4ecb7d1..3c21639 100644 --- a/p2pvr/daemon/maintenance/network.cpp +++ b/p2pvr/daemon/maintenance/network.cpp @@ -5,7 +5,6 @@ #include <Ice/Communicator.h> #include <p2Helpers.h> #include <containerIterator.h> -#include <singleIterator.h> #include <temporaryIceAdapterObject.h> class SiNetworkInformationMerger : public SiNetworkInformationParser { @@ -39,15 +38,9 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser { mergeTransports.loadComplete(commonObjects); mergeTransports.execute(NULL); - SqlMergeTask mergeDvbt("postgres", "delivery_dvbt"); - CreateColumns<DVBSI::TerrestrialDeliveryPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeDvbt, _1, _2)); - for (const auto & s : n->TransportStreams) { - if (s->Terrestrial) { - mergeDvbt.sources.insert(new SingleIterator<DVBSI::TerrestrialDeliveryPtr>(&s->Terrestrial)); - } - } - mergeDvbt.loadComplete(commonObjects); - mergeDvbt.execute(NULL); + mergeDelivery<DVBSI::TerrestrialDeliveryPtr, &DVBSI::NetworkTransportStream::Terrestrial>("delivery_dvbt", n); + mergeDelivery<DVBSI::SatelliteDeliveryPtr, &DVBSI::NetworkTransportStream::Satellite>("delivery_dvbs", n); + mergeDelivery<DVBSI::CableDeliveryPtr, &DVBSI::NetworkTransportStream::Cable>("delivery_dvbc", n); SqlMergeTask mergeServices("postgres", "services"); CreateColumns<DVBSI::NetworkService>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeServices, _1, _2)); @@ -59,6 +52,21 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser { return false; } private: + template <class Delivery, Delivery DVBSI::NetworkTransportStream::*member> + void mergeDelivery(const std::string & table, DVBSI::NetworkPtr n) + { + SqlMergeTask merge("postgres", table); + CreateColumns<Delivery>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &merge, _1, _2)); + std::vector<Delivery> dels; + for (const auto & s : n->TransportStreams) { + if (auto d = s.get()->*member) { + dels.push_back(d); + } + } + merge.sources.insert(new ContainerIterator<decltype(dels)>(&dels)); + merge.loadComplete(commonObjects); + merge.execute(NULL); + } DatabaseClient * commonObjects; }; |