From 1eaa6683947f4ebe74c29b4844b47efb352f9a3b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 14 Jun 2015 03:20:20 +0100 Subject: Compatibility with AppInstance and ExecContext changes --- p2pvr/daemon/containerIterator.h | 2 +- p2pvr/daemon/maintenance/events.cpp | 16 +++++++++++----- p2pvr/daemon/maintenance/network.cpp | 11 ++++++----- p2pvr/daemon/maintenance/services.cpp | 5 +++-- p2pvr/daemon/privateExecContext.cpp | 14 ++++++++++++++ p2pvr/daemon/privateExecContext.h | 13 +++++++++++++ p2pvr/daemon/schedules.cpp | 4 +++- p2pvr/daemon/unittests/testErrorHandling.cpp | 3 ++- p2pvr/daemon/unittests/testMaint.cpp | 3 ++- p2pvr/daemon/unittests/testRecording.cpp | 4 ++-- p2pvr/daemon/unittests/testRecordings.cpp | 3 ++- p2pvr/daemon/unittests/testSched.cpp | 3 ++- p2pvr/daemon/unittests/testSi.cpp | 3 ++- p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp | 3 ++- p2pvr/daemon/unittests/testStorage.cpp | 3 ++- p2pvr/daemon/unittests/testp2ice.cpp | 3 +++ 16 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 p2pvr/daemon/privateExecContext.cpp create mode 100644 p2pvr/daemon/privateExecContext.h diff --git a/p2pvr/daemon/containerIterator.h b/p2pvr/daemon/containerIterator.h index 14c339d..88976af 100644 --- a/p2pvr/daemon/containerIterator.h +++ b/p2pvr/daemon/containerIterator.h @@ -20,7 +20,7 @@ class ContainerIterator : public IHaveSubTasks { ObjectRowStateTmpl rs; for (const auto & i : *container) { binder(rs, i); - rs.process(boost::bind(&ContainerIterator::executeChildren, this, ec)); + rs.process(ec, boost::bind(&ContainerIterator::executeChildren, this, ec)); } } diff --git a/p2pvr/daemon/maintenance/events.cpp b/p2pvr/daemon/maintenance/events.cpp index 9a22cd9..7029398 100644 --- a/p2pvr/daemon/maintenance/events.cpp +++ b/p2pvr/daemon/maintenance/events.cpp @@ -8,21 +8,25 @@ #include #include #include +#include ResourceString(Maint_pruneEvents, sql_Maint_pruneEvents); class SiEventsHandler : public SiEpgParser { public: - SiEventsHandler(const RowProcessorCallback & cb, const SelectedColumns & sc) : + SiEventsHandler(const RowProcessorCallback & cb, ExecContext * e, const SelectedColumns & sc) : ecs(sc), - callBack(cb) {} + callBack(cb), + ec(e) + { + } bool HandleTable(DVBSI::EventPtr e) { Logger()->messagebf(LOG_DEBUG, "Service Id: %d Program Id: %d Title: %s Time: %s - %s", e->ServiceId, e->EventId, e->Title, e->StartTime, e->StopTime); BindColumns(rowState, ecs, e); - rowState.process(callBack); + rowState.process(ec, callBack); return false; } @@ -30,6 +34,7 @@ class SiEventsHandler : public SiEpgParser { ObjectRowStateTmpl rowState; const SelectedColumns & ecs; const RowProcessorCallback callBack; + ExecContext * ec; }; class SiEventsMerger : public IHaveSubTasks { @@ -51,7 +56,7 @@ class SiEventsMerger : public IHaveSubTasks { } TemporaryIceAdapterObject parser(ice.adapter, - new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec), ecs)); + new SiEventsHandler(boost::bind(&SiEventsMerger::executeChildren, this, ec), ec, ecs)); auto delivery = si->GetDeliveryForSi(); if (!delivery) { @@ -81,13 +86,14 @@ void Maintenance::UpdateEvents(const Ice::Current & ice) { TxHelper tx(this); + PrivateExecContext ec; SqlMergeTask mergeEvents("postgres", "events"); auto ecs = CreateColumns(boost::bind(SqlMergeColumnsInserter, &mergeEvents, _1, _2)); mergeEvents.sources.insert(new SiEventsMerger(ice, ecs)); mergeEvents.insteadOfDelete = new DynamicSql::SqlText("SET current = false"); mergeEvents.updateWhere = new DynamicSql::SqlText("a.current"); mergeEvents.loadComplete(this); - mergeEvents.execute(NULL); + mergeEvents.execute(&ec); Modify(Maint_pruneEvents).second->execute(); tx.Commit(); Logger()->messagebf(LOG_INFO, "%s: Updated events", __PRETTY_FUNCTION__); diff --git a/p2pvr/daemon/maintenance/network.cpp b/p2pvr/daemon/maintenance/network.cpp index 0152a29..fdf2c8e 100644 --- a/p2pvr/daemon/maintenance/network.cpp +++ b/p2pvr/daemon/maintenance/network.cpp @@ -6,8 +6,9 @@ #include #include #include +#include -class SiNetworkInformationMerger : public SiNetworkInformationParser { +class SiNetworkInformationMerger : public SiNetworkInformationParser, public PrivateExecContext { public: SiNetworkInformationMerger(DatabaseClient * co) : commonObjects(co) { } @@ -30,13 +31,13 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser { std::vector networks = { n }; mergeNetwork.sources.insert(new ContainerIterator>(&networks, ncs)); mergeNetwork.loadComplete(commonObjects); - mergeNetwork.execute(NULL); + mergeNetwork.execute(this); SqlMergeTask mergeTransports("postgres", "transportstreams"); auto tscs = CreateColumns(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeTransports, _1, _2)); mergeTransports.sources.insert(new ContainerIterator(&n->TransportStreams, tscs)); mergeTransports.loadComplete(commonObjects); - mergeTransports.execute(NULL); + mergeTransports.execute(this); mergeDelivery("delivery_dvbt", n); mergeDelivery("delivery_dvbs", n); @@ -48,7 +49,7 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser { mergeServices.sources.insert(new ContainerIterator(&s->Services, scs)); } mergeServices.loadComplete(commonObjects); - mergeServices.execute(NULL); + mergeServices.execute(this); return false; } private: @@ -65,7 +66,7 @@ class SiNetworkInformationMerger : public SiNetworkInformationParser { } merge.sources.insert(new ContainerIterator(&dels, dcs)); merge.loadComplete(commonObjects); - merge.execute(NULL); + merge.execute(this); } DatabaseClient * commonObjects; }; diff --git a/p2pvr/daemon/maintenance/services.cpp b/p2pvr/daemon/maintenance/services.cpp index 6619d42..e5edbc5 100644 --- a/p2pvr/daemon/maintenance/services.cpp +++ b/p2pvr/daemon/maintenance/services.cpp @@ -6,8 +6,9 @@ #include #include #include +#include -class SiServicesMerger : public SiServicesParser { +class SiServicesMerger : public SiServicesParser, public PrivateExecContext { public: SiServicesMerger(DatabaseClient * co) : commonObjects(co) { } @@ -29,7 +30,7 @@ class SiServicesMerger : public SiServicesParser { mergeServices.doInsert = VariableType(false); mergeServices.sources.insert(new ContainerIterator(&ts->Services, scs)); mergeServices.loadComplete(commonObjects); - mergeServices.execute(NULL); + mergeServices.execute(this); return false; } diff --git a/p2pvr/daemon/privateExecContext.cpp b/p2pvr/daemon/privateExecContext.cpp new file mode 100644 index 0000000..47c5773 --- /dev/null +++ b/p2pvr/daemon/privateExecContext.cpp @@ -0,0 +1,14 @@ +#include "privateExecContext.h" + +VariableType +PrivateExecContext::getParameter(const VariableType &) const +{ + throw NotSupported(__PRETTY_FUNCTION__); +} + +SessionPtr +PrivateExecContext::getSession() const +{ + throw NotSupported(__PRETTY_FUNCTION__); +} + diff --git a/p2pvr/daemon/privateExecContext.h b/p2pvr/daemon/privateExecContext.h new file mode 100644 index 0000000..1d336b0 --- /dev/null +++ b/p2pvr/daemon/privateExecContext.h @@ -0,0 +1,13 @@ +#ifndef PRIVATEEXECCONTENT_H +#define PRIVATEEXECCONTENT_H + +#include + +class PrivateExecContext : public ExecContext { + public: + VariableType getParameter(const VariableType & key) const; + SessionPtr getSession() const; +}; + +#endif + diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 674dd87..5e3881d 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -14,6 +14,7 @@ #include "sqlSelectDeserializer.h" #include #include +#include ResourceString(Schedules_getCandidates, sql_Schedules_getCandidates); ResourceString(Schedules_insert, sql_Schedules_insert); @@ -284,11 +285,12 @@ Schedules::DoReschedule(const Ice::Current & ice) } TxHelper tx(this); + PrivateExecContext ec; SqlMergeTask mergeRecords("postgres", "record"); auto rcs = CreateColumns(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeRecords, _1, _2)); mergeRecords.sources.insert(new ContainerIterator(&records, rcs)); mergeRecords.loadComplete(this); - mergeRecords.execute(NULL); + mergeRecords.execute(&ec); tx.Commit(); auto recorder = P2PVR::RecorderPrx::checkedCast(ice.adapter->createProxy(ice.adapter->getCommunicator()->stringToIdentity("Recorder"))); diff --git a/p2pvr/daemon/unittests/testErrorHandling.cpp b/p2pvr/daemon/unittests/testErrorHandling.cpp index ca5bd63..9c720a2 100644 --- a/p2pvr/daemon/unittests/testErrorHandling.cpp +++ b/p2pvr/daemon/unittests/testErrorHandling.cpp @@ -16,8 +16,9 @@ #include #include #include "mockDefs.h" +#include -class Core { +class Core : public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp index f8340af..0d7d5a0 100644 --- a/p2pvr/daemon/unittests/testMaint.cpp +++ b/p2pvr/daemon/unittests/testMaint.cpp @@ -17,8 +17,9 @@ #include "sqlSelectDeserializer.h" #include "commonHelpers.h" #include +#include -class Core : public CommonObjects { +class Core : public CommonObjects, public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp index 4e49916..720b868 100644 --- a/p2pvr/daemon/unittests/testRecording.cpp +++ b/p2pvr/daemon/unittests/testRecording.cpp @@ -19,9 +19,9 @@ #include "serviceStreamer.h" #include "temporaryIceAdapterObject.h" #include +#include - -class Core : public CommonObjects { +class Core : public CommonObjects, public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testRecordings.cpp b/p2pvr/daemon/unittests/testRecordings.cpp index c0496d3..eb3d5db 100644 --- a/p2pvr/daemon/unittests/testRecordings.cpp +++ b/p2pvr/daemon/unittests/testRecordings.cpp @@ -15,8 +15,9 @@ #include #include #include "mockDefs.h" +#include -class Core { +class Core : public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp index bfa8567..3a513d0 100644 --- a/p2pvr/daemon/unittests/testSched.cpp +++ b/p2pvr/daemon/unittests/testSched.cpp @@ -16,8 +16,9 @@ #include #include #include "mockDefs.h" +#include -class Core { +class Core : public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testSi.cpp b/p2pvr/daemon/unittests/testSi.cpp index c0f3fdf..6cc810b 100644 --- a/p2pvr/daemon/unittests/testSi.cpp +++ b/p2pvr/daemon/unittests/testSi.cpp @@ -13,8 +13,9 @@ #include #include #include "mockDefs.h" +#include -class Core { +class Core : public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp index b109c04..2608fd8 100644 --- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp +++ b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp @@ -11,10 +11,11 @@ #include #include #include "mockDefs.h" +#include typedef boost::shared_ptr SelectPtr; -class TestCommonObjects : public CommonObjects { +class TestCommonObjects : public CommonObjects, public TestAppInstance { public: TestCommonObjects() { diff --git a/p2pvr/daemon/unittests/testStorage.cpp b/p2pvr/daemon/unittests/testStorage.cpp index 5480566..973e93b 100644 --- a/p2pvr/daemon/unittests/testStorage.cpp +++ b/p2pvr/daemon/unittests/testStorage.cpp @@ -10,9 +10,10 @@ #include #include #include +#include const boost::filesystem::path rootDir = "/tmp/ut/p2pvr/recordings"; -class Core { +class Core : public TestAppInstance { public: Core() { diff --git a/p2pvr/daemon/unittests/testp2ice.cpp b/p2pvr/daemon/unittests/testp2ice.cpp index 23fcbdc..4d29cc9 100644 --- a/p2pvr/daemon/unittests/testp2ice.cpp +++ b/p2pvr/daemon/unittests/testp2ice.cpp @@ -4,6 +4,7 @@ #include #include #include +#include const boost::filesystem::path variant = BinDir.leaf(); const boost::filesystem::path compiler = BinDir.parent_path().leaf(); @@ -29,6 +30,8 @@ unloadTests() BOOST_WARN_THROW(ElementLoader::getFor("p2pvrservicestream"), NotSupported); } +BOOST_GLOBAL_FIXTURE( TestAppInstance ); + BOOST_AUTO_TEST_CASE( compile_client_clientOnly ) { TestOptionsSource::LoadTestOptions({ }); -- cgit v1.2.3