diff options
Diffstat (limited to 'p2pvr/daemon/schedules.cpp')
-rw-r--r-- | p2pvr/daemon/schedules.cpp | 54 |
1 files changed, 6 insertions, 48 deletions
diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp index 5b0b5cd..267e1dd 100644 --- a/p2pvr/daemon/schedules.cpp +++ b/p2pvr/daemon/schedules.cpp @@ -30,48 +30,6 @@ DECLARE_OPTIONS(Schedules, "P2PVR Scheduler options") "Implementation of episode group scheduler problem solver") END_OPTIONS() -enum RecordStatuses { - Record_WillRecordThisShowing = 0, - Record_WillRecordOtherShowing = 1, - Record_CannotRecordAnyShowing = 2 -}; - -class Record { - public: - Record() { }; - Record(int e, RecordStatuses rs, int sc) : - EventUid(e), - RecordStatus(rs), - ScheduleId(sc) - { - } - - int EventUid; - RecordStatuses RecordStatus; - int ScheduleId; -}; -typedef boost::shared_ptr<Record> RecordPtr; -typedef std::vector<RecordPtr> Records; - -template<> -SelectedColumns -CreateColumns<RecordPtr>(const ColumnCreator & cc) -{ - cc("eventuid", true); - cc("recordstatus", false); - cc("scheduleid", false); - return {true, true, true}; -} - -template<> -void -BindColumns(RowState & rs, const SelectedColumns &, RecordPtr const & s) -{ - rs.fields[0] << s->EventUid; - rs.fields[1] << (int)s->RecordStatus; - rs.fields[2] << s->ScheduleId; -} - Showing::Showing(unsigned int e, unsigned int t, unsigned int sc, datetime start, datetime stop, int p, const Episode * ep) : episode(ep), eventUid(e), @@ -261,7 +219,7 @@ Schedules::DoReschedule(const Ice::Current & ice) e->priority /= e->showings.size(); } - Records records; + P2PVR::ScheduledToRecordList records; // Solve while (!scheduleList.empty()) { auto work = scheduleList.begin(); @@ -315,10 +273,10 @@ Schedules::DoReschedule(const Ice::Current & ice) } for (const auto & i : c->showings) { if (i) { - records.push_back(RecordPtr(new Record(i->eventUid, + records.push_back(new P2PVR::ScheduledToRecord(i->eventUid, found ? - selected.find(i) != selected.end() ? Record_WillRecordThisShowing : Record_WillRecordOtherShowing : - Record_CannotRecordAnyShowing, i->scheduleId))); + selected.find(i) != selected.end() ? P2PVR::WillRecordThisShowing : P2PVR::WillRecordOtherShowing : + P2PVR::CannotRecordAnyShowing, i->scheduleId)); } } } @@ -326,8 +284,8 @@ Schedules::DoReschedule(const Ice::Current & ice) TxHelper tx(this); SqlMergeTask mergeRecords("postgres", "record"); - auto rcs = CreateColumns<RecordPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeRecords, _1, _2)); - mergeRecords.sources.insert(new ContainerIterator<Records>(&records, rcs)); + auto rcs = CreateColumns<P2PVR::ScheduledToRecordPtr>(boost::bind(&DatabaseClient::SqlMergeColumnsInserter, &mergeRecords, _1, _2)); + mergeRecords.sources.insert(new ContainerIterator<P2PVR::ScheduledToRecordList>(&records, rcs)); mergeRecords.loadComplete(this); mergeRecords.execute(NULL); tx.Commit(); |