summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p2pvr/daemon/dbClient.h8
-rw-r--r--p2pvr/daemon/recordings.cpp3
-rw-r--r--p2pvr/daemon/schedules.cpp7
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 <sqlVariableBinder.h>
#include <sqlHandleAsVariableType.h>
#include "p2Helpers.h"
+#include <slicer/slicer.h>
class SqlMergeTask;
@@ -40,6 +41,13 @@ class DatabaseClient : public virtual CommonObjects {
return {db, cmd};
}
+ template <typename SerializerType, typename Obj, typename ... ExtraArgs>
+ void Store(const Obj & o, const ExtraArgs & ... ea) const
+ {
+ auto db = dataSource<RdbmsDataSource>("postgres")->getWritable();
+ Slicer::SerializeAny<SerializerType>(o, db.get(), ea...);
+ }
+
template <typename... Args>
std::pair<RdbmsDataSource::ConnectionRef, SelectPtr> 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<RdbmsDataSource>("postgres")->getWritable();
- Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(r, db.get(), "recordings");
+ Store<Slicer::SqlFetchIdInsertSerializer>(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 <slicer/db/sqlSelectDeserializer.h>
#include <slicer/db/sqlInsertSerializer.h>
#include <slicer/db/sqlUpdateSerializer.h>
-#include <slicer/slicer.h>
#include <p2pvr-int.h>
#include <privateExecContext.h>
@@ -334,8 +333,7 @@ Ice::Int
Schedules::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
{
TxHelper tx(this);
- auto db = dataSource<RdbmsDataSource>("postgres")->getWritable();
- Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(s, db.get(), "schedules");
+ Store<Slicer::SqlFetchIdInsertSerializer>(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<RdbmsDataSource>("postgres")->getWritable();
- Slicer::SerializeAny<Slicer::SqlUpdateSerializer>(s, db.get(), "schedules");
+ Store<Slicer::SqlUpdateSerializer>(s, "schedules");
DoReschedule(ice);
}