From 652e7bb6fa67d9f1816eb2f77915101055b6e686 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 17 Jan 2015 02:55:49 +0000 Subject: Migrate schedulecandidate to slicer model and migrate remaining bits of schedules impl to SQL deserializer --- p2pvr/daemon/schedules.cpp | 36 +++++------------------------------- p2pvr/ice/p2pvr.ice | 13 +++++++++++++ 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 86ac5fb..1590312 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -7,6 +7,7 @@ #include #include #include "p2Helpers.h" +#include "commonHelpers.h" #include "containerIterator.h" #include "resources.h" #include @@ -30,19 +31,6 @@ DECLARE_OPTIONS(Schedules, "P2PVR Scheduler options") "Implementation of episode group scheduler problem solver") END_OPTIONS() -class ScheduleCandidate { - public: - std::string What; - int EventUid; - int TransportStreamId; - datetime StartTime; - datetime StopTime; - int Priority; - int ScheduleId; -}; -typedef boost::shared_ptr ScheduleCandidatePtr; -typedef std::vector ScheduleCandidates; - enum RecordStatuses { Record_WillRecordThisShowing = 0, Record_WillRecordOtherShowing = 1, @@ -76,7 +64,7 @@ CreateColumns(const ColumnCreator & cc) template<> void -CreateColumns(const ColumnCreator & cc) +CreateColumns(const ColumnCreator & cc) { cc("what", true); cc("serviceid", false); @@ -88,19 +76,6 @@ CreateColumns(const ColumnCreator & cc) cc("scheduleid", false); } -template<> -void -UnbindColumns(RowState & rs, ScheduleCandidatePtr const & s) -{ - rs.fields[0] >> s->What; - rs.fields[1] >> s->EventUid; - rs.fields[2] >> s->TransportStreamId; - rs.fields[3] >> s->StartTime; - rs.fields[4] >> s->StopTime; - rs.fields[5] >> s->Priority; - rs.fields[6] >> s->ScheduleId; -} - template<> void CreateColumns(const ColumnCreator & cc) @@ -295,9 +270,8 @@ Schedules::DoReschedule(const Ice::Current & ice) unsigned int tunerCount = devs->TunerCount(); // Load list from database - ScheduleCandidates episodes; - SqlContainerCreator cct(episodes); - cct.populate(Select(Schedules_getCandidates).second); + auto episodes = Slicer::DeserializeAny( + *Select(Schedules_getCandidates).second); Episodes scheduleList; Showings allShowings; @@ -309,7 +283,7 @@ Schedules::DoReschedule(const Ice::Current & ice) scheduleList.push_back(cur); } ShowingPtr s = new Showing(c->EventUid, c->TransportStreamId, c->ScheduleId, - c->StartTime, c->StopTime, c->Priority, cur.get()); + *c->StartTime, *c->StopTime, c->Priority, cur.get()); minPriority = std::min(minPriority, s->priority); cur->showings.push_back(s); allShowings.push_back(s); diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index ff9b859..2d9cde2 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -73,6 +73,19 @@ module P2PVR { void Send(string guid, RawDataClient * target, long start, long len) throws StorageException; }; + class ScheduleCandidate { + string What; + int EventUid; + int TransportStreamId; + [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime" ] + Common::DateTime StartTime; + [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime" ] + Common::DateTime StopTime; + int Priority; + int ScheduleId; + }; + sequence ScheduleCandidates; + interface Recordings { idempotent int NewRecording(Recording rec); ["project2:task"] -- cgit v1.2.3