summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-01-17 02:55:49 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-06-13 17:29:47 +0100
commit652e7bb6fa67d9f1816eb2f77915101055b6e686 (patch)
tree251541fe95c7feff5e8039d803f238d12e9fa98d
parentRemove some no longer required UnbindColumns impls (diff)
downloadp2pvr-652e7bb6fa67d9f1816eb2f77915101055b6e686.tar.bz2
p2pvr-652e7bb6fa67d9f1816eb2f77915101055b6e686.tar.xz
p2pvr-652e7bb6fa67d9f1816eb2f77915101055b6e686.zip
Migrate schedulecandidate to slicer model and migrate remaining bits of schedules impl to SQL deserializer
-rw-r--r--p2pvr/daemon/schedules.cpp36
-rw-r--r--p2pvr/ice/p2pvr.ice13
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 <sqlVariableBinder.h>
#include <sqlMergeTask.h>
#include "p2Helpers.h"
+#include "commonHelpers.h"
#include "containerIterator.h"
#include "resources.h"
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -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<ScheduleCandidate> ScheduleCandidatePtr;
-typedef std::vector<ScheduleCandidatePtr> ScheduleCandidates;
-
enum RecordStatuses {
Record_WillRecordThisShowing = 0,
Record_WillRecordOtherShowing = 1,
@@ -76,7 +64,7 @@ CreateColumns<P2PVR::ScheduledToRecordPtr>(const ColumnCreator & cc)
template<>
void
-CreateColumns<ScheduleCandidatePtr>(const ColumnCreator & cc)
+CreateColumns<P2PVR::ScheduleCandidatePtr>(const ColumnCreator & cc)
{
cc("what", true);
cc("serviceid", false);
@@ -90,19 +78,6 @@ CreateColumns<ScheduleCandidatePtr>(const ColumnCreator & cc)
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<P2PVR::SchedulePtr>(const ColumnCreator & cc)
{
cc("scheduleid", true);
@@ -295,9 +270,8 @@ Schedules::DoReschedule(const Ice::Current & ice)
unsigned int tunerCount = devs->TunerCount();
// Load list from database
- ScheduleCandidates episodes;
- SqlContainerCreator<ScheduleCandidates, ScheduleCandidate, ScheduleCandidatePtr> cct(episodes);
- cct.populate(Select(Schedules_getCandidates).second);
+ auto episodes = Slicer::DeserializeAny<SqlSelectDeserializer, P2PVR::ScheduleCandidates>(
+ *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<ScheduleCandidate> ScheduleCandidates;
+
interface Recordings {
idempotent int NewRecording(Recording rec);
["project2:task"]