From a45927691e40de464bcdcca0f89e3f40ee9be38f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 23 Oct 2015 21:36:36 +0100 Subject: Use Slicer-DB to replace our own sqlSelectDeserializer --- p2pvr/daemon/Jamfile.jam | 2 + p2pvr/daemon/recordings.cpp | 4 +- p2pvr/daemon/schedules.cpp | 10 +- p2pvr/daemon/si.cpp | 37 ++--- p2pvr/daemon/sqlSelectDeserializer.cpp | 176 --------------------- p2pvr/daemon/sqlSelectDeserializer.h | 28 ---- p2pvr/daemon/unittests/Jamfile.jam | 1 + p2pvr/daemon/unittests/testMaint.cpp | 2 +- p2pvr/daemon/unittests/testRecording.cpp | 2 +- .../daemon/unittests/testSqlSelectDeserializer.cpp | 10 +- 10 files changed, 36 insertions(+), 236 deletions(-) delete mode 100644 p2pvr/daemon/sqlSelectDeserializer.cpp delete mode 100644 p2pvr/daemon/sqlSelectDeserializer.h diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam index c565234..369e714 100644 --- a/p2pvr/daemon/Jamfile.jam +++ b/p2pvr/daemon/Jamfile.jam @@ -1,4 +1,5 @@ lib slicer : : slicer : : /usr/include/slicer ; +lib slicer-db : : slicer-db : : /usr/include/slicer ; cpp-pch pch : pch.hpp : ../ice//p2pvrice @@ -24,6 +25,7 @@ lib p2pvrdaemon : ..//adhocutil ../../libtmdb//tmdb slicer + slicer-db yes . : : diff --git a/p2pvr/daemon/recordings.cpp b/p2pvr/daemon/recordings.cpp index 9b79d60..4a3e6d2 100644 --- a/p2pvr/daemon/recordings.cpp +++ b/p2pvr/daemon/recordings.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "sqlSelectDeserializer.h" +#include ResourceString(Recording_Insert, sql_Recordings_insert); ResourceString(Recording_InsertNewId, sql_Recordings_insertNewId); @@ -47,7 +47,7 @@ P2PVR::RecordingList Recordings::GetRecordings(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(Recording_GetAll).second); } diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 40d7863..19d277f 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -11,7 +11,7 @@ #include "resources.h" #include #include -#include "sqlSelectDeserializer.h" +#include #include #include #include @@ -193,7 +193,7 @@ Schedules::DoReschedule(const Ice::Current & ice) unsigned int tunerCount = devs->TunerCount(); // Load list from database - auto episodes = Slicer::DeserializeAny( + auto episodes = Slicer::DeserializeAny( *Select(Schedules_getCandidates).second); Episodes scheduleList; @@ -309,7 +309,7 @@ P2PVR::ScheduleList Schedules::GetSchedules(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(Schedules_selectAll).second); } @@ -317,7 +317,7 @@ P2PVR::SchedulePtr Schedules::GetSchedule(int id, const Ice::Current &) { Logger()->messagebf(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - auto schedules = Slicer::DeserializeAny( + auto schedules = Slicer::DeserializeAny( *Select(Schedules_selectById, id).second); if (schedules.empty()) throw P2PVR::NotFound(); return schedules.front(); @@ -327,7 +327,7 @@ P2PVR::ScheduledToRecordList Schedules::GetScheduledToRecord(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(Schedules_scheduledToRecord).second); } diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp index 9164a62..d511c47 100644 --- a/p2pvr/daemon/si.cpp +++ b/p2pvr/daemon/si.cpp @@ -1,7 +1,8 @@ #include #include "si.h" #include "resources.h" -#include "sqlSelectDeserializer.h" +#include +#include #include "commonHelpers.h" #include #include @@ -25,7 +26,7 @@ DVBSI::Networks SI::GetNetworks(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_allNetworks).second); } @@ -33,7 +34,7 @@ P2PVR::Deliveries SI::GetAllDeliveries(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - auto rtn = Slicer::DeserializeAny( + auto rtn = Slicer::DeserializeAny( *Select(SI_allDeliveries).second, "delivery_type"); Logger()->messagebf(LOG_DEBUG, "%s: Found %d delivery methods", __PRETTY_FUNCTION__, rtn.size()); return rtn; @@ -44,10 +45,10 @@ SI::GetDeliveryForTransport(int id, const Ice::Current&) { try { Logger()->messagef(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_deliveryForTransport, id).second, "delivery_type"); } - catch (const NoRowsReturned &) { + catch (const Slicer::NoRowsReturned &) { throw P2PVR::NotFound(); } } @@ -57,10 +58,10 @@ SI::GetDeliveryForSi(const Ice::Current&) { try { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_serviceNextUsed).second, "delivery_type"); } - catch (const NoRowsReturned &) { + catch (const Slicer::NoRowsReturned &) { return NULL; } } @@ -70,10 +71,10 @@ SI::GetDeliveryForService(int id, const Ice::Current&) { try { Logger()->messagef(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_deliveryForService, id).second, "delivery_type"); } - catch (const NoRowsReturned &) { + catch (const Slicer::NoRowsReturned &) { throw P2PVR::NotFound(); } } @@ -82,7 +83,7 @@ DVBSI::ServiceList SI::GetServices(const Ice::Current&) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_servicesSelectAll).second); } @@ -90,7 +91,7 @@ DVBSI::ServicePtr SI::GetService(int id, const Ice::Current&) { Logger()->messagef(LOG_DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id); - auto rtn = Slicer::DeserializeAny( + auto rtn = Slicer::DeserializeAny( *Select(SI_servicesSelectById, id).second); if (rtn.empty()) throw P2PVR::NotFound(); return rtn.front(); @@ -102,7 +103,7 @@ SI::GetEvents(const P2PVR::IntSequence & eventUids, const Ice::Current &) Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); P2PVR::Events rtn; for (const auto & uid : eventUids) { - auto list = Slicer::DeserializeAny( + auto list = Slicer::DeserializeAny( *Select(SI_eventByUid, uid).second); std::copy(list.begin(), list.end(), std::back_inserter(rtn)); } @@ -114,7 +115,7 @@ P2PVR::EventPtr SI::GetEvent(int serviceId, int eventId, const Ice::Current &) { Logger()->messagef(LOG_DEBUG, "%s(s=%d, e=%d)", __PRETTY_FUNCTION__, serviceId, eventId); - auto rtn = Slicer::DeserializeAny( + auto rtn = Slicer::DeserializeAny( *Select(SI_eventById, serviceId, eventId).second); if (rtn.empty()) throw P2PVR::NotFound(); return rtn.front(); @@ -124,7 +125,7 @@ P2PVR::Events SI::EventsOnNow(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_eventsOnNow).second); } @@ -132,7 +133,7 @@ P2PVR::Events SI::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, const Ice::Current &) { Logger()->messagebf(LOG_DEBUG, "%s([%s]-[%s])", from, to, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_eventsInRange, from, to).second); } @@ -141,7 +142,7 @@ SI::EventSearch(const IceUtil::Optional & keywords, const IceUtil:: { Logger()->messagebf(LOG_DEBUG, "%s(keywords=%s,serviceId=%s,from=%s,to=%s)", keywords, serviceId, from, to, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_eventSearch, from, to, serviceId, serviceId, keywords, keywords, keywords, keywords).second); } @@ -149,7 +150,7 @@ P2PVR::Events SI::EventsInSchedules(const Ice::Current &) { Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_eventsInSchedules).second); } @@ -157,7 +158,7 @@ P2PVR::Events SI::EventsInSchedule(int scheduleId, const Ice::Current &) { Logger()->messagebf(LOG_DEBUG, "%s(%d)", scheduleId, __PRETTY_FUNCTION__); - return Slicer::DeserializeAny( + return Slicer::DeserializeAny( *Select(SI_eventsInSchedule, scheduleId).second); } diff --git a/p2pvr/daemon/sqlSelectDeserializer.cpp b/p2pvr/daemon/sqlSelectDeserializer.cpp deleted file mode 100644 index 5a59e3a..0000000 --- a/p2pvr/daemon/sqlSelectDeserializer.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "sqlSelectDeserializer.h" -#include -#include -#include -#include - -VariableType -operator/(DB::SelectCommand & cmd, unsigned int col) -{ - HandleAsVariableType vt; - cmd[col].apply(vt); - return vt.variable; -} - -class SqlSource : public DB::HandleField, public Slicer::ValueSource, - public Slicer::TValueSource, - public Slicer::TValueSource { - public: - bool isNull() const - { - return vt.isNull(); - } - - void interval(const boost::posix_time::time_duration & d) override - { - vt = d; - } - void null() override - { - vt = Null(); - } - void string(const char * s, size_t l) override - { - vt = std::string(s, l); - } - void integer(int64_t i) override - { - vt = i; - } - void floatingpoint(double fp) override - { - vt = fp; - } - void timestamp(const boost::posix_time::ptime & t) - { - vt = t; - } - void boolean(bool b) override - { - vt = b; - } -#define SET(Type) \ - void set(Type & b) const override { \ - b = vt.as(); \ - } -#define SETNCONV(Type, CType) \ - void set(Type & b) const override { \ - b = boost::numeric_cast(vt.as()); \ - } - SET(bool); - SET(std::string); - SETNCONV(Ice::Byte, int64_t); - SETNCONV(Ice::Short, int64_t); - SET(Ice::Int); - SET(Ice::Long); - SETNCONV(Ice::Float, double); - SET(Ice::Double); - SET(boost::posix_time::ptime); - SET(boost::posix_time::time_duration); - - private: - VariableType vt; -}; -typedef IceUtil::Handle SqlSourcePtr; - -SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand & c, IceUtil::Optional tc) : - cmd(c), - typeIdColName(tc) -{ -} - -void -SqlSelectDeserializer::Deserialize(Slicer::ModelPartPtr mp) -{ - cmd.execute(); - columnCount = cmd.columnCount(); - if (typeIdColName) { - typeIdColIdx = cmd.getOrdinal(*typeIdColName); - } - switch (mp->GetType()) { - case Slicer::mpt_Sequence: - DeserializeSequence(mp); - return; - case Slicer::mpt_Complex: - DeserializeObject(mp); - return; - case Slicer::mpt_Simple: - DeserializeSimple(mp); - return; - default: - throw std::invalid_argument("Unspported model type"); - } -} - -void -SqlSelectDeserializer::DeserializeSimple(Slicer::ModelPartPtr mp) -{ - auto fmp = mp->GetAnonChild(); - if (!cmd.fetch()) { - throw NoRowsReturned(); - } - SqlSourcePtr h = new SqlSource(); - const DB::Column & c = cmd[0]; - c.apply(*h); - if (!h->isNull()) { - fmp->Create(); - fmp->SetValue(h); - fmp->Complete(); - } - if (cmd.fetch()) { - throw std::invalid_argument("Too many rows returned"); - } -} - -void -SqlSelectDeserializer::DeserializeSequence(Slicer::ModelPartPtr mp) -{ - mp = mp->GetAnonChild(); - SqlSourcePtr h = new SqlSource(); - while (cmd.fetch()) { - DeserializeRow(mp); - } -} - -void -SqlSelectDeserializer::DeserializeObject(Slicer::ModelPartPtr mp) -{ - if (!cmd.fetch()) { - throw NoRowsReturned(); - } - DeserializeRow(mp); - if (cmd.fetch()) { - while (cmd.fetch()) ; - throw std::invalid_argument("Too many rows returned"); - } -} - -void -SqlSelectDeserializer::DeserializeRow(Slicer::ModelPartPtr mp) -{ - SqlSourcePtr h = new SqlSource(); - auto rmp = mp->GetAnonChild(); - if (rmp) { - if (typeIdColIdx) { - rmp = rmp->GetSubclassModelPart(cmd / *typeIdColIdx); - } - rmp->Create(); - for (auto col = 0u; col < columnCount; col += 1) { - const DB::Column & c = cmd[col]; - auto fmpr = rmp->GetAnonChildRef([&c](Slicer::HookCommonPtr h) { - return boost::iequals(c.name.raw(), h->PartName()); - }); - if (fmpr) { - auto fmp = fmpr->Child(); - c.apply(*h); - if (!h->isNull()) { - fmp->Create(); - fmp->SetValue(h); - fmp->Complete(); - } - } - } - rmp->Complete(); - } -} - diff --git a/p2pvr/daemon/sqlSelectDeserializer.h b/p2pvr/daemon/sqlSelectDeserializer.h deleted file mode 100644 index 0c32811..0000000 --- a/p2pvr/daemon/sqlSelectDeserializer.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef P2PVR_SQL_DESERIALIZER_H -#define P2PVR_SQL_DESERIALIZER_H - -#include -#include - -class NoRowsReturned : public std::exception { }; - -class SqlSelectDeserializer : public Slicer::Deserializer { - public: - SqlSelectDeserializer(DB::SelectCommand &, IceUtil::Optional typeIdCol = IceUtil::Optional()); - - virtual void Deserialize(Slicer::ModelPartPtr) override; - - protected: - void DeserializeSimple(Slicer::ModelPartPtr); - void DeserializeObject(Slicer::ModelPartPtr); - void DeserializeSequence(Slicer::ModelPartPtr); - void DeserializeRow(Slicer::ModelPartPtr); - - DB::SelectCommand & cmd; - unsigned int columnCount; - IceUtil::Optional typeIdColName; - IceUtil::Optional typeIdColIdx; -}; - -#endif - diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam index 86bb906..6f0f0dd 100644 --- a/p2pvr/daemon/unittests/Jamfile.jam +++ b/p2pvr/daemon/unittests/Jamfile.jam @@ -237,6 +237,7 @@ run Ice ../..//boost_utf testCommon + ..//slicer-db test-data ROOT=\"$(me)\" : testSqlSelectDeserializer ; diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp index 38c9478..9926c2b 100644 --- a/p2pvr/daemon/unittests/testMaint.cpp +++ b/p2pvr/daemon/unittests/testMaint.cpp @@ -13,7 +13,7 @@ #include #include #include "mockDefs.h" -#include "sqlSelectDeserializer.h" +#include #include "commonHelpers.h" #include #include diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp index d3ecee6..260bf82 100644 --- a/p2pvr/daemon/unittests/testRecording.cpp +++ b/p2pvr/daemon/unittests/testRecording.cpp @@ -13,7 +13,7 @@ #include #include #include "mockDefs.h" -#include "sqlSelectDeserializer.h" +#include #include "commonHelpers.h" #include "serviceStreamer.h" #include "temporaryIceAdapterObject.h" diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp index 077486c..47d36c5 100644 --- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp +++ b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp @@ -1,6 +1,6 @@ #define BOOST_TEST_MODULE SqlSelectDeserializer #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE( listOfEvents ) { auto db = dataSource("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM events ORDER BY serviceId, eventId LIMIT 100")); - auto res = Slicer::DeserializeAny(*sel); + auto res = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(res.size(), 100); BOOST_REQUIRE_EQUAL(res[0]->ServiceId, 4166); BOOST_REQUIRE_EQUAL(res[0]->EventId, 49741); @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE( singleField ) { auto db = dataSource("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT EventId FROM events ORDER BY serviceId, eventId LIMIT 1")); - auto res = Slicer::DeserializeAny(*sel); + auto res = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(res, 49741); } @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE( singleEvent ) { auto db = dataSource("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM events ORDER BY serviceId, eventId LIMIT 1")); - auto res = Slicer::DeserializeAny(*sel); + auto res = Slicer::DeserializeAny(*sel); BOOST_REQUIRE_EQUAL(res->ServiceId, 4166); BOOST_REQUIRE_EQUAL(res->EventId, 49741); BOOST_REQUIRE_EQUAL(res->Title, "Skiing Weatherview"); @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE( dynamicTypes ) { auto db = dataSource("postgres")->getReadonly(); auto sel = SelectPtr(db->newSelectCommand("SELECT d.*, '::DVBSI::TerrestrialDelivery' \"typeid\" FROM delivery_dvbt d ORDER BY TransportStreamId")); - auto res = Slicer::DeserializeAny(*sel, "typeid"); + auto res = Slicer::DeserializeAny(*sel, "typeid"); BOOST_REQUIRE_EQUAL(res.size(), 6); auto dvbt = DVBSI::TerrestrialDeliveryPtr::dynamicCast(res[0]); BOOST_REQUIRE_EQUAL(dvbt->Frequency, 682000000); -- cgit v1.2.3 From 175596644e6f23231878845bd4ed56b1165f49f5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 24 Oct 2015 14:58:54 +0100 Subject: Use slicer for inserts and updates --- p2pvr/daemon/recordings.cpp | 10 ++++------ p2pvr/daemon/recordings.h | 2 +- p2pvr/daemon/schedules.cpp | 27 +++++++++++++++------------ p2pvr/daemon/schedules.h | 3 ++- p2pvr/daemon/sql/Recordings_insert.sql | 2 -- p2pvr/daemon/sql/Recordings_insertNewId.sql | 2 -- p2pvr/daemon/sql/Schedules_insert.sql | 2 -- p2pvr/daemon/sql/Schedules_insertNewId.sql | 1 - p2pvr/daemon/sql/Schedules_update.sql | 10 ---------- p2pvr/daemon/unittests/mockScheduler.cpp | 7 ++++++- p2pvr/daemon/unittests/mockScheduler.h | 3 ++- p2pvr/daemon/unittests/testRecordings.cpp | 5 +++-- p2pvr/daemon/unittests/testSched.cpp | 12 +++++------- p2pvr/ice/p2pvr.ice | 6 +++++- 14 files changed, 43 insertions(+), 49 deletions(-) delete mode 100644 p2pvr/daemon/sql/Recordings_insert.sql delete mode 100644 p2pvr/daemon/sql/Recordings_insertNewId.sql delete mode 100644 p2pvr/daemon/sql/Schedules_insert.sql delete mode 100644 p2pvr/daemon/sql/Schedules_insertNewId.sql delete mode 100644 p2pvr/daemon/sql/Schedules_update.sql diff --git a/p2pvr/daemon/recordings.cpp b/p2pvr/daemon/recordings.cpp index 4a3e6d2..547b3bf 100644 --- a/p2pvr/daemon/recordings.cpp +++ b/p2pvr/daemon/recordings.cpp @@ -5,21 +5,19 @@ #include #include #include +#include -ResourceString(Recording_Insert, sql_Recordings_insert); -ResourceString(Recording_InsertNewId, sql_Recordings_insertNewId); ResourceString(Recording_Delete, sql_Recordings_delete); ResourceString(Recording_GetStorage, sql_Recordings_getStorage); ResourceString(Recording_GetAll, sql_Recordings_getAll); -int +Ice::Int Recordings::NewRecording(const P2PVR::RecordingPtr & r, const Ice::Current &) { Logger()->messagebf(LOG_INFO, "%s: Creating new recording %s at %s", __PRETTY_FUNCTION__, r->Guid, r->StorageAddress); TxHelper tx(this); - auto insert = Modify(Recording_Insert, r->StorageAddress, r->Guid, r->ScheduleId, r->EventUid); - insert.second->execute(); - r->RecordingId = SelectScalar(Recording_InsertNewId); + auto db = dataSource("postgres")->getWritable(); + Slicer::SerializeAny(r, db.get(), "recordings"); Logger()->messagebf(LOG_INFO, "%s: Created recording Id: %d", __PRETTY_FUNCTION__, r->RecordingId); return r->RecordingId; } diff --git a/p2pvr/daemon/recordings.h b/p2pvr/daemon/recordings.h index 0f18a36..fc7863a 100644 --- a/p2pvr/daemon/recordings.h +++ b/p2pvr/daemon/recordings.h @@ -7,7 +7,7 @@ class Recordings : public DatabaseClient, public P2PVR::Recordings { public: - int NewRecording(const P2PVR::RecordingPtr & rec, const Ice::Current &); + Ice::Int NewRecording(const P2PVR::RecordingPtr & rec, const Ice::Current &); void DeleteRecording(int recordingId, const Ice::Current &); P2PVR::RecordingList GetRecordings(const Ice::Current &); }; diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 19d277f..6a985c3 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -12,14 +12,13 @@ #include #include #include +#include +#include #include #include #include ResourceString(Schedules_getCandidates, sql_Schedules_getCandidates); -ResourceString(Schedules_insert, sql_Schedules_insert); -ResourceString(Schedules_insertNewId, sql_Schedules_insertNewId); -ResourceString(Schedules_update, sql_Schedules_update); ResourceString(Schedules_delete, sql_Schedules_delete); ResourceString(Schedules_selectAll, sql_Schedules_selectAll); ResourceString(Schedules_selectById, sql_Schedules_selectById); @@ -331,20 +330,24 @@ Schedules::GetScheduledToRecord(const Ice::Current &) *Select(Schedules_scheduledToRecord).second); } -int -Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) +Ice::Int +Schedules::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) { TxHelper tx(this); - if (s->ScheduleId == 0) { - Modify(Schedules_insert, s->ServiceId, s->EventUid, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats).second->execute(); - s->ScheduleId = SelectScalar(Schedules_insertNewId); - } - else { - Modify(Schedules_update, s->ServiceId, s->EventUid, s->Title, s->Search, s->Priority, s->Early, s->Late, s->Repeats, s->ScheduleId).second->execute(); - } + auto db = dataSource("postgres")->getWritable(); + Slicer::SerializeAny(s, db.get(), "schedules"); DoReschedule(ice); return s->ScheduleId; } +void +Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) +{ + TxHelper tx(this); + auto db = dataSource("postgres")->getWritable(); + Slicer::SerializeAny(s, db.get(), "schedules"); + DoReschedule(ice); +} + INSTANTIATEFACTORY(EpisodeGroup, const Episodes &); diff --git a/p2pvr/daemon/schedules.h b/p2pvr/daemon/schedules.h index 07f2c23..2669449 100644 --- a/p2pvr/daemon/schedules.h +++ b/p2pvr/daemon/schedules.h @@ -67,7 +67,8 @@ class Schedules : public P2PVR::Schedules, public DatabaseClient { P2PVR::SchedulePtr GetSchedule(int id, const Ice::Current &); P2PVR::ScheduleList GetSchedules(const Ice::Current &); P2PVR::ScheduledToRecordList GetScheduledToRecord(const Ice::Current &); - int UpdateSchedule(const P2PVR::SchedulePtr &, const Ice::Current &); + Ice::Int NewSchedule(const P2PVR::SchedulePtr &, const Ice::Current &); + void UpdateSchedule(const P2PVR::SchedulePtr &, const Ice::Current &); void DoReschedule(const Ice::Current &); INITOPTIONS; diff --git a/p2pvr/daemon/sql/Recordings_insert.sql b/p2pvr/daemon/sql/Recordings_insert.sql deleted file mode 100644 index ba0b9e2..0000000 --- a/p2pvr/daemon/sql/Recordings_insert.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO recordings(storageAddress, guid, scheduleId, eventUid) -VALUES(?, ?, ?, ?) diff --git a/p2pvr/daemon/sql/Recordings_insertNewId.sql b/p2pvr/daemon/sql/Recordings_insertNewId.sql deleted file mode 100644 index 0583b49..0000000 --- a/p2pvr/daemon/sql/Recordings_insertNewId.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT currval('recordings_recordingid_seq'); - diff --git a/p2pvr/daemon/sql/Schedules_insert.sql b/p2pvr/daemon/sql/Schedules_insert.sql deleted file mode 100644 index 70c95bd..0000000 --- a/p2pvr/daemon/sql/Schedules_insert.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO schedules(serviceId, eventUid, title, search, priority, early, late, repeats) -VALUES(?, ?, ?, ?, ?, ?, ?, ?) diff --git a/p2pvr/daemon/sql/Schedules_insertNewId.sql b/p2pvr/daemon/sql/Schedules_insertNewId.sql deleted file mode 100644 index f66acd5..0000000 --- a/p2pvr/daemon/sql/Schedules_insertNewId.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT currval('schedules_scheduleid_seq'); diff --git a/p2pvr/daemon/sql/Schedules_update.sql b/p2pvr/daemon/sql/Schedules_update.sql deleted file mode 100644 index cf3ce49..0000000 --- a/p2pvr/daemon/sql/Schedules_update.sql +++ /dev/null @@ -1,10 +0,0 @@ -UPDATE schedules SET - serviceId = ?, - eventUid = ?, - title = ?, - search = ?, - priority = ?, - early = ?, - late = ?, - repeats = ? -WHERE scheduleId = ? diff --git a/p2pvr/daemon/unittests/mockScheduler.cpp b/p2pvr/daemon/unittests/mockScheduler.cpp index 2677df7..193630d 100644 --- a/p2pvr/daemon/unittests/mockScheduler.cpp +++ b/p2pvr/daemon/unittests/mockScheduler.cpp @@ -29,8 +29,13 @@ MockScheduler::GetScheduledToRecord(const::Ice::Current &) } Ice::Int +MockScheduler::NewSchedule(const::P2PVR::SchedulePtr &, const::Ice::Current &) +{ + return 1; +} + +void MockScheduler::UpdateSchedule(const::P2PVR::SchedulePtr &, const::Ice::Current &) { - return 0; } diff --git a/p2pvr/daemon/unittests/mockScheduler.h b/p2pvr/daemon/unittests/mockScheduler.h index 9176bb6..e90567b 100644 --- a/p2pvr/daemon/unittests/mockScheduler.h +++ b/p2pvr/daemon/unittests/mockScheduler.h @@ -10,7 +10,8 @@ class MockScheduler : public P2PVR::Schedules { P2PVR::SchedulePtr GetSchedule(::Ice::Int, const ::Ice::Current&) override; P2PVR::ScheduleList GetSchedules(const ::Ice::Current&) override; P2PVR::ScheduledToRecordList GetScheduledToRecord(const ::Ice::Current&) override; - Ice::Int UpdateSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) override; + Ice::Int NewSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) override; + void UpdateSchedule(const ::P2PVR::SchedulePtr&, const ::Ice::Current&) override; }; #endif diff --git a/p2pvr/daemon/unittests/testRecordings.cpp b/p2pvr/daemon/unittests/testRecordings.cpp index ff8f676..7415cb1 100644 --- a/p2pvr/daemon/unittests/testRecordings.cpp +++ b/p2pvr/daemon/unittests/testRecordings.cpp @@ -68,9 +68,10 @@ BOOST_AUTO_TEST_CASE( recordings_addAndDelete ) auto guid = boost::lexical_cast(boost::uuids::random_generator()()); auto rec = P2PVR::RecordingPtr(new P2PVR::Recording(0, "", guid, 0, event->EventUid)); - auto id = r->NewRecording(rec); + rec->RecordingId = r->NewRecording(rec); + BOOST_REQUIRE_EQUAL(218, rec->RecordingId); r->GetRecordings(); - r->DeleteRecording(id); + r->DeleteRecording(rec->RecordingId); } BOOST_AUTO_TEST_SUITE_END() diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp index 9afdaad..45414aa 100644 --- a/p2pvr/daemon/unittests/testSched.cpp +++ b/p2pvr/daemon/unittests/testSched.cpp @@ -79,11 +79,10 @@ BOOST_AUTO_TEST_CASE( sc_crud ) P2PVR::SchedulePtr schedule = new P2PVR::Schedule(); schedule->Search = "Top Gear"; - auto id = sc->UpdateSchedule(schedule); - BOOST_REQUIRE(id > 0); - schedule->ScheduleId = id; + schedule->ScheduleId = sc->NewSchedule(schedule); + BOOST_REQUIRE_EQUAL(187, schedule->ScheduleId); - auto fetched = sc->GetSchedule(id); + auto fetched = sc->GetSchedule(schedule->ScheduleId); BOOST_REQUIRE_EQUAL(schedule->ScheduleId, fetched->ScheduleId); BOOST_REQUIRE_EQUAL(*schedule->Search, *fetched->Search); BOOST_REQUIRE_EQUAL(schedule->Priority, fetched->Priority); @@ -94,10 +93,9 @@ BOOST_AUTO_TEST_CASE( sc_crud ) schedule->Search = "Top Gear Special"; schedule->Early.Minutes = 5; schedule->Late.Minutes = 15; - auto updatedId = sc->UpdateSchedule(schedule); + sc->UpdateSchedule(schedule); - fetched = sc->GetSchedule(id); - BOOST_REQUIRE_EQUAL(updatedId, id); + fetched = sc->GetSchedule(schedule->ScheduleId); BOOST_REQUIRE_EQUAL(schedule->ScheduleId, fetched->ScheduleId); BOOST_REQUIRE_EQUAL(*schedule->Search, *fetched->Search); BOOST_REQUIRE_EQUAL(schedule->Priority, fetched->Priority); diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 8f746d1..0c9cce3 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -8,6 +8,7 @@ module P2PVR { ["project2:type"] class Event extends DVBSI::Event { + ["slicer:db:auto","slicer:db:pkey"] int EventUid; bool Current = true; }; @@ -19,6 +20,7 @@ module P2PVR { // Something that we have recorded. ["project2:type"] class Recording { + ["slicer:db:auto","slicer:db:pkey"] int RecordingId; string StorageAddress; string Guid; @@ -30,6 +32,7 @@ module P2PVR { // Something that defines what we would like to record. ["project2:type"] class Schedule { + ["slicer:db:auto","slicer:db:pkey"] int ScheduleId = 0; optional(1) int ServiceId; optional(2) int EventUid; @@ -96,7 +99,8 @@ module P2PVR { idempotent ScheduleList GetSchedules(); ["project2:rows"] idempotent ScheduledToRecordList GetScheduledToRecord(); - idempotent int UpdateSchedule(Schedule newSchedule); + idempotent int NewSchedule(Schedule newSchedule); + idempotent void UpdateSchedule(Schedule newSchedule); ["project2:task"] idempotent void DoReschedule(); }; -- cgit v1.2.3 From f529b94f37e5a4387e2e68f6742972defcce017b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 24 Oct 2015 15:22:27 +0100 Subject: Wrap up slicer updates and DB connection access --- p2pvr/daemon/dbClient.h | 8 ++++++++ p2pvr/daemon/recordings.cpp | 3 +-- p2pvr/daemon/schedules.cpp | 7 ++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/p2pvr/daemon/dbClient.h b/p2pvr/daemon/dbClient.h index cd846e5..1fc12e8 100644 --- a/p2pvr/daemon/dbClient.h +++ b/p2pvr/daemon/dbClient.h @@ -11,6 +11,7 @@ #include #include #include "p2Helpers.h" +#include class SqlMergeTask; @@ -40,6 +41,13 @@ class DatabaseClient : public virtual CommonObjects { return {db, cmd}; } + template + void Store(const Obj & o, const ExtraArgs & ... ea) const + { + auto db = dataSource("postgres")->getWritable(); + Slicer::SerializeAny(o, db.get(), ea...); + } + template std::pair Select(const std::string & sql, const Args & ... args) const { diff --git a/p2pvr/daemon/recordings.cpp b/p2pvr/daemon/recordings.cpp index 547b3bf..ac8f27a 100644 --- a/p2pvr/daemon/recordings.cpp +++ b/p2pvr/daemon/recordings.cpp @@ -16,8 +16,7 @@ Recordings::NewRecording(const P2PVR::RecordingPtr & r, const Ice::Current &) { Logger()->messagebf(LOG_INFO, "%s: Creating new recording %s at %s", __PRETTY_FUNCTION__, r->Guid, r->StorageAddress); TxHelper tx(this); - auto db = dataSource("postgres")->getWritable(); - Slicer::SerializeAny(r, db.get(), "recordings"); + Store(r, "recordings"); Logger()->messagebf(LOG_INFO, "%s: Created recording Id: %d", __PRETTY_FUNCTION__, r->RecordingId); return r->RecordingId; } diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 6a985c3..90a42a9 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -334,8 +333,7 @@ Ice::Int Schedules::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) { TxHelper tx(this); - auto db = dataSource("postgres")->getWritable(); - Slicer::SerializeAny(s, db.get(), "schedules"); + Store(s, "schedules"); DoReschedule(ice); return s->ScheduleId; } @@ -344,8 +342,7 @@ void Schedules::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice) { TxHelper tx(this); - auto db = dataSource("postgres")->getWritable(); - Slicer::SerializeAny(s, db.get(), "schedules"); + Store(s, "schedules"); DoReschedule(ice); } -- cgit v1.2.3 From f2667ed93ae631dc90eb6935692edfad5e7edb85 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 24 Oct 2015 16:49:16 +0100 Subject: Enable hidden visibility and LTO --- p2pvr/carddaemon/Jamfile.jam | 2 ++ p2pvr/daemon/Jamfile.jam | 2 ++ p2pvr/daemon/globalDevices.h | 3 ++- p2pvr/daemon/maintenance.h | 6 ++++-- p2pvr/daemon/recorder.h | 7 ++++--- p2pvr/daemon/recordings.h | 3 ++- p2pvr/daemon/schedules.h | 4 +++- p2pvr/daemon/si.h | 3 ++- p2pvr/daemon/storage.h | 3 ++- p2pvr/daemon/unittests/testp2ice.cpp | 5 ++--- p2pvr/daemonbase/Jamfile.jam | 2 ++ p2pvr/daemonbase/daemonBase.h | 3 ++- p2pvr/daemonbase/fileSink.h | 3 ++- p2pvr/daemonbase/p2LoggerWrapper.h | 3 ++- p2pvr/devices/Jamfile.jam | 2 ++ p2pvr/devices/localDevices.h | 8 +++++--- p2pvr/dvb/Jamfile.jam | 2 ++ p2pvr/dvb/siParsers/event.h | 13 +++++++------ p2pvr/dvb/siParsers/network.h | 13 +++++++------ p2pvr/dvb/siParsers/programAssociation.h | 3 ++- p2pvr/dvb/siParsers/programMap.h | 3 ++- p2pvr/dvb/siParsers/service.h | 7 ++++--- p2pvr/dvb/siParsers/table.h | 7 +++++-- p2pvr/ice/Jamfile.jam | 1 + p2pvr/ice/commonHelpers.h | 9 +++++---- p2pvr/ice/converters.cpp | 18 +++++++++--------- p2pvr/lib/Jamfile.jam | 2 ++ p2pvr/lib/bindTimerTask.h | 3 ++- p2pvr/lib/fileHandle.h | 4 +++- p2pvr/lib/muxer.h | 9 +++++---- p2pvr/lib/p2Helpers.h | 10 ++++++++++ p2pvr/lib/serviceStreamer.h | 3 ++- p2pvr/lib/serviceStreamerCore.h | 3 ++- p2pvr/lib/temporaryIceAdapterObject.h | 3 ++- p2pvr/p2comp/Jamfile.jam | 4 +++- 35 files changed, 115 insertions(+), 61 deletions(-) diff --git a/p2pvr/carddaemon/Jamfile.jam b/p2pvr/carddaemon/Jamfile.jam index 7088966..afa055f 100644 --- a/p2pvr/carddaemon/Jamfile.jam +++ b/p2pvr/carddaemon/Jamfile.jam @@ -5,4 +5,6 @@ lib p2pvrcarddaemon : ../ice//p2pvrice ../devices//p2pvrdevices ../daemonbase//p2pvrdaemonbase + -fvisibility=hidden + release:-flto ; diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam index 369e714..05b0e9b 100644 --- a/p2pvr/daemon/Jamfile.jam +++ b/p2pvr/daemon/Jamfile.jam @@ -23,6 +23,8 @@ lib p2pvrdaemon : ../devices//p2pvrdevices ../daemonbase//p2pvrdaemonbase ..//adhocutil + -fvisibility=hidden + release:-flto ../../libtmdb//tmdb slicer slicer-db diff --git a/p2pvr/daemon/globalDevices.h b/p2pvr/daemon/globalDevices.h index 33f6231..86d80c5 100644 --- a/p2pvr/daemon/globalDevices.h +++ b/p2pvr/daemon/globalDevices.h @@ -6,8 +6,9 @@ #include #include +#include -class GlobalDevices : public P2PVR::Devices { +class DLL_PUBLIC GlobalDevices : public P2PVR::Devices { public: P2PVR::TunerPrx GetTunerSpecific(const DVBSI::DeliveryPtr &, const Ice::Current &); P2PVR::TunerPrx GetTunerAny(const DVBSI::DeliveryPtr &, const Ice::Current &); diff --git a/p2pvr/daemon/maintenance.h b/p2pvr/daemon/maintenance.h index 7ec0541..7c3e9b3 100644 --- a/p2pvr/daemon/maintenance.h +++ b/p2pvr/daemon/maintenance.h @@ -2,9 +2,11 @@ #define P2PVR_MAINTENANCE_H #include +#include #include "dbClient.h" +#include -class Maintenance : public P2PVR::Maintenance, public DatabaseClient { +class DLL_PUBLIC Maintenance : public P2PVR::Maintenance, public DatabaseClient { public: Maintenance(Ice::ObjectAdapterPtr, IceUtil::TimerPtr); @@ -17,7 +19,7 @@ class Maintenance : public P2PVR::Maintenance, public DatabaseClient { INITOPTIONS; private: - void ScheduledUpdate(); + DLL_PRIVATE void ScheduledUpdate(); Ice::ObjectAdapterPtr adapter; IceUtil::TimerPtr timer; diff --git a/p2pvr/daemon/recorder.h b/p2pvr/daemon/recorder.h index bef331b..6a6940e 100644 --- a/p2pvr/daemon/recorder.h +++ b/p2pvr/daemon/recorder.h @@ -7,8 +7,9 @@ #include #include #include "serviceStreamer.h" +#include -class Recorder : public P2PVR::Recorder { +class DLL_PUBLIC Recorder : public P2PVR::Recorder { public: typedef std::vector Pendings; @@ -32,8 +33,8 @@ class Recorder : public P2PVR::Recorder { INITOPTIONS; private: - void StartRecording(P2PVR::SchedulePtr schedule, DVBSI::ServicePtr service, P2PVR::EventPtr event); - void StopRecording(CurrentPtr); + DLL_PRIVATE void StartRecording(P2PVR::SchedulePtr schedule, DVBSI::ServicePtr service, P2PVR::EventPtr event); + DLL_PRIVATE void StopRecording(CurrentPtr); Ice::ObjectAdapterPtr adapter; IceUtil::TimerPtr timer; diff --git a/p2pvr/daemon/recordings.h b/p2pvr/daemon/recordings.h index fc7863a..482ce23 100644 --- a/p2pvr/daemon/recordings.h +++ b/p2pvr/daemon/recordings.h @@ -4,8 +4,9 @@ #include #include #include "dbClient.h" +#include -class Recordings : public DatabaseClient, public P2PVR::Recordings { +class DLL_PUBLIC Recordings : public DatabaseClient, public P2PVR::Recordings { public: Ice::Int NewRecording(const P2PVR::RecordingPtr & rec, const Ice::Current &); void DeleteRecording(int recordingId, const Ice::Current &); diff --git a/p2pvr/daemon/schedules.h b/p2pvr/daemon/schedules.h index 2669449..122e214 100644 --- a/p2pvr/daemon/schedules.h +++ b/p2pvr/daemon/schedules.h @@ -5,6 +5,7 @@ #include #include "dbClient.h" #include +#include typedef boost::posix_time::ptime datetime; class Episode; @@ -61,7 +62,7 @@ class EpisodeGroup { Showings selected; }; -class Schedules : public P2PVR::Schedules, public DatabaseClient { +class DLL_PUBLIC Schedules : public P2PVR::Schedules, public DatabaseClient { public: void DeleteSchedule(int id, const Ice::Current &); P2PVR::SchedulePtr GetSchedule(int id, const Ice::Current &); @@ -74,6 +75,7 @@ class Schedules : public P2PVR::Schedules, public DatabaseClient { INITOPTIONS; protected: static void GetEpisodeIntersects(Episodes &, Episodes &); + private: static std::string SchedulerAlgorithm; }; diff --git a/p2pvr/daemon/si.h b/p2pvr/daemon/si.h index c57a018..0e388a1 100644 --- a/p2pvr/daemon/si.h +++ b/p2pvr/daemon/si.h @@ -3,8 +3,9 @@ #include #include "dbClient.h" +#include -class SI : public P2PVR::SI, public DatabaseClient { +class DLL_PUBLIC SI : public P2PVR::SI, public DatabaseClient { public: DVBSI::Networks GetNetworks(const Ice::Current &); P2PVR::Deliveries GetAllDeliveries(const Ice::Current &); diff --git a/p2pvr/daemon/storage.h b/p2pvr/daemon/storage.h index 144d6bd..982c3fd 100644 --- a/p2pvr/daemon/storage.h +++ b/p2pvr/daemon/storage.h @@ -6,8 +6,9 @@ #include #include #include "temporaryIceAdapterObject.h" +#include -class Storage : public P2PVR::Storage { +class DLL_PUBLIC Storage : public P2PVR::Storage { public: P2PVR::RawDataClientPrx OpenForWrite(const std::string &, const Ice::Current &) override; void Close(const P2PVR::RawDataClientPrx & file, const Ice::Current &) override; diff --git a/p2pvr/daemon/unittests/testp2ice.cpp b/p2pvr/daemon/unittests/testp2ice.cpp index dc584b6..6eece19 100644 --- a/p2pvr/daemon/unittests/testp2ice.cpp +++ b/p2pvr/daemon/unittests/testp2ice.cpp @@ -27,9 +27,8 @@ void unloadTests() { BOOST_REQUIRE_THROW(RowSetFactory::get("P2PVR-SI-GetEvent"), AdHoc::NoSuchPluginException); - // Known issue, these *should* unload, but for some reason, don't. - BOOST_WARN_THROW(StreamFactory::get("p2pvrrecordingstream"), AdHoc::NoSuchPluginException); - BOOST_WARN_THROW(StreamFactory::get("p2pvrservicestream"), AdHoc::NoSuchPluginException); + BOOST_REQUIRE_THROW(StreamFactory::get("p2pvrrecordingstream"), AdHoc::NoSuchPluginException); + BOOST_REQUIRE_THROW(StreamFactory::get("p2pvrservicestream"), AdHoc::NoSuchPluginException); } BOOST_GLOBAL_FIXTURE( TestAppInstance ); diff --git a/p2pvr/daemonbase/Jamfile.jam b/p2pvr/daemonbase/Jamfile.jam index f02a172..2168986 100644 --- a/p2pvr/daemonbase/Jamfile.jam +++ b/p2pvr/daemonbase/Jamfile.jam @@ -15,6 +15,8 @@ lib p2pvrdaemonbase : ../lib//p2pvrlib ../ice//p2pvrice ..//adhocutil + -fvisibility=hidden + release:-flto ../ice//p2pvrice : : ../ice//p2pvrice diff --git a/p2pvr/daemonbase/daemonBase.h b/p2pvr/daemonbase/daemonBase.h index 3cf9b19..87e741b 100644 --- a/p2pvr/daemonbase/daemonBase.h +++ b/p2pvr/daemonbase/daemonBase.h @@ -5,8 +5,9 @@ #include #include #include +#include -class DaemonBase : public Daemon { +class DLL_PUBLIC DaemonBase : public Daemon { public: DaemonBase(int argc, char ** argv); ~DaemonBase(); diff --git a/p2pvr/daemonbase/fileSink.h b/p2pvr/daemonbase/fileSink.h index 8c7594b..fbd469c 100644 --- a/p2pvr/daemonbase/fileSink.h +++ b/p2pvr/daemonbase/fileSink.h @@ -4,8 +4,9 @@ #include #include #include +#include -class FileSink : public P2PVR::RawDataClient { +class DLL_PUBLIC FileSink : public P2PVR::RawDataClient { public: FileSink(const boost::filesystem::path & path); FileSink(int fd); diff --git a/p2pvr/daemonbase/p2LoggerWrapper.h b/p2pvr/daemonbase/p2LoggerWrapper.h index e8de1e8..0d84683 100644 --- a/p2pvr/daemonbase/p2LoggerWrapper.h +++ b/p2pvr/daemonbase/p2LoggerWrapper.h @@ -2,8 +2,9 @@ #define P2LOGGERWRAPPER #include +#include -class P2LoggerWrapper : public Ice::Logger { +class DLL_PUBLIC P2LoggerWrapper : public Ice::Logger { public: P2LoggerWrapper(const std::string & prefix = std::string()); diff --git a/p2pvr/devices/Jamfile.jam b/p2pvr/devices/Jamfile.jam index f39256b..67c86fe 100644 --- a/p2pvr/devices/Jamfile.jam +++ b/p2pvr/devices/Jamfile.jam @@ -25,6 +25,8 @@ lib p2pvrdevices : ..//p2common ..//adhocutil ../ice//p2pvrice + -fvisibility=hidden + release:-flto : : boost_filesystem ../ice//p2pvrice diff --git a/p2pvr/devices/localDevices.h b/p2pvr/devices/localDevices.h index 3c3d51b..1845256 100644 --- a/p2pvr/devices/localDevices.h +++ b/p2pvr/devices/localDevices.h @@ -7,8 +7,10 @@ #include #include #include +#include +#include -class LocalDevices : public P2PVR::LocalDevices { +class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices { public: LocalDevices(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr); ~LocalDevices(); @@ -30,9 +32,9 @@ class LocalDevices : public P2PVR::LocalDevices { IceUtil::TimerTaskPtr clientCheck; // Check that registered clients haven't silently gone away - void ClientCheck(Ice::ObjectAdapterPtr adapter); + DLL_PRIVATE void ClientCheck(Ice::ObjectAdapterPtr adapter); - class OpenTuner { + class DLL_PRIVATE OpenTuner { public: OpenTuner(DVBSI::DeliveryPtr, P2PVR::PrivateTunerPrx, bool); diff --git a/p2pvr/dvb/Jamfile.jam b/p2pvr/dvb/Jamfile.jam index e71093a..1e81a73 100644 --- a/p2pvr/dvb/Jamfile.jam +++ b/p2pvr/dvb/Jamfile.jam @@ -8,6 +8,8 @@ lib p2pvrdvb : : ../ice//p2pvrice ..//adhocutil + -fvisibility=hidden + release:-flto ../ice//p2pvrice : : ../ice//p2pvrice diff --git a/p2pvr/dvb/siParsers/event.h b/p2pvr/dvb/siParsers/event.h index d437c4e..5baadd4 100644 --- a/p2pvr/dvb/siParsers/event.h +++ b/p2pvr/dvb/siParsers/event.h @@ -3,6 +3,7 @@ #include "table.h" #include +#include struct EventInformation { SiTableHeader header; @@ -13,7 +14,7 @@ struct EventInformation { u_char data[]; } __attribute__((packed)); -class SiEpgParser : public SiTableParser { +class DLL_PUBLIC SiEpgParser : public SiTableParser { protected: bool CheckTableId(u_char tableId) const; int SectionNumberShift() const { return 3; } @@ -24,11 +25,11 @@ class SiEpgParser : public SiTableParser +#include struct NetworkInformation { SiTableHeader header; @@ -17,17 +18,17 @@ struct NetworkInformation { u_char data[]; } __attribute__((packed)); -class SiNetworkInformationParser : public SiTableParser { +class DLL_PUBLIC SiNetworkInformationParser : public SiTableParser { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct NetworkInformation * nit, DVBSI::NetworkPtr); private: - static void parseDescriptor_NetworkName(DVBSI::NetworkPtr, const u_char *data, size_t len); - static void parseDescriptor_ServiceList(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); - static void parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); - static void parseDescriptor_SatelliteDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); - static void parseDescriptor_CableDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_NetworkName(DVBSI::NetworkPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_ServiceList(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_SatelliteDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_CableDelivery(DVBSI::NetworkTransportStreamPtr, const u_char *data, size_t len); }; #endif diff --git a/p2pvr/dvb/siParsers/programAssociation.h b/p2pvr/dvb/siParsers/programAssociation.h index 653be0c..3ef44f0 100644 --- a/p2pvr/dvb/siParsers/programAssociation.h +++ b/p2pvr/dvb/siParsers/programAssociation.h @@ -3,6 +3,7 @@ #include "table.h" #include +#include struct ProgramAssociationSection { SiTableHeader header; @@ -12,7 +13,7 @@ struct ProgramAssociationSection { typedef std::map ProgramAssociationMap; typedef boost::shared_ptr ProgramAssociationMapPtr; -class SiProgramAssociationParser : public SiTableParser { +class DLL_PUBLIC SiProgramAssociationParser : public SiTableParser { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct ProgramAssociationSection * pas, ProgramAssociationMapPtr); diff --git a/p2pvr/dvb/siParsers/programMap.h b/p2pvr/dvb/siParsers/programMap.h index 07821b5..14f0c8d 100644 --- a/p2pvr/dvb/siParsers/programMap.h +++ b/p2pvr/dvb/siParsers/programMap.h @@ -3,6 +3,7 @@ #include "table.h" #include +#include struct ProgramMap { SiTableHeader header; @@ -25,7 +26,7 @@ struct ProgramMap { u_char data[]; } __attribute__((packed)); -class SiProgramMapParser : public SiTableParser { +class DLL_PUBLIC SiProgramMapParser : public SiTableParser { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct ProgramMap * nit, DVBSI::ProgramMapPtr); diff --git a/p2pvr/dvb/siParsers/service.h b/p2pvr/dvb/siParsers/service.h index 611eb90..64ec351 100644 --- a/p2pvr/dvb/siParsers/service.h +++ b/p2pvr/dvb/siParsers/service.h @@ -3,6 +3,7 @@ #include "table.h" #include +#include struct TransportStreamDescriptor { SiTableHeader header; @@ -11,14 +12,14 @@ struct TransportStreamDescriptor { u_char data[]; } __attribute__((packed)); -class SiServicesParser : public SiTableParser { +class DLL_PUBLIC SiServicesParser : public SiTableParser { protected: bool CheckTableId(u_char tableId) const; void ParseSiTable(const struct TransportStreamDescriptor * nit, DVBSI::TransportStreamPtr); private: - static void parseDescriptor_Service(DVBSI::ServicePtr, const u_char *data, size_t len); - static void parseDescriptor_DefaultAuthority(DVBSI::ServicePtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_Service(DVBSI::ServicePtr, const u_char *data, size_t len); + DLL_PRIVATE static void parseDescriptor_DefaultAuthority(DVBSI::ServicePtr, const u_char *data, size_t len); }; #endif diff --git a/p2pvr/dvb/siParsers/table.h b/p2pvr/dvb/siParsers/table.h index c470159..6333a2a 100644 --- a/p2pvr/dvb/siParsers/table.h +++ b/p2pvr/dvb/siParsers/table.h @@ -10,6 +10,7 @@ #include #include #include +#include typedef unsigned char u_char; @@ -19,9 +20,10 @@ typedef unsigned char u_char; #define HILO4(x) (x##4 << 24 | x##2 << 16 | x##3 << 8 | x##4) #define BcdCharToInt(x) (10*((x & 0xF0)>>4) + (x & 0xF)) -class SiTableParserBase : public P2PVR::RawDataClient { +class DLL_PUBLIC SiTableParserBase : public P2PVR::RawDataClient { public: const P2PVR::Data & CurrentRawData() const; + protected: SiTableParserBase(); virtual ~SiTableParserBase() = 0; @@ -35,11 +37,12 @@ class SiTableParserBase : public P2PVR::RawDataClient { static const std::string ISO10646; static const std::string EitEncoding; static const std::string UTF8; - protected: + virtual bool ParseInfoTable(const u_char * data, size_t len) = 0; time_t startTime; unsigned int incomplete; std::mutex lock; + private: const P2PVR::Data * currentRawData; }; diff --git a/p2pvr/ice/Jamfile.jam b/p2pvr/ice/Jamfile.jam index ca27324..98d6018 100644 --- a/p2pvr/ice/Jamfile.jam +++ b/p2pvr/ice/Jamfile.jam @@ -12,6 +12,7 @@ lib p2pvrice : ..//adhocutil ..//p2ice slicer + -fvisibility=hidden yes : : . diff --git a/p2pvr/ice/commonHelpers.h b/p2pvr/ice/commonHelpers.h index 3f7e57d..67e861c 100644 --- a/p2pvr/ice/commonHelpers.h +++ b/p2pvr/ice/commonHelpers.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace Common { template @@ -30,13 +31,13 @@ namespace Common { return o; } - boost::posix_time::ptime operator*(const Common::DateTime &); - boost::posix_time::time_duration operator*(const Common::Duration &); + DLL_PUBLIC boost::posix_time::ptime operator*(const Common::DateTime &); + DLL_PUBLIC boost::posix_time::time_duration operator*(const Common::Duration &); } namespace boost { namespace posix_time { - Common::DateTime operator*(const boost::posix_time::ptime &); - Common::Duration operator*(const boost::posix_time::time_duration &); + DLL_PUBLIC Common::DateTime operator*(const boost::posix_time::ptime &); + DLL_PUBLIC Common::Duration operator*(const boost::posix_time::time_duration &); } } diff --git a/p2pvr/ice/converters.cpp b/p2pvr/ice/converters.cpp index 2a6b3c2..2b5f653 100644 --- a/p2pvr/ice/converters.cpp +++ b/p2pvr/ice/converters.cpp @@ -5,53 +5,53 @@ template<> VariableType -IceConvert::ToVariable(const Common::DateTime & dt) +DLL_PUBLIC IceConvert::ToVariable(const Common::DateTime & dt) { return *dt; } template<> VariableType -IceConvert::ToVariable(const Common::Duration & d) +DLL_PUBLIC IceConvert::ToVariable(const Common::Duration & d) { return *d; } template<> Common::DateTime -IceConvert::FromVariable(const VariableType & dt) +DLL_PUBLIC IceConvert::FromVariable(const VariableType & dt) { return *dt.as(); } template<> Common::Duration -IceConvert::FromVariable(const VariableType & d) +DLL_PUBLIC IceConvert::FromVariable(const VariableType & d) { return *d.as(); } - + namespace Slicer { Common::DateTime - ptimeToDateTime(boost::posix_time::ptime const & p) + DLL_PUBLIC ptimeToDateTime(boost::posix_time::ptime const & p) { return *p; } boost::posix_time::ptime - dateTimeToPTime(Common::DateTime const & c) + DLL_PUBLIC dateTimeToPTime(Common::DateTime const & c) { return *c; } Common::Duration - timedurationToDuration(const boost::posix_time::time_duration & td) + DLL_PUBLIC timedurationToDuration(const boost::posix_time::time_duration & td) { return *td; } boost::posix_time::time_duration - durationToTimeDuration(const Common::Duration & td) + DLL_PUBLIC durationToTimeDuration(const Common::Duration & td) { return *td; } diff --git a/p2pvr/lib/Jamfile.jam b/p2pvr/lib/Jamfile.jam index 31974b7..1cb0033 100644 --- a/p2pvr/lib/Jamfile.jam +++ b/p2pvr/lib/Jamfile.jam @@ -22,6 +22,8 @@ lib p2pvrlib : ..//adhocutil ../ice//p2pvrice slicer + -fvisibility=hidden + release:-flto : : boost_filesystem ../ice//p2pvrice diff --git a/p2pvr/lib/bindTimerTask.h b/p2pvr/lib/bindTimerTask.h index 8c82680..f420ee0 100644 --- a/p2pvr/lib/bindTimerTask.h +++ b/p2pvr/lib/bindTimerTask.h @@ -3,8 +3,9 @@ #include #include +#include -class BindTimerTask : public IceUtil::TimerTask { +class DLL_PUBLIC BindTimerTask : public IceUtil::TimerTask { public: typedef boost::function Event; BindTimerTask(const Event & event); diff --git a/p2pvr/lib/fileHandle.h b/p2pvr/lib/fileHandle.h index 3c8d45e..0a3b7fc 100644 --- a/p2pvr/lib/fileHandle.h +++ b/p2pvr/lib/fileHandle.h @@ -1,7 +1,9 @@ #ifndef FILEHANDLE_H #define FILEHANDLE_H -class FileHandle { +#include + +class DLL_PUBLIC FileHandle { public: FileHandle(int fd); ~FileHandle(); diff --git a/p2pvr/lib/muxer.h b/p2pvr/lib/muxer.h index cf0db1c..f0563a4 100644 --- a/p2pvr/lib/muxer.h +++ b/p2pvr/lib/muxer.h @@ -5,8 +5,9 @@ #include #include #include +#include -class Muxer : public P2PVR::RawDataClient { +class DLL_PUBLIC Muxer : public P2PVR::RawDataClient { public: Muxer(const P2PVR::RawDataClientPrx & target, const std::string & cmd); ~Muxer(); @@ -14,9 +15,9 @@ class Muxer : public P2PVR::RawDataClient { bool NewData(const P2PVR::Data &, const Ice::Current &); private: - bool ReadWaiting() const; - bool ReadAvailable() const; - bool ReadMuxerAndSend(int wait) const; + DLL_PRIVATE bool ReadWaiting() const; + DLL_PRIVATE bool ReadAvailable() const; + DLL_PRIVATE bool ReadMuxerAndSend(int wait) const; const P2PVR::RawDataClientPrx target; typedef boost::shared_ptr ProcessPipesPtr; ProcessPipesPtr fds; diff --git a/p2pvr/lib/p2Helpers.h b/p2pvr/lib/p2Helpers.h index 3b73f1b..d94d161 100644 --- a/p2pvr/lib/p2Helpers.h +++ b/p2pvr/lib/p2Helpers.h @@ -3,8 +3,10 @@ #include #include +#include template +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, T & v) { @@ -13,14 +15,17 @@ operator>>(const VariableType & vt, T & v) } template <> +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, Common::Duration & d); template <> +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, Common::DateTime & dt); template +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, IceUtil::Optional & v) { @@ -35,10 +40,12 @@ operator>>(const VariableType & vt, IceUtil::Optional & v) } template <> +DLL_PUBLIC const VariableType & operator>>(const VariableType & vt, short int & v); template +DLL_PUBLIC VariableType & operator<<(VariableType & vt, const T & v) { @@ -47,14 +54,17 @@ operator<<(VariableType & vt, const T & v) } template <> +DLL_PUBLIC VariableType & operator<<(VariableType & vt, const Common::Duration & d); template <> +DLL_PUBLIC VariableType & operator<<(VariableType & vt, const Common::DateTime & dt); template +DLL_PUBLIC VariableType & operator<<(VariableType & vt, const IceUtil::Optional & v) { diff --git a/p2pvr/lib/serviceStreamer.h b/p2pvr/lib/serviceStreamer.h index bff14ec..c4aa93e 100644 --- a/p2pvr/lib/serviceStreamer.h +++ b/p2pvr/lib/serviceStreamer.h @@ -2,8 +2,9 @@ #define SERVICESTREAMER_H #include "serviceStreamerCore.h" +#include -class ServiceStreamer : public ServiceStreamerCore { +class DLL_PUBLIC ServiceStreamer : public ServiceStreamerCore { public: ServiceStreamer(int sid, P2PVR::RawDataClientPrx, const Ice::CommunicatorPtr & ic, const Ice::ObjectAdapterPtr & a); ServiceStreamer(int sid, P2PVR::RawDataClientPrx, const P2PVR::DevicesPrx & d, const P2PVR::SIPrx & s, const Ice::ObjectAdapterPtr & a); diff --git a/p2pvr/lib/serviceStreamerCore.h b/p2pvr/lib/serviceStreamerCore.h index 4af422a..1db80f8 100644 --- a/p2pvr/lib/serviceStreamerCore.h +++ b/p2pvr/lib/serviceStreamerCore.h @@ -8,8 +8,9 @@ #include "temporaryIceAdapterObject.h" #include #include +#include -class ServiceStreamerCore { +class DLL_PUBLIC ServiceStreamerCore { public: ServiceStreamerCore(int sid, P2PVR::RawDataClientPrx, P2PVR::RawDataClientPrx, P2PVR::RawDataClientPrx, P2PVR::DevicesPrx, Ice::ObjectAdapterPtr); diff --git a/p2pvr/lib/temporaryIceAdapterObject.h b/p2pvr/lib/temporaryIceAdapterObject.h index d7fc77d..0614066 100644 --- a/p2pvr/lib/temporaryIceAdapterObject.h +++ b/p2pvr/lib/temporaryIceAdapterObject.h @@ -2,9 +2,10 @@ #define TEMPORARYICEADAPTER_H #include +#include template -class TemporaryIceAdapterObject { +class DLL_PUBLIC TemporaryIceAdapterObject { public: TemporaryIceAdapterObject(Ice::ObjectAdapterPtr a, IceUtil::Handle o) : adapter(a), diff --git a/p2pvr/p2comp/Jamfile.jam b/p2pvr/p2comp/Jamfile.jam index 10b7fea..6540d77 100644 --- a/p2pvr/p2comp/Jamfile.jam +++ b/p2pvr/p2comp/Jamfile.jam @@ -1,11 +1,13 @@ lib p2pvrp2comp : [ glob-tree *.cpp ] - : : + : ../ice//p2pvrice ../lib//p2pvrlib ..//p2streams ..//p2ice ..//p2cgi ..//adhocutil + -fvisibility=hidden + release:-flto ../ice//p2pvrice ; -- cgit v1.2.3