diff options
author | randomdan <randomdan@localhost> | 2013-11-30 15:48:48 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2013-11-30 15:48:48 +0000 |
commit | 78a3d07fce8a04c20d0b0408da299095be3a585e (patch) | |
tree | 19172cc8ea18f0e82cf14fc4ad9e248a74762b76 | |
parent | First commit for big refactor into a Project2 daemon, much still to do, but m... (diff) | |
download | p2pvr-78a3d07fce8a04c20d0b0408da299095be3a585e.tar.bz2 p2pvr-78a3d07fce8a04c20d0b0408da299095be3a585e.tar.xz p2pvr-78a3d07fce8a04c20d0b0408da299095be3a585e.zip |
Bit of refactor and tidy up
-rw-r--r-- | p2pvr/ice/p2pvr.ice | 2 | ||||
-rw-r--r-- | p2pvr/lib/containerCreator.h | 3 | ||||
-rw-r--r-- | p2pvr/lib/containerIterator.h | 1 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers.cpp | 190 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers.h | 69 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/cableDelivery.cpp | 37 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/event.cpp | 61 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/network.cpp | 20 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/networkService.cpp | 21 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp | 22 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp | 49 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/service.cpp | 35 | ||||
-rw-r--r-- | p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp | 58 | ||||
-rw-r--r-- | p2pvr/lib/objectRowState.h | 3 | ||||
-rw-r--r-- | p2pvr/lib/p2Helpers.h | 15 | ||||
-rw-r--r-- | p2pvr/lib/si.cpp | 46 | ||||
-rw-r--r-- | p2pvr/lib/si.h | 1 | ||||
-rw-r--r-- | p2pvr/lib/singleIterator.h | 1 | ||||
-rw-r--r-- | p2pvr/lib/sqlContainerCreator.h | 28 |
19 files changed, 404 insertions, 258 deletions
diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 250cc37..62c58ca 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -243,6 +243,8 @@ module P2PVR { interface SI { // Get any delivery suitable for SI reading idempotent Deliveries GetAllDeliveries(short type); + // Get a list of services + idempotent DVBSI::ServiceList GetServices(); }; }; diff --git a/p2pvr/lib/containerCreator.h b/p2pvr/lib/containerCreator.h index aed2479..da4eced 100644 --- a/p2pvr/lib/containerCreator.h +++ b/p2pvr/lib/containerCreator.h @@ -11,13 +11,12 @@ class ContainerCreator { void populate( boost::function<bool()> fetch, boost::function<VariableType(unsigned int)> get, - boost::function<unsigned int()> columns) + unsigned int columnCount) { while (fetch()) { auto v = new V; container.push_back(v); ObjectRowState<IceInternal::Handle<V>> rs; - const auto columnCount = columns(); for (unsigned int c = 0; c < columnCount; c++) { rs.fields[c] = get(c); } diff --git a/p2pvr/lib/containerIterator.h b/p2pvr/lib/containerIterator.h index 1c4e6bf..6c43a41 100644 --- a/p2pvr/lib/containerIterator.h +++ b/p2pvr/lib/containerIterator.h @@ -16,6 +16,7 @@ class ContainerIterator : public IHaveSubTasks { container(con) { } + void execute(ExecContext * ec) const { ObjectRowState<typename T::value_type> rs; diff --git a/p2pvr/lib/dvbsiHelpers.cpp b/p2pvr/lib/dvbsiHelpers.cpp deleted file mode 100644 index 3dcbdcc..0000000 --- a/p2pvr/lib/dvbsiHelpers.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "dvbsiHelpers.h" -#include "p2Helpers.h" - -template<> -void -CreateColumns<DVBSI::NetworkPtr>(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; -} - -template<> -void -CreateColumns<DVBSI::NetworkTransportStreamPtr>(const ColumnCreator & cc) -{ - cc("transportStreamId", true); - cc("networkId", false); - cc("originalNetworkId", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkTransportStreamPtr & ts, const DVBSI::NetworkPtr & network) -{ - rs.fields[0] << ts->TransportStreamId; - rs.fields[1] << network->NetworkId; - rs.fields[2] << ts->OriginalNetworkId; -} - -template<> -void -CreateColumns<DVBSI::NetworkService>(const ColumnCreator & cc) -{ - cc("serviceId", true); - cc("type", false); - cc("transportStreamId", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkService & s, const DVBSI::NetworkTransportStreamPtr & ts) -{ - rs.fields[0] << s.ServiceId; - rs.fields[1] << s.ServiceType; - rs.fields[2] << ts->TransportStreamId; -} - -template<> -void -CreateColumns<DVBSI::ServicePtr>(const ColumnCreator & cc) -{ - cc("serviceId", true); - cc("transportStreamId", true); - cc("name", false); - cc("providerName", false); - cc("defaultAuthority", false); -} - -template<> -void -BindColumns(RowState & rs, const DVBSI::ServicePtr & s, const DVBSI::TransportStreamPtr & ts) -{ - rs.fields[0] << s->ServiceId; - rs.fields[1] << ts->TransportStreamId; - rs.fields[2] << s->Name; - rs.fields[4] << s->ProviderName; - rs.fields[4] << s->DefaultAuthority; -} - -template<> -void -CreateColumns<DVBSI::EventPtr>(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); -} - -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; -} - -template<> -void -CreateColumns<DVBSI::TerrestrialDeliveryPtr>(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, const DVBSI::NetworkTransportStreamPtr & ts) -{ - rs.fields[0] << s->Frequency; - rs.fields[1] << ts->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/dvbsiHelpers.h b/p2pvr/lib/dvbsiHelpers.h index 49cb404..bf0de82 100644 --- a/p2pvr/lib/dvbsiHelpers.h +++ b/p2pvr/lib/dvbsiHelpers.h @@ -4,57 +4,24 @@ #include <p2pvr.h> #include "objectRowState.h" -template<> -void -CreateColumns<DVBSI::NetworkPtr>(const ColumnCreator & cc); - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkPtr & network); - -template<> -void -CreateColumns<DVBSI::NetworkTransportStreamPtr>(const ColumnCreator & cc); - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkTransportStreamPtr & ts, const DVBSI::NetworkPtr & network); - -template<> -void -CreateColumns<DVBSI::NetworkService>(const ColumnCreator & cc); - -template<> -void -BindColumns(RowState & rs, const DVBSI::NetworkService & s, const DVBSI::NetworkTransportStreamPtr & ts); - -template<> -void -CreateColumns<DVBSI::ServicePtr>(const ColumnCreator & cc); - -template<> -void -BindColumns(RowState & rs, const DVBSI::ServicePtr & s, const DVBSI::TransportStreamPtr & ts); - -template<> -void -CreateColumns<DVBSI::EventPtr>(const ColumnCreator & cc); - -template<> -void -BindColumns(RowState & rs, const DVBSI::EventPtr & e); - -template<> -void -CreateColumns<DVBSI::TerrestrialDeliveryPtr>(const ColumnCreator & cc); - -template<> -void -BindColumns(RowState & rs, const DVBSI::TerrestrialDeliveryPtr & e, const DVBSI::TransportStreamPtr & ts); - -template<> -void -UnbindColumns(RowState & rs, const DVBSI::TerrestrialDeliveryPtr & s); +#define ColumnHelper(T) \ + template<> void CreateColumns<T>(const ColumnCreator & cc); \ + template<> void BindColumns(RowState & rs, const T & obj); \ + template<> void UnbindColumns(RowState & rs, const T & s) + +#define ColumnHelperParent(T, P) \ + template<> void CreateColumns<T>(const ColumnCreator & cc); \ + template<> void BindColumns(RowState & rs, const T & obj, const P & parent); \ + template<> void UnbindColumns(RowState & rs, const T & s) + +ColumnHelper(DVBSI::NetworkPtr); +ColumnHelperParent(DVBSI::NetworkTransportStreamPtr, DVBSI::NetworkPtr); +ColumnHelperParent(DVBSI::NetworkService, DVBSI::NetworkTransportStreamPtr); +ColumnHelperParent(DVBSI::TerrestrialDeliveryPtr, DVBSI::TransportStreamPtr); +ColumnHelperParent(DVBSI::CableDeliveryPtr, DVBSI::TransportStreamPtr); +ColumnHelperParent(DVBSI::SatelliteDeliveryPtr, DVBSI::TransportStreamPtr); +ColumnHelperParent(DVBSI::ServicePtr, DVBSI::TransportStreamPtr); +ColumnHelper(DVBSI::EventPtr); #endif diff --git a/p2pvr/lib/dvbsiHelpers/cableDelivery.cpp b/p2pvr/lib/dvbsiHelpers/cableDelivery.cpp new file mode 100644 index 0000000..a550de7 --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/cableDelivery.cpp @@ -0,0 +1,37 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::CableDeliveryPtr>(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, const DVBSI::NetworkTransportStreamPtr & ts) +{ + rs.fields[0] << s->Frequency; + rs.fields[1] << ts->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[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 new file mode 100644 index 0000000..d5ea1d4 --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/event.cpp @@ -0,0 +1,61 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::EventPtr>(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); +} + +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; +} + diff --git a/p2pvr/lib/dvbsiHelpers/network.cpp b/p2pvr/lib/dvbsiHelpers/network.cpp new file mode 100644 index 0000000..eeda8db --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/network.cpp @@ -0,0 +1,20 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::NetworkPtr>(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 new file mode 100644 index 0000000..60b357a --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/networkService.cpp @@ -0,0 +1,21 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::NetworkService>(const ColumnCreator & cc) +{ + cc("serviceId", true); + cc("type", false); + cc("transportStreamId", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::NetworkService & s, const DVBSI::NetworkTransportStreamPtr & ts) +{ + rs.fields[0] << s.ServiceId; + rs.fields[1] << s.ServiceType; + rs.fields[2] << ts->TransportStreamId; +} + diff --git a/p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp b/p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp new file mode 100644 index 0000000..884a7db --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/networkTransportStream.cpp @@ -0,0 +1,22 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::NetworkTransportStreamPtr>(const ColumnCreator & cc) +{ + cc("transportStreamId", true); + cc("networkId", false); + cc("originalNetworkId", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::NetworkTransportStreamPtr & ts, const DVBSI::NetworkPtr & network) +{ + rs.fields[0] << ts->TransportStreamId; + rs.fields[1] << network->NetworkId; + rs.fields[2] << ts->OriginalNetworkId; +} + + diff --git a/p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp b/p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp new file mode 100644 index 0000000..a8d6f1a --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/satelliteDelivery.cpp @@ -0,0 +1,49 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::SatelliteDeliveryPtr>(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, const DVBSI::NetworkTransportStreamPtr & ts) +{ + rs.fields[0] << s->Frequency; + rs.fields[1] << ts->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[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 new file mode 100644 index 0000000..dfc03be --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/service.cpp @@ -0,0 +1,35 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::ServicePtr>(const ColumnCreator & cc) +{ + cc("serviceId", true); + cc("transportStreamId", true); + cc("name", false); + cc("providerName", false); + cc("defaultAuthority", false); +} + +template<> +void +BindColumns(RowState & rs, const DVBSI::ServicePtr & s, const DVBSI::TransportStreamPtr & ts) +{ + rs.fields[0] << s->ServiceId; + rs.fields[1] << ts->TransportStreamId; + rs.fields[2] << s->Name; + rs.fields[4] << s->ProviderName; + rs.fields[4] << s->DefaultAuthority; +} + +template<> +void +UnbindColumns(RowState & rs, DVBSI::ServicePtr const & s) +{ + rs.fields[0] >> s->ServiceId; + rs.fields[0] >> s->Name; + rs.fields[0] >> s->ProviderName; + rs.fields[0] >> s->DefaultAuthority; +} + diff --git a/p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp b/p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp new file mode 100644 index 0000000..dfacd01 --- /dev/null +++ b/p2pvr/lib/dvbsiHelpers/terrestrialDelivery.cpp @@ -0,0 +1,58 @@ +#include "../dvbsiHelpers.h" +#include "../p2Helpers.h" + +template<> +void +CreateColumns<DVBSI::TerrestrialDeliveryPtr>(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, const DVBSI::NetworkTransportStreamPtr & ts) +{ + rs.fields[0] << s->Frequency; + rs.fields[1] << ts->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/objectRowState.h b/p2pvr/lib/objectRowState.h index 9d53d43..945ea89 100644 --- a/p2pvr/lib/objectRowState.h +++ b/p2pvr/lib/objectRowState.h @@ -27,7 +27,7 @@ class ObjectRowState : public RowState { const Columns & getColumns() const { return columns; } private: - Columns ColumnCreatorHelper() + static Columns ColumnCreatorHelper() { int index = 0; Columns columns; @@ -36,6 +36,7 @@ class ObjectRowState : public RowState { }); return columns; } + Columns columns; }; diff --git a/p2pvr/lib/p2Helpers.h b/p2pvr/lib/p2Helpers.h index 7f2f577..ac88de1 100644 --- a/p2pvr/lib/p2Helpers.h +++ b/p2pvr/lib/p2Helpers.h @@ -8,7 +8,20 @@ template <typename T> VariableType & operator>>(VariableType & vt, T & v) { - v = vt; + v = vt.as<T>(); + return vt; +} + +template <typename T> +VariableType & +operator>>(VariableType & vt, IceUtil::Optional<T> & v) +{ + if (!vt.isNull()) { + v = NULL; + } + else { + v = vt.as<T>(); + } return vt; } diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp index 45fa793..032220e 100644 --- a/p2pvr/lib/si.cpp +++ b/p2pvr/lib/si.cpp @@ -1,9 +1,8 @@ #include "si.h" #include "dvbsiHelpers.h" -#include "containerCreator.h" +#include "sqlContainerCreator.h" #include <linux/dvb/frontend.h> #include <rdbmsDataSource.h> -#include <sqlHandleAsVariableType.h> #include <selectcommand.h> #include <logger.h> @@ -13,21 +12,42 @@ P2PVR::Deliveries SI::GetAllDeliveries(short type, const Ice::Current &) { auto db = dataSource<RdbmsDataSource>("postgres"); + Logger()->messagebf(LOG_DEBUG, "%s(type %d)", __PRETTY_FUNCTION__, type); + P2PVR::Deliveries rtn; SelectPtr sel; switch (type) { case FE_OFDM: - sel = SelectPtr(db->getReadonly().newSelectCommand("SELECT * FROM delivery_dvbt")); - break; + { + SqlContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cc(rtn); + sel = SelectPtr(db->getReadonly().newSelectCommand("SELECT * FROM delivery_dvbt")); + cc.populate(sel); + break; + } + case FE_QAM: + { + SqlContainerCreator<P2PVR::Deliveries, DVBSI::CableDelivery> cc(rtn); + sel = SelectPtr(db->getReadonly().newSelectCommand("SELECT * FROM delivery_dvbc")); + cc.populate(sel); + break; + } + case FE_QPSK: + { + SqlContainerCreator<P2PVR::Deliveries, DVBSI::SatelliteDelivery> cc(rtn); + sel = SelectPtr(db->getReadonly().newSelectCommand("SELECT * FROM delivery_dvbs")); + cc.populate(sel); + break; + } } - Logger()->messagebf(LOG_DEBUG, "%s: ", __PRETTY_FUNCTION__); - P2PVR::Deliveries rtn; - ContainerCreator<P2PVR::Deliveries, DVBSI::TerrestrialDelivery> cc(rtn); - cc.populate(boost::bind(&DB::SelectCommand::fetch, sel), [sel](unsigned int c) { - HandleAsVariableType h; - const DB::Column & col = (*sel)[c]; - col.apply(h); - return h.variable; - }, boost::bind(&DB::SelectCommand::columnCount, sel)); + Logger()->messagebf(LOG_DEBUG, "%s: Found %d delivery methods", __PRETTY_FUNCTION__, rtn.size()); return rtn; } +DVBSI::ServiceList +SI::GetServices(const Ice::Current&) +{ + auto db = dataSource<RdbmsDataSource>("postgres"); + DVBSI::ServiceList rtn; + SqlContainerCreator<DVBSI::ServiceList, DVBSI::Service> cc(rtn); + cc.populate(SelectPtr(db->getReadonly().newSelectCommand("SELECT * FROM services ORDER BY serviceId"))); + return rtn; +} diff --git a/p2pvr/lib/si.h b/p2pvr/lib/si.h index 2740c8e..5530125 100644 --- a/p2pvr/lib/si.h +++ b/p2pvr/lib/si.h @@ -7,6 +7,7 @@ class SI : public P2PVR::SI, public virtual CommonObjects { public: P2PVR::Deliveries GetAllDeliveries(short type, const Ice::Current&); + DVBSI::ServiceList GetServices(const Ice::Current&); }; #endif diff --git a/p2pvr/lib/singleIterator.h b/p2pvr/lib/singleIterator.h index 232ad91..c8b9a1e 100644 --- a/p2pvr/lib/singleIterator.h +++ b/p2pvr/lib/singleIterator.h @@ -16,6 +16,7 @@ class SingleIterator : public IHaveSubTasks { item(i) { } + void execute(ExecContext * ec) const { ObjectRowState<T> rs; diff --git a/p2pvr/lib/sqlContainerCreator.h b/p2pvr/lib/sqlContainerCreator.h new file mode 100644 index 0000000..896a6de --- /dev/null +++ b/p2pvr/lib/sqlContainerCreator.h @@ -0,0 +1,28 @@ +#ifndef SQLCONTAINERCREATOR_H +#define SQLCONTAINERCREATOR_H + +#include "containerCreator.h" +#include <boost/shared_ptr.hpp> +#include <selectcommand.h> +#include <sqlHandleAsVariableType.h> + +template <typename T, typename V> +class SqlContainerCreator : public ContainerCreator<T, V> { + public: + SqlContainerCreator(T & c) : ContainerCreator<T, V>(c) { } + + void populate(boost::shared_ptr<DB::SelectCommand> sel) + { + sel->execute(); + ContainerCreator<T, V>::populate(boost::bind(&DB::SelectCommand::fetch, sel), [sel](unsigned int c) { + HandleAsVariableType h; + const DB::Column & col = (*sel)[c]; + col.apply(h); + return h.variable; + }, sel->columnCount()); + } +}; + + +#endif + |