From d6a39d3b419262532ba951384db6a3e724654fd4 Mon Sep 17 00:00:00 2001 From: randomdan Date: Tue, 17 Dec 2013 12:14:53 +0000 Subject: Move some stuff into a utils lib --- p2pvr/Jamfile.jam | 2 +- p2pvr/daemon/daemon.cpp | 7 +-- p2pvr/lib/Jamfile.jam | 2 +- p2pvr/lib/containerCreator.h | 33 ----------- p2pvr/lib/containerIterator.h | 41 -------------- p2pvr/lib/dvbsiHelpers.h | 23 -------- p2pvr/lib/dvbsiHelpers/cableDelivery.cpp | 39 ------------- p2pvr/lib/dvbsiHelpers/event.cpp | 64 ---------------------- p2pvr/lib/dvbsiHelpers/network.cpp | 21 ------- p2pvr/lib/dvbsiHelpers/networkService.cpp | 22 -------- p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp | 23 -------- p2pvr/lib/dvbsiHelpers/programMap.cpp | 24 -------- p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp | 51 ----------------- p2pvr/lib/dvbsiHelpers/service.cpp | 49 ----------------- p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp | 59 -------------------- p2pvr/lib/fileHandle.cpp | 28 ---------- p2pvr/lib/fileHandle.h | 19 ------- p2pvr/lib/maintenance/events.cpp | 8 +-- p2pvr/lib/maintenance/network.cpp | 8 +-- p2pvr/lib/maintenance/programAssociations.cpp | 6 +- p2pvr/lib/maintenance/programMap.cpp | 8 +-- p2pvr/lib/maintenance/services.cpp | 8 +-- p2pvr/lib/mapIterator.cpp | 11 ---- p2pvr/lib/mapIterator.h | 45 --------------- p2pvr/lib/objectRowState.h | 45 --------------- p2pvr/lib/p2Helpers.cpp | 32 ----------- p2pvr/lib/p2Helpers.h | 63 --------------------- p2pvr/lib/singleIterator.h | 39 ------------- p2pvr/util/Jamfile.jam | 19 +++++++ p2pvr/util/containerCreator.h | 33 +++++++++++ p2pvr/util/containerIterator.h | 41 ++++++++++++++ p2pvr/util/dvbsiHelpers.h | 23 ++++++++ p2pvr/util/dvbsiHelpers/cableDelivery.cpp | 39 +++++++++++++ p2pvr/util/dvbsiHelpers/event.cpp | 64 ++++++++++++++++++++++ p2pvr/util/dvbsiHelpers/network.cpp | 21 +++++++ p2pvr/util/dvbsiHelpers/networkService.cpp | 22 ++++++++ p2pvr/util/dvbsiHelpers/networkTransportStream.cpp | 23 ++++++++ p2pvr/util/dvbsiHelpers/programMap.cpp | 24 ++++++++ p2pvr/util/dvbsiHelpers/satelliteDelivery.cpp | 51 +++++++++++++++++ p2pvr/util/dvbsiHelpers/service.cpp | 49 +++++++++++++++++ p2pvr/util/dvbsiHelpers/terrestrialDelivery.cpp | 59 ++++++++++++++++++++ p2pvr/util/fileHandle.cpp | 28 ++++++++++ p2pvr/util/fileHandle.h | 19 +++++++ p2pvr/util/mapIterator.cpp | 11 ++++ p2pvr/util/mapIterator.h | 45 +++++++++++++++ p2pvr/util/objectRowState.h | 45 +++++++++++++++ p2pvr/util/p2Helpers.cpp | 32 +++++++++++ p2pvr/util/p2Helpers.h | 63 +++++++++++++++++++++ p2pvr/util/pch.hpp | 23 ++++++++ p2pvr/util/singleIterator.h | 39 +++++++++++++ 50 files changed, 795 insertions(+), 758 deletions(-) delete mode 100644 p2pvr/lib/containerCreator.h delete mode 100644 p2pvr/lib/containerIterator.h delete mode 100644 p2pvr/lib/dvbsiHelpers.h delete mode 100644 p2pvr/lib/dvbsiHelpers/cableDelivery.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/event.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/network.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/networkService.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/programMap.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/service.cpp delete mode 100644 p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp delete mode 100644 p2pvr/lib/fileHandle.cpp delete mode 100644 p2pvr/lib/fileHandle.h delete mode 100644 p2pvr/lib/mapIterator.cpp delete mode 100644 p2pvr/lib/mapIterator.h delete mode 100644 p2pvr/lib/objectRowState.h delete mode 100644 p2pvr/lib/p2Helpers.cpp delete mode 100644 p2pvr/lib/p2Helpers.h delete mode 100644 p2pvr/lib/singleIterator.h create mode 100644 p2pvr/util/Jamfile.jam create mode 100644 p2pvr/util/containerCreator.h create mode 100644 p2pvr/util/containerIterator.h create mode 100644 p2pvr/util/dvbsiHelpers.h create mode 100644 p2pvr/util/dvbsiHelpers/cableDelivery.cpp create mode 100644 p2pvr/util/dvbsiHelpers/event.cpp create mode 100644 p2pvr/util/dvbsiHelpers/network.cpp create mode 100644 p2pvr/util/dvbsiHelpers/networkService.cpp create mode 100644 p2pvr/util/dvbsiHelpers/networkTransportStream.cpp create mode 100644 p2pvr/util/dvbsiHelpers/programMap.cpp create mode 100644 p2pvr/util/dvbsiHelpers/satelliteDelivery.cpp create mode 100644 p2pvr/util/dvbsiHelpers/service.cpp create mode 100644 p2pvr/util/dvbsiHelpers/terrestrialDelivery.cpp create mode 100644 p2pvr/util/fileHandle.cpp create mode 100644 p2pvr/util/fileHandle.h create mode 100644 p2pvr/util/mapIterator.cpp create mode 100644 p2pvr/util/mapIterator.h create mode 100644 p2pvr/util/objectRowState.h create mode 100644 p2pvr/util/p2Helpers.cpp create mode 100644 p2pvr/util/p2Helpers.h create mode 100644 p2pvr/util/pch.hpp create mode 100644 p2pvr/util/singleIterator.h diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam index 4f69bae..a0948fc 100644 --- a/p2pvr/Jamfile.jam +++ b/p2pvr/Jamfile.jam @@ -24,7 +24,7 @@ alias p2daemonlib : glibmm : : : build-project daemon ; build-project carddaemon ; -install debuginstall : lib//p2pvrlib carddaemon daemon ice : ./testing ; +install debuginstall : lib//p2pvrlib util//p2pvrutil carddaemon daemon ice : ./testing ; package.install install : : : carddaemon daemon ; import type ; diff --git a/p2pvr/daemon/daemon.cpp b/p2pvr/daemon/daemon.cpp index 58ca66e..8597a25 100644 --- a/p2pvr/daemon/daemon.cpp +++ b/p2pvr/daemon/daemon.cpp @@ -34,12 +34,7 @@ class P2PvrDaemon : public Daemon { adapter->add(new Schedules(), ic->stringToIdentity("Schedules")); adapter->activate(); - auto maint = P2PVR::MaintenancePrx::checkedCast(adapter->createProxy(ic->stringToIdentity("Maintenance"))); - maint->UpdateNetwork(FE_OFDM); - maint->UpdateServices(FE_OFDM); - maint->UpdateEvents(FE_OFDM); - - //ic->waitForShutdown(); + ic->waitForShutdown(); timer->destroy(); } diff --git a/p2pvr/lib/Jamfile.jam b/p2pvr/lib/Jamfile.jam index f56741c..a1b6214 100644 --- a/p2pvr/lib/Jamfile.jam +++ b/p2pvr/lib/Jamfile.jam @@ -15,11 +15,11 @@ lib p2pvrlib : pch [ glob-tree *.cpp ] [ glob-tree *.sql ] - ../../libmisc/misc.cpp : boost_system boost_filesystem ../ice//p2pvrice + ../util//p2pvrutil ..//p2common ..//p2sql ..//p2lib diff --git a/p2pvr/lib/containerCreator.h b/p2pvr/lib/containerCreator.h deleted file mode 100644 index 9804d9b..0000000 --- a/p2pvr/lib/containerCreator.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CONTAINERCREATOR_H -#define CONTAINERCREATOR_H - -#include -#include -#include "objectRowState.h" - -template > -class ContainerCreator { - public: - ContainerCreator(T & c) : container(c) { } - - void populate( - boost::function fetch, - boost::function get, - unsigned int columnCount) - { - while (fetch()) { - auto v = P(new V); - container.push_back(v); - ObjectRowState

rs; - for (unsigned int c = 0; c < columnCount; c++) { - rs.fields[c] = get(c); - } - UnbindColumns

(rs, v); - } - } - private: - T & container; -}; - -#endif - diff --git a/p2pvr/lib/containerIterator.h b/p2pvr/lib/containerIterator.h deleted file mode 100644 index 2b61055..0000000 --- a/p2pvr/lib/containerIterator.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CONTAINERITERATOR_H -#define CONTAINERITERATOR_H - -#include -#include -#include "objectRowState.h" - -template -class ContainerIterator : public IHaveSubTasks { - public: - ContainerIterator(const T * con) : - SourceObject(__PRETTY_FUNCTION__), - IHaveSubTasks(NULL), - binder(boost::bind(&BindColumns, _1, _2)), - container(con) - { - } - - void execute(ExecContext * ec) const - { - ObjectRowState rs; - BOOST_FOREACH(const auto & i, *container) { - binder(rs, i); - rs.process(boost::bind(&ContainerIterator::executeChildren, this, ec)); - } - } - - private: - boost::function binder; - const T * container; - - void executeChildren(ExecContext * ec) const - { - BOOST_FOREACH(const Tasks::value_type & sq, normal) { - sq->execute(ec); - } - } -}; - -#endif - diff --git a/p2pvr/lib/dvbsiHelpers.h b/p2pvr/lib/dvbsiHelpers.h deleted file mode 100644 index b8cc1cf..0000000 --- a/p2pvr/lib/dvbsiHelpers.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ICE_DVBSI_HELPERS_H -#define ICE_DVBSI_HELPERS_H - -#include -#include "objectRowState.h" - -#define ColumnHelper(T) \ - template<> void CreateColumns(const ColumnCreator & cc); \ - template<> void BindColumns(RowState & rs, const T & obj); \ - template<> void UnbindColumns(RowState & rs, const T & s) - -ColumnHelper(DVBSI::NetworkPtr); -ColumnHelper(DVBSI::NetworkTransportStreamPtr); -ColumnHelper(DVBSI::NetworkService); -ColumnHelper(DVBSI::TerrestrialDeliveryPtr); -ColumnHelper(DVBSI::CableDeliveryPtr); -ColumnHelper(DVBSI::SatelliteDeliveryPtr); -ColumnHelper(DVBSI::ServicePtr); -ColumnHelper(DVBSI::StreamPtr); -ColumnHelper(DVBSI::EventPtr); - -#endif - diff --git a/p2pvr/lib/dvbsiHelpers/cableDelivery.cpp b/p2pvr/lib/dvbsiHelpers/cableDelivery.cpp deleted file mode 100644 index 7bf9f6d..0000000 --- a/p2pvr/lib/dvbsiHelpers/cableDelivery.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("frequency", false); - cc("transportStreamId", true); - cc("fecOuter", false); - cc("modulation", false); - cc("symbolRate", false); - cc("fecInner", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::CableDeliveryPtr & s) -{ - rs.fields[0] << s->Frequency; - rs.fields[1] << s->TransportStreamId; - rs.fields[2] << s->FecOuter; - rs.fields[3] << s->Modulation; - rs.fields[4] << s->SymbolRate; - rs.fields[5] << s->FecInner; -} -template<> -void -UnbindColumns(RowState & rs, DVBSI::CableDeliveryPtr const & s) -{ - rs.fields[0] >> s->Frequency; - rs.fields[1] >> s->TransportStreamId; - rs.fields[2] >> s->FecOuter; - rs.fields[3] >> s->Modulation; - rs.fields[4] >> s->SymbolRate; - rs.fields[5] >> s->FecInner; -} - diff --git a/p2pvr/lib/dvbsiHelpers/event.cpp b/p2pvr/lib/dvbsiHelpers/event.cpp deleted file mode 100644 index decd2b9..0000000 --- a/p2pvr/lib/dvbsiHelpers/event.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("serviceId", true); - cc("eventId", true); - cc("title", false); - cc("titleLang", false); - cc("subtitle", false); - cc("description", false); - cc("descriptionLang", false); - cc("videoAspect", false); - cc("videoFrameRate", false); - cc("videoHd", false); - cc("audioChannels", false); - cc("audioLanguage", false); - cc("subtitleLanguage", false); - cc("category", false); - cc("subCategory", false); - cc("userCategory", false); - cc("dvbRating", false); - cc("startTime", false); - cc("stopTime", false); - cc("episode", false); - cc("episodes", false); - cc("year", false); - cc("flags", false); - cc("season", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::EventPtr & e) -{ - rs.fields[0] << e->ServiceId; - rs.fields[1] << e->EventId; - rs.fields[2] << e->Title; - rs.fields[3] << e->TitleLang; - rs.fields[4] << e->Subtitle; - rs.fields[5] << e->Description; - rs.fields[6] << e->DescriptionLang; - rs.fields[7] << e->VideoAspect; - rs.fields[8] << e->VideoFrameRate; - rs.fields[9] << e->VideoHD; - rs.fields[10] << e->AudioChannels; - rs.fields[11] << e->AudioLanguage; - rs.fields[12] << e->SubtitleLanguage; - rs.fields[13] << e->Category; - rs.fields[14] << e->SubCategory; - rs.fields[15] << e->UserCategory; - rs.fields[16] << e->DvbRating; - rs.fields[17] << e->StartTime; - rs.fields[18] << e->StopTime; - rs.fields[19] << e->Episode; - rs.fields[20] << e->Episodes; - rs.fields[21] << e->Year; - rs.fields[22] << e->Flags; - rs.fields[23] << e->Season; -} - diff --git a/p2pvr/lib/dvbsiHelpers/network.cpp b/p2pvr/lib/dvbsiHelpers/network.cpp deleted file mode 100644 index 3b117f1..0000000 --- a/p2pvr/lib/dvbsiHelpers/network.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("networkId", true); - cc("name", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkPtr & network) -{ - rs.fields[0] << network->NetworkId; - rs.fields[1] << network->Name; -} - - diff --git a/p2pvr/lib/dvbsiHelpers/networkService.cpp b/p2pvr/lib/dvbsiHelpers/networkService.cpp deleted file mode 100644 index a4a47d5..0000000 --- a/p2pvr/lib/dvbsiHelpers/networkService.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("serviceId", true); - cc("type", false); - cc("transportStreamId", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkService & s) -{ - rs.fields[0] << s.ServiceId; - rs.fields[1] << s.ServiceType; - rs.fields[2] << s.TransportStreamId; -} - diff --git a/p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp b/p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp deleted file mode 100644 index bdc7c4f..0000000 --- a/p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("transportStreamId", true); - cc("networkId", false); - cc("originalNetworkId", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkTransportStreamPtr & ts) -{ - rs.fields[0] << ts->TransportStreamId; - rs.fields[1] << ts->NetworkId; - rs.fields[2] << ts->OriginalNetworkId; -} - - diff --git a/p2pvr/lib/dvbsiHelpers/programMap.cpp b/p2pvr/lib/dvbsiHelpers/programMap.cpp deleted file mode 100644 index d8cf400..0000000 --- a/p2pvr/lib/dvbsiHelpers/programMap.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("serviceId", true); - cc("id", true); - cc("type", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::StreamPtr & stream) -{ - rs.fields[0] << stream->ServiceId; - rs.fields[1] << stream->Id; - rs.fields[2] << stream->Type; -} - - - diff --git a/p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp b/p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp deleted file mode 100644 index 8231fc3..0000000 --- a/p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("frequency", false); - cc("transportStreamId", true); - cc("orbitalPosition", false); - cc("westEastFlag", false); - cc("polarization", false); - cc("rollOff", false); - cc("modulationSystem", false); - cc("modulationType", false); - cc("symbolRate", false); - cc("fecInner", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::SatelliteDeliveryPtr & s) -{ - rs.fields[0] << s->Frequency; - rs.fields[1] << s->TransportStreamId; - rs.fields[2] << s->OrbitalPosition; - rs.fields[3] << s->WestEastFlag; - rs.fields[4] << s->Polarization; - rs.fields[5] << s->RollOff; - rs.fields[6] << s->ModulationSystem; - rs.fields[7] << s->ModulationType; - rs.fields[8] << s->SymbolRate; - rs.fields[9] << s->FecInner; -} -template<> -void -UnbindColumns(RowState & rs, DVBSI::SatelliteDeliveryPtr const & s) -{ - rs.fields[0] >> s->Frequency; - rs.fields[1] << s->TransportStreamId; - rs.fields[2] >> s->OrbitalPosition; - rs.fields[3] >> s->WestEastFlag; - rs.fields[4] >> s->Polarization; - rs.fields[5] >> s->RollOff; - rs.fields[6] >> s->ModulationSystem; - rs.fields[7] >> s->ModulationType; - rs.fields[8] >> s->SymbolRate; - rs.fields[9] >> s->FecInner; -} - diff --git a/p2pvr/lib/dvbsiHelpers/service.cpp b/p2pvr/lib/dvbsiHelpers/service.cpp deleted file mode 100644 index 9f82d91..0000000 --- a/p2pvr/lib/dvbsiHelpers/service.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("serviceId", true); - cc("transportStreamId", true); - cc("name", false); - cc("providerName", false); - cc("defaultAuthority", false); - cc("runningStatus", false); - cc("eitSchedule", false); - cc("eitPresentFollowing", false); - cc("freeCAMode", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::ServicePtr & s) -{ - rs.fields[0] << s->ServiceId; - rs.fields[1] << s->TransportStreamId; - rs.fields[2] << s->Name; - rs.fields[3] << s->ProviderName; - rs.fields[4] << s->DefaultAuthority; - rs.fields[5] << s->RunningStatus; - rs.fields[6] << s->EitSchedule; - rs.fields[7] << s->EitPresentFollowing; - rs.fields[8] << s->FreeCaMode; -} - -template<> -void -UnbindColumns(RowState & rs, DVBSI::ServicePtr const & s) -{ - rs.fields[0] >> s->ServiceId; - rs.fields[1] >> s->TransportStreamId; - rs.fields[2] >> s->Name; - rs.fields[3] >> s->ProviderName; - rs.fields[4] >> s->DefaultAuthority; - rs.fields[5] >> s->RunningStatus; - rs.fields[6] >> s->EitSchedule; - rs.fields[7] >> s->EitPresentFollowing; - rs.fields[8] >> s->FreeCaMode; -} - diff --git a/p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp b/p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp deleted file mode 100644 index 46e60f9..0000000 --- a/p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include "../dvbsiHelpers.h" -#include "../p2Helpers.h" - -template<> -void -CreateColumns(const ColumnCreator & cc) -{ - cc("frequency", false); - cc("transportStreamId", true); - cc("bandwidth", false); - cc("priority", false); - cc("timeSlicing", false); - cc("mpeFec", false); - cc("constellation", false); - cc("hierarchy", false); - cc("codeRateHP", false); - cc("codeRateLP", false); - cc("guardInterval", false); - cc("transmissionMode", false); - cc("otherFrequencyFlag", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::TerrestrialDeliveryPtr & s) -{ - rs.fields[0] << s->Frequency; - rs.fields[1] << s->TransportStreamId; - rs.fields[2] << s->Bandwidth; - rs.fields[3] << s->Priority; - rs.fields[4] << s->TimeSlicing; - rs.fields[5] << s->MpeFec; - rs.fields[6] << s->Constellation; - rs.fields[7] << s->Hierarchy; - rs.fields[8] << s->CodeRateHP; - rs.fields[9] << s->CodeRateLP; - rs.fields[10] << s->GuardInterval; - rs.fields[11] << s->TransmissionMode; - rs.fields[12] << s->OtherFrequencyFlag; -} -template<> -void -UnbindColumns(RowState & rs, DVBSI::TerrestrialDeliveryPtr const & s) -{ - rs.fields[0] >> s->Frequency; - rs.fields[2] >> s->Bandwidth; - rs.fields[3] >> s->Priority; - rs.fields[4] >> s->TimeSlicing; - rs.fields[5] >> s->MpeFec; - rs.fields[6] >> s->Constellation; - rs.fields[7] >> s->Hierarchy; - rs.fields[8] >> s->CodeRateHP; - rs.fields[9] >> s->CodeRateLP; - rs.fields[10] >> s->GuardInterval; - rs.fields[11] >> s->TransmissionMode; - rs.fields[12] >> s->OtherFrequencyFlag; -} - diff --git a/p2pvr/lib/fileHandle.cpp b/p2pvr/lib/fileHandle.cpp deleted file mode 100644 index b85d390..0000000 --- a/p2pvr/lib/fileHandle.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include "fileHandle.h" -#include -#include - -class InvalidFileHandle : public std::runtime_error { - public: - InvalidFileHandle() : std::runtime_error("Invalid file handle") { } -}; - -FileHandle::FileHandle(int f) : - fd(f) -{ - if (fd < 0) { - throw InvalidFileHandle(); - } -} - -FileHandle::~FileHandle() -{ - close(fd); -} - -FileHandle::operator int() const -{ - return fd; -} - diff --git a/p2pvr/lib/fileHandle.h b/p2pvr/lib/fileHandle.h deleted file mode 100644 index 3c8d45e..0000000 --- a/p2pvr/lib/fileHandle.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FILEHANDLE_H -#define FILEHANDLE_H - -class FileHandle { - public: - FileHandle(int fd); - ~FileHandle(); - - FileHandle(const FileHandle &) = delete; - void operator=(const FileHandle &) = delete; - - operator int() const; - - private: - const int fd; -}; - -#endif - diff --git a/p2pvr/lib/maintenance/events.cpp b/p2pvr/lib/maintenance/events.cpp index a2d3e21..0327ec8 100644 --- a/p2pvr/lib/maintenance/events.cpp +++ b/p2pvr/lib/maintenance/events.cpp @@ -3,10 +3,10 @@ #include "../siParsers/event.h" #include #include -#include "../p2Helpers.h" -#include "../dvbsiHelpers.h" -#include "../containerIterator.h" -#include "../singleIterator.h" +#include +#include +#include +#include #include "../temporaryIceAdapterObject.h" #include diff --git a/p2pvr/lib/maintenance/network.cpp b/p2pvr/lib/maintenance/network.cpp index 7806824..6704b7b 100644 --- a/p2pvr/lib/maintenance/network.cpp +++ b/p2pvr/lib/maintenance/network.cpp @@ -3,10 +3,10 @@ #include "../siParsers/network.h" #include #include -#include "../p2Helpers.h" -#include "../dvbsiHelpers.h" -#include "../containerIterator.h" -#include "../singleIterator.h" +#include +#include +#include +#include #include "../temporaryIceAdapterObject.h" class SiNetworkInformationMerger : public SiNetworkInformationParser { diff --git a/p2pvr/lib/maintenance/programAssociations.cpp b/p2pvr/lib/maintenance/programAssociations.cpp index 69287da..c859684 100644 --- a/p2pvr/lib/maintenance/programAssociations.cpp +++ b/p2pvr/lib/maintenance/programAssociations.cpp @@ -3,9 +3,9 @@ #include "../siParsers/programAssociation.h" #include #include -#include "../p2Helpers.h" -#include "../dvbsiHelpers.h" -#include "../mapIterator.h" +#include +#include +#include #include "../temporaryIceAdapterObject.h" class SiProgramAssociationHandler : public SiProgramAssociationParser { diff --git a/p2pvr/lib/maintenance/programMap.cpp b/p2pvr/lib/maintenance/programMap.cpp index a7cfe40..75e5ce8 100644 --- a/p2pvr/lib/maintenance/programMap.cpp +++ b/p2pvr/lib/maintenance/programMap.cpp @@ -3,10 +3,10 @@ #include "../siParsers/programMap.h" #include #include -#include "../p2Helpers.h" -#include "../dvbsiHelpers.h" -#include "../containerIterator.h" -#include "../singleIterator.h" +#include +#include +#include +#include #include "../temporaryIceAdapterObject.h" #include #include diff --git a/p2pvr/lib/maintenance/services.cpp b/p2pvr/lib/maintenance/services.cpp index ec4c6dc..ba958a8 100644 --- a/p2pvr/lib/maintenance/services.cpp +++ b/p2pvr/lib/maintenance/services.cpp @@ -3,10 +3,10 @@ #include "../siParsers/service.h" #include #include -#include "../p2Helpers.h" -#include "../dvbsiHelpers.h" -#include "../containerIterator.h" -#include "../singleIterator.h" +#include +#include +#include +#include #include "../temporaryIceAdapterObject.h" class SiServicesMerger : public SiServicesParser { diff --git a/p2pvr/lib/mapIterator.cpp b/p2pvr/lib/mapIterator.cpp deleted file mode 100644 index 157669a..0000000 --- a/p2pvr/lib/mapIterator.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include "mapIterator.h" -#include "p2Helpers.h" - -template<> -void BindColumns>(RowState & rs, std::pair const & p) -{ - rs.fields[0] << p.first; - rs.fields[1] << p.second; -} - diff --git a/p2pvr/lib/mapIterator.h b/p2pvr/lib/mapIterator.h deleted file mode 100644 index 8a06fe6..0000000 --- a/p2pvr/lib/mapIterator.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MAPITERATOR_H -#define MAPITERATOR_H - -#include -#include -#include "objectRowState.h" - -template -class MapIterator : public IHaveSubTasks { - public: - template - MapIterator(const ColumnSpecifier & cs, const T * m, const Parents & ... p) : - SourceObject(__PRETTY_FUNCTION__), - IHaveSubTasks(NULL), - binder(boost::bind(&BindColumns, _1, _2, p...)), - columnSpecifier(cs), - map(m) - { - } - - void execute(ExecContext * ec) const - { - ObjectRowState rs(columnSpecifier); - BOOST_FOREACH(const auto & i, *map) { - binder(rs, i); - rs.process(boost::bind(&MapIterator::executeChildren, this, ec)); - } - } - - private: - boost::function binder; - const ColumnSpecifier columnSpecifier; - const T * map; - - void executeChildren(ExecContext * ec) const - { - BOOST_FOREACH(const Tasks::value_type & sq, normal) { - sq->execute(ec); - } - } -}; - -#endif - - diff --git a/p2pvr/lib/objectRowState.h b/p2pvr/lib/objectRowState.h deleted file mode 100644 index 9ba69f0..0000000 --- a/p2pvr/lib/objectRowState.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef OBJECT_ROW_STATE_H -#define OBJECT_ROW_STATE_H - -#include -#include -#include - -typedef boost::function ColumnCreator; -typedef boost::function ColumnSpecifier; - -template -void BindColumns(RowState &, const V &); - -template -void UnbindColumns(RowState &, const V &); - -template -void CreateColumns(const ColumnCreator &); - -template -class ObjectRowState : public RowState { - public: - ObjectRowState(const ColumnSpecifier & cs = CreateColumns) : - columns(ColumnCreatorHelper(cs)) - { - fields.resize(columns.size()); - } - const Columns & getColumns() const { return columns; } - - private: - static Columns ColumnCreatorHelper(const ColumnSpecifier & cs) - { - int index = 0; - Columns columns; - cs([&columns, &index](const std::string & name, bool) { - columns.insert(new Column(index++, name)); - }); - return columns; - } - - Columns columns; -}; - -#endif - diff --git a/p2pvr/lib/p2Helpers.cpp b/p2pvr/lib/p2Helpers.cpp deleted file mode 100644 index 0c1fe37..0000000 --- a/p2pvr/lib/p2Helpers.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include "p2Helpers.h" - -template <> -VariableType & -operator<<(VariableType & vt, const Common::DateTime & dt) -{ - vt = boost::posix_time::ptime(boost::gregorian::date(dt.Year, dt.Month, dt.Day), - boost::posix_time::time_duration(dt.Hour, dt.Minute, 0)); - return vt; -} - -template <> -VariableType & -operator>>(VariableType & vt, Common::DateTime & dt) -{ - const boost::posix_time::ptime & date = vt; - dt.Year = date.date().year(); - dt.Month = date.date().month(); - dt.Day = date.date().day(); - dt.Hour = date.time_of_day().hours(); - dt.Minute = date.time_of_day().minutes(); - return vt; -} - -template <> -VariableType & -operator>>(VariableType & vt, short int & v) -{ - v = (int)vt; - return vt; -} diff --git a/p2pvr/lib/p2Helpers.h b/p2pvr/lib/p2Helpers.h deleted file mode 100644 index 7ea56de..0000000 --- a/p2pvr/lib/p2Helpers.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef ICE_P2_HELPERS_H -#define ICE_P2_HELPERS_H - -#include -#include - -template -VariableType & -operator>>(VariableType & vt, T & v) -{ - v = vt.as(); - return vt; -} - -template <> -VariableType & -operator>>(VariableType & vt, Common::DateTime & dt); - -template -VariableType & -operator>>(VariableType & vt, IceUtil::Optional & v) -{ - if (vt.isNull()) { - v = NULL; - } - else { - v = vt.as(); - } - return vt; -} - -template <> -VariableType & -operator>>(VariableType & vt, short int & v); - -template -VariableType & -operator<<(VariableType & vt, const T & v) -{ - vt = v; - return vt; -} - -template <> -VariableType & -operator<<(VariableType & vt, const Common::DateTime & dt); - -template -VariableType & -operator<<(VariableType & vt, const IceUtil::Optional & v) -{ - if (v) { - vt << *v; - } - else { - vt = Null(); - } - return vt; -} - - -#endif - diff --git a/p2pvr/lib/singleIterator.h b/p2pvr/lib/singleIterator.h deleted file mode 100644 index 1aac418..0000000 --- a/p2pvr/lib/singleIterator.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SINGLEITERATOR_H -#define SINGLEITERATOR_H - -#include -#include -#include "objectRowState.h" - -template -class SingleIterator : public IHaveSubTasks { - public: - SingleIterator(const T * i) : - SourceObject(__PRETTY_FUNCTION__), - IHaveSubTasks(NULL), - binder(boost::bind(&BindColumns, _1, _2)), - item(i) - { - } - - void execute(ExecContext * ec) const - { - ObjectRowState rs; - binder(rs, *item); - rs.process(boost::bind(&SingleIterator::executeChildren, this, ec)); - } - - private: - boost::function binder; - const T * item; - - void executeChildren(ExecContext * ec) const - { - BOOST_FOREACH(const Tasks::value_type & sq, normal) { - sq->execute(ec); - } - } -}; - -#endif - diff --git a/p2pvr/util/Jamfile.jam b/p2pvr/util/Jamfile.jam new file mode 100644 index 0000000..84b2654 --- /dev/null +++ b/p2pvr/util/Jamfile.jam @@ -0,0 +1,19 @@ +cpp-pch pch : pch.hpp : + ..//p2common + ..//p2lib + ../ice//p2pvrice +; + +lib p2pvrutil : + pch + [ glob-tree *.cpp ] + ../../libmisc/misc.cpp + : + ..//p2common + ..//p2lib + ../ice//p2pvrice + ../ice//p2pvrice + : : + . + ; + diff --git a/p2pvr/util/containerCreator.h b/p2pvr/util/containerCreator.h new file mode 100644 index 0000000..9804d9b --- /dev/null +++ b/p2pvr/util/containerCreator.h @@ -0,0 +1,33 @@ +#ifndef CONTAINERCREATOR_H +#define CONTAINERCREATOR_H + +#include +#include +#include "objectRowState.h" + +template > +class ContainerCreator { + public: + ContainerCreator(T & c) : container(c) { } + + void populate( + boost::function fetch, + boost::function get, + unsigned int columnCount) + { + while (fetch()) { + auto v = P(new V); + container.push_back(v); + ObjectRowState

rs; + for (unsigned int c = 0; c < columnCount; c++) { + rs.fields[c] = get(c); + } + UnbindColumns

(rs, v); + } + } + private: + T & container; +}; + +#endif + diff --git a/p2pvr/util/containerIterator.h b/p2pvr/util/containerIterator.h new file mode 100644 index 0000000..2b61055 --- /dev/null +++ b/p2pvr/util/containerIterator.h @@ -0,0 +1,41 @@ +#ifndef CONTAINERITERATOR_H +#define CONTAINERITERATOR_H + +#include +#include +#include "objectRowState.h" + +template +class ContainerIterator : public IHaveSubTasks { + public: + ContainerIterator(const T * con) : + SourceObject(__PRETTY_FUNCTION__), + IHaveSubTasks(NULL), + binder(boost::bind(&BindColumns, _1, _2)), + container(con) + { + } + + void execute(ExecContext * ec) const + { + ObjectRowState rs; + BOOST_FOREACH(const auto & i, *container) { + binder(rs, i); + rs.process(boost::bind(&ContainerIterator::executeChildren, this, ec)); + } + } + + private: + boost::function binder; + const T * container; + + void executeChildren(ExecContext * ec) const + { + BOOST_FOREACH(const Tasks::value_type & sq, normal) { + sq->execute(ec); + } + } +}; + +#endif + diff --git a/p2pvr/util/dvbsiHelpers.h b/p2pvr/util/dvbsiHelpers.h new file mode 100644 index 0000000..b8cc1cf --- /dev/null +++ b/p2pvr/util/dvbsiHelpers.h @@ -0,0 +1,23 @@ +#ifndef ICE_DVBSI_HELPERS_H +#define ICE_DVBSI_HELPERS_H + +#include +#include "objectRowState.h" + +#define ColumnHelper(T) \ + template<> void CreateColumns(const ColumnCreator & cc); \ + template<> void BindColumns(RowState & rs, const T & obj); \ + template<> void UnbindColumns(RowState & rs, const T & s) + +ColumnHelper(DVBSI::NetworkPtr); +ColumnHelper(DVBSI::NetworkTransportStreamPtr); +ColumnHelper(DVBSI::NetworkService); +ColumnHelper(DVBSI::TerrestrialDeliveryPtr); +ColumnHelper(DVBSI::CableDeliveryPtr); +ColumnHelper(DVBSI::SatelliteDeliveryPtr); +ColumnHelper(DVBSI::ServicePtr); +ColumnHelper(DVBSI::StreamPtr); +ColumnHelper(DVBSI::EventPtr); + +#endif + diff --git a/p2pvr/util/dvbsiHelpers/cableDelivery.cpp b/p2pvr/util/dvbsiHelpers/cableDelivery.cpp new file mode 100644 index 0000000..7bf9f6d --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/cableDelivery.cpp @@ -0,0 +1,39 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("frequency", false); + cc("transportStreamId", true); + cc("fecOuter", false); + cc("modulation", false); + cc("symbolRate", false); + cc("fecInner", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::CableDeliveryPtr & s) +{ + rs.fields[0] << s->Frequency; + rs.fields[1] << s->TransportStreamId; + rs.fields[2] << s->FecOuter; + rs.fields[3] << s->Modulation; + rs.fields[4] << s->SymbolRate; + rs.fields[5] << s->FecInner; +} +template<> +void +UnbindColumns(RowState & rs, DVBSI::CableDeliveryPtr const & s) +{ + rs.fields[0] >> s->Frequency; + rs.fields[1] >> s->TransportStreamId; + rs.fields[2] >> s->FecOuter; + rs.fields[3] >> s->Modulation; + rs.fields[4] >> s->SymbolRate; + rs.fields[5] >> s->FecInner; +} + diff --git a/p2pvr/util/dvbsiHelpers/event.cpp b/p2pvr/util/dvbsiHelpers/event.cpp new file mode 100644 index 0000000..decd2b9 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/event.cpp @@ -0,0 +1,64 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("serviceId", true); + cc("eventId", true); + cc("title", false); + cc("titleLang", false); + cc("subtitle", false); + cc("description", false); + cc("descriptionLang", false); + cc("videoAspect", false); + cc("videoFrameRate", false); + cc("videoHd", false); + cc("audioChannels", false); + cc("audioLanguage", false); + cc("subtitleLanguage", false); + cc("category", false); + cc("subCategory", false); + cc("userCategory", false); + cc("dvbRating", false); + cc("startTime", false); + cc("stopTime", false); + cc("episode", false); + cc("episodes", false); + cc("year", false); + cc("flags", false); + cc("season", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::EventPtr & e) +{ + rs.fields[0] << e->ServiceId; + rs.fields[1] << e->EventId; + rs.fields[2] << e->Title; + rs.fields[3] << e->TitleLang; + rs.fields[4] << e->Subtitle; + rs.fields[5] << e->Description; + rs.fields[6] << e->DescriptionLang; + rs.fields[7] << e->VideoAspect; + rs.fields[8] << e->VideoFrameRate; + rs.fields[9] << e->VideoHD; + rs.fields[10] << e->AudioChannels; + rs.fields[11] << e->AudioLanguage; + rs.fields[12] << e->SubtitleLanguage; + rs.fields[13] << e->Category; + rs.fields[14] << e->SubCategory; + rs.fields[15] << e->UserCategory; + rs.fields[16] << e->DvbRating; + rs.fields[17] << e->StartTime; + rs.fields[18] << e->StopTime; + rs.fields[19] << e->Episode; + rs.fields[20] << e->Episodes; + rs.fields[21] << e->Year; + rs.fields[22] << e->Flags; + rs.fields[23] << e->Season; +} + diff --git a/p2pvr/util/dvbsiHelpers/network.cpp b/p2pvr/util/dvbsiHelpers/network.cpp new file mode 100644 index 0000000..3b117f1 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/network.cpp @@ -0,0 +1,21 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("networkId", true); + cc("name", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::NetworkPtr & network) +{ + rs.fields[0] << network->NetworkId; + rs.fields[1] << network->Name; +} + + diff --git a/p2pvr/util/dvbsiHelpers/networkService.cpp b/p2pvr/util/dvbsiHelpers/networkService.cpp new file mode 100644 index 0000000..a4a47d5 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/networkService.cpp @@ -0,0 +1,22 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("serviceId", true); + cc("type", false); + cc("transportStreamId", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::NetworkService & s) +{ + rs.fields[0] << s.ServiceId; + rs.fields[1] << s.ServiceType; + rs.fields[2] << s.TransportStreamId; +} + diff --git a/p2pvr/util/dvbsiHelpers/networkTransportStream.cpp b/p2pvr/util/dvbsiHelpers/networkTransportStream.cpp new file mode 100644 index 0000000..bdc7c4f --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/networkTransportStream.cpp @@ -0,0 +1,23 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("transportStreamId", true); + cc("networkId", false); + cc("originalNetworkId", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::NetworkTransportStreamPtr & ts) +{ + rs.fields[0] << ts->TransportStreamId; + rs.fields[1] << ts->NetworkId; + rs.fields[2] << ts->OriginalNetworkId; +} + + diff --git a/p2pvr/util/dvbsiHelpers/programMap.cpp b/p2pvr/util/dvbsiHelpers/programMap.cpp new file mode 100644 index 0000000..d8cf400 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/programMap.cpp @@ -0,0 +1,24 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("serviceId", true); + cc("id", true); + cc("type", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::StreamPtr & stream) +{ + rs.fields[0] << stream->ServiceId; + rs.fields[1] << stream->Id; + rs.fields[2] << stream->Type; +} + + + diff --git a/p2pvr/util/dvbsiHelpers/satelliteDelivery.cpp b/p2pvr/util/dvbsiHelpers/satelliteDelivery.cpp new file mode 100644 index 0000000..8231fc3 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/satelliteDelivery.cpp @@ -0,0 +1,51 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("frequency", false); + cc("transportStreamId", true); + cc("orbitalPosition", false); + cc("westEastFlag", false); + cc("polarization", false); + cc("rollOff", false); + cc("modulationSystem", false); + cc("modulationType", false); + cc("symbolRate", false); + cc("fecInner", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::SatelliteDeliveryPtr & s) +{ + rs.fields[0] << s->Frequency; + rs.fields[1] << s->TransportStreamId; + rs.fields[2] << s->OrbitalPosition; + rs.fields[3] << s->WestEastFlag; + rs.fields[4] << s->Polarization; + rs.fields[5] << s->RollOff; + rs.fields[6] << s->ModulationSystem; + rs.fields[7] << s->ModulationType; + rs.fields[8] << s->SymbolRate; + rs.fields[9] << s->FecInner; +} +template<> +void +UnbindColumns(RowState & rs, DVBSI::SatelliteDeliveryPtr const & s) +{ + rs.fields[0] >> s->Frequency; + rs.fields[1] << s->TransportStreamId; + rs.fields[2] >> s->OrbitalPosition; + rs.fields[3] >> s->WestEastFlag; + rs.fields[4] >> s->Polarization; + rs.fields[5] >> s->RollOff; + rs.fields[6] >> s->ModulationSystem; + rs.fields[7] >> s->ModulationType; + rs.fields[8] >> s->SymbolRate; + rs.fields[9] >> s->FecInner; +} + diff --git a/p2pvr/util/dvbsiHelpers/service.cpp b/p2pvr/util/dvbsiHelpers/service.cpp new file mode 100644 index 0000000..9f82d91 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/service.cpp @@ -0,0 +1,49 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("serviceId", true); + cc("transportStreamId", true); + cc("name", false); + cc("providerName", false); + cc("defaultAuthority", false); + cc("runningStatus", false); + cc("eitSchedule", false); + cc("eitPresentFollowing", false); + cc("freeCAMode", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::ServicePtr & s) +{ + rs.fields[0] << s->ServiceId; + rs.fields[1] << s->TransportStreamId; + rs.fields[2] << s->Name; + rs.fields[3] << s->ProviderName; + rs.fields[4] << s->DefaultAuthority; + rs.fields[5] << s->RunningStatus; + rs.fields[6] << s->EitSchedule; + rs.fields[7] << s->EitPresentFollowing; + rs.fields[8] << s->FreeCaMode; +} + +template<> +void +UnbindColumns(RowState & rs, DVBSI::ServicePtr const & s) +{ + rs.fields[0] >> s->ServiceId; + rs.fields[1] >> s->TransportStreamId; + rs.fields[2] >> s->Name; + rs.fields[3] >> s->ProviderName; + rs.fields[4] >> s->DefaultAuthority; + rs.fields[5] >> s->RunningStatus; + rs.fields[6] >> s->EitSchedule; + rs.fields[7] >> s->EitPresentFollowing; + rs.fields[8] >> s->FreeCaMode; +} + diff --git a/p2pvr/util/dvbsiHelpers/terrestrialDelivery.cpp b/p2pvr/util/dvbsiHelpers/terrestrialDelivery.cpp new file mode 100644 index 0000000..46e60f9 --- /dev/null +++ b/p2pvr/util/dvbsiHelpers/terrestrialDelivery.cpp @@ -0,0 +1,59 @@ +#include +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns(const ColumnCreator & cc) +{ + cc("frequency", false); + cc("transportStreamId", true); + cc("bandwidth", false); + cc("priority", false); + cc("timeSlicing", false); + cc("mpeFec", false); + cc("constellation", false); + cc("hierarchy", false); + cc("codeRateHP", false); + cc("codeRateLP", false); + cc("guardInterval", false); + cc("transmissionMode", false); + cc("otherFrequencyFlag", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::TerrestrialDeliveryPtr & s) +{ + rs.fields[0] << s->Frequency; + rs.fields[1] << s->TransportStreamId; + rs.fields[2] << s->Bandwidth; + rs.fields[3] << s->Priority; + rs.fields[4] << s->TimeSlicing; + rs.fields[5] << s->MpeFec; + rs.fields[6] << s->Constellation; + rs.fields[7] << s->Hierarchy; + rs.fields[8] << s->CodeRateHP; + rs.fields[9] << s->CodeRateLP; + rs.fields[10] << s->GuardInterval; + rs.fields[11] << s->TransmissionMode; + rs.fields[12] << s->OtherFrequencyFlag; +} +template<> +void +UnbindColumns(RowState & rs, DVBSI::TerrestrialDeliveryPtr const & s) +{ + rs.fields[0] >> s->Frequency; + rs.fields[2] >> s->Bandwidth; + rs.fields[3] >> s->Priority; + rs.fields[4] >> s->TimeSlicing; + rs.fields[5] >> s->MpeFec; + rs.fields[6] >> s->Constellation; + rs.fields[7] >> s->Hierarchy; + rs.fields[8] >> s->CodeRateHP; + rs.fields[9] >> s->CodeRateLP; + rs.fields[10] >> s->GuardInterval; + rs.fields[11] >> s->TransmissionMode; + rs.fields[12] >> s->OtherFrequencyFlag; +} + diff --git a/p2pvr/util/fileHandle.cpp b/p2pvr/util/fileHandle.cpp new file mode 100644 index 0000000..b85d390 --- /dev/null +++ b/p2pvr/util/fileHandle.cpp @@ -0,0 +1,28 @@ +#include +#include "fileHandle.h" +#include +#include + +class InvalidFileHandle : public std::runtime_error { + public: + InvalidFileHandle() : std::runtime_error("Invalid file handle") { } +}; + +FileHandle::FileHandle(int f) : + fd(f) +{ + if (fd < 0) { + throw InvalidFileHandle(); + } +} + +FileHandle::~FileHandle() +{ + close(fd); +} + +FileHandle::operator int() const +{ + return fd; +} + diff --git a/p2pvr/util/fileHandle.h b/p2pvr/util/fileHandle.h new file mode 100644 index 0000000..3c8d45e --- /dev/null +++ b/p2pvr/util/fileHandle.h @@ -0,0 +1,19 @@ +#ifndef FILEHANDLE_H +#define FILEHANDLE_H + +class FileHandle { + public: + FileHandle(int fd); + ~FileHandle(); + + FileHandle(const FileHandle &) = delete; + void operator=(const FileHandle &) = delete; + + operator int() const; + + private: + const int fd; +}; + +#endif + diff --git a/p2pvr/util/mapIterator.cpp b/p2pvr/util/mapIterator.cpp new file mode 100644 index 0000000..157669a --- /dev/null +++ b/p2pvr/util/mapIterator.cpp @@ -0,0 +1,11 @@ +#include +#include "mapIterator.h" +#include "p2Helpers.h" + +template<> +void BindColumns>(RowState & rs, std::pair const & p) +{ + rs.fields[0] << p.first; + rs.fields[1] << p.second; +} + diff --git a/p2pvr/util/mapIterator.h b/p2pvr/util/mapIterator.h new file mode 100644 index 0000000..8a06fe6 --- /dev/null +++ b/p2pvr/util/mapIterator.h @@ -0,0 +1,45 @@ +#ifndef MAPITERATOR_H +#define MAPITERATOR_H + +#include +#include +#include "objectRowState.h" + +template +class MapIterator : public IHaveSubTasks { + public: + template + MapIterator(const ColumnSpecifier & cs, const T * m, const Parents & ... p) : + SourceObject(__PRETTY_FUNCTION__), + IHaveSubTasks(NULL), + binder(boost::bind(&BindColumns, _1, _2, p...)), + columnSpecifier(cs), + map(m) + { + } + + void execute(ExecContext * ec) const + { + ObjectRowState rs(columnSpecifier); + BOOST_FOREACH(const auto & i, *map) { + binder(rs, i); + rs.process(boost::bind(&MapIterator::executeChildren, this, ec)); + } + } + + private: + boost::function binder; + const ColumnSpecifier columnSpecifier; + const T * map; + + void executeChildren(ExecContext * ec) const + { + BOOST_FOREACH(const Tasks::value_type & sq, normal) { + sq->execute(ec); + } + } +}; + +#endif + + diff --git a/p2pvr/util/objectRowState.h b/p2pvr/util/objectRowState.h new file mode 100644 index 0000000..9ba69f0 --- /dev/null +++ b/p2pvr/util/objectRowState.h @@ -0,0 +1,45 @@ +#ifndef OBJECT_ROW_STATE_H +#define OBJECT_ROW_STATE_H + +#include +#include +#include + +typedef boost::function ColumnCreator; +typedef boost::function ColumnSpecifier; + +template +void BindColumns(RowState &, const V &); + +template +void UnbindColumns(RowState &, const V &); + +template +void CreateColumns(const ColumnCreator &); + +template +class ObjectRowState : public RowState { + public: + ObjectRowState(const ColumnSpecifier & cs = CreateColumns) : + columns(ColumnCreatorHelper(cs)) + { + fields.resize(columns.size()); + } + const Columns & getColumns() const { return columns; } + + private: + static Columns ColumnCreatorHelper(const ColumnSpecifier & cs) + { + int index = 0; + Columns columns; + cs([&columns, &index](const std::string & name, bool) { + columns.insert(new Column(index++, name)); + }); + return columns; + } + + Columns columns; +}; + +#endif + diff --git a/p2pvr/util/p2Helpers.cpp b/p2pvr/util/p2Helpers.cpp new file mode 100644 index 0000000..0c1fe37 --- /dev/null +++ b/p2pvr/util/p2Helpers.cpp @@ -0,0 +1,32 @@ +#include +#include "p2Helpers.h" + +template <> +VariableType & +operator<<(VariableType & vt, const Common::DateTime & dt) +{ + vt = boost::posix_time::ptime(boost::gregorian::date(dt.Year, dt.Month, dt.Day), + boost::posix_time::time_duration(dt.Hour, dt.Minute, 0)); + return vt; +} + +template <> +VariableType & +operator>>(VariableType & vt, Common::DateTime & dt) +{ + const boost::posix_time::ptime & date = vt; + dt.Year = date.date().year(); + dt.Month = date.date().month(); + dt.Day = date.date().day(); + dt.Hour = date.time_of_day().hours(); + dt.Minute = date.time_of_day().minutes(); + return vt; +} + +template <> +VariableType & +operator>>(VariableType & vt, short int & v) +{ + v = (int)vt; + return vt; +} diff --git a/p2pvr/util/p2Helpers.h b/p2pvr/util/p2Helpers.h new file mode 100644 index 0000000..7ea56de --- /dev/null +++ b/p2pvr/util/p2Helpers.h @@ -0,0 +1,63 @@ +#ifndef ICE_P2_HELPERS_H +#define ICE_P2_HELPERS_H + +#include +#include + +template +VariableType & +operator>>(VariableType & vt, T & v) +{ + v = vt.as(); + return vt; +} + +template <> +VariableType & +operator>>(VariableType & vt, Common::DateTime & dt); + +template +VariableType & +operator>>(VariableType & vt, IceUtil::Optional & v) +{ + if (vt.isNull()) { + v = NULL; + } + else { + v = vt.as(); + } + return vt; +} + +template <> +VariableType & +operator>>(VariableType & vt, short int & v); + +template +VariableType & +operator<<(VariableType & vt, const T & v) +{ + vt = v; + return vt; +} + +template <> +VariableType & +operator<<(VariableType & vt, const Common::DateTime & dt); + +template +VariableType & +operator<<(VariableType & vt, const IceUtil::Optional & v) +{ + if (v) { + vt << *v; + } + else { + vt = Null(); + } + return vt; +} + + +#endif + diff --git a/p2pvr/util/pch.hpp b/p2pvr/util/pch.hpp new file mode 100644 index 0000000..dafc462 --- /dev/null +++ b/p2pvr/util/pch.hpp @@ -0,0 +1,23 @@ +#ifdef BOOST_BUILD_PCH_ENABLED +#ifndef P2PVRUTIL_PCH +#define P2PVRUTIL_PCH + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#endif +#endif + + diff --git a/p2pvr/util/singleIterator.h b/p2pvr/util/singleIterator.h new file mode 100644 index 0000000..1aac418 --- /dev/null +++ b/p2pvr/util/singleIterator.h @@ -0,0 +1,39 @@ +#ifndef SINGLEITERATOR_H +#define SINGLEITERATOR_H + +#include +#include +#include "objectRowState.h" + +template +class SingleIterator : public IHaveSubTasks { + public: + SingleIterator(const T * i) : + SourceObject(__PRETTY_FUNCTION__), + IHaveSubTasks(NULL), + binder(boost::bind(&BindColumns, _1, _2)), + item(i) + { + } + + void execute(ExecContext * ec) const + { + ObjectRowState rs; + binder(rs, *item); + rs.process(boost::bind(&SingleIterator::executeChildren, this, ec)); + } + + private: + boost::function binder; + const T * item; + + void executeChildren(ExecContext * ec) const + { + BOOST_FOREACH(const Tasks::value_type & sq, normal) { + sq->execute(ec); + } + } +}; + +#endif + -- cgit v1.2.3