summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--p2pvr/lib/dbClient.cpp22
-rw-r--r--p2pvr/lib/dbClient.h18
-rw-r--r--p2pvr/lib/si.cpp19
-rw-r--r--p2pvr/lib/si.h10
4 files changed, 42 insertions, 27 deletions
diff --git a/p2pvr/lib/dbClient.cpp b/p2pvr/lib/dbClient.cpp
new file mode 100644
index 0000000..e085c86
--- /dev/null
+++ b/p2pvr/lib/dbClient.cpp
@@ -0,0 +1,22 @@
+#include "dbClient.h"
+#include <rdbmsDataSource.h>
+#include <sqlVariableBinder.h>
+
+DatabaseClient::SelectPtr
+DatabaseClient::Select(const std::string & sql) const
+{
+ auto db = dataSource<RdbmsDataSource>("postgres");
+ return SelectPtr(db->getReadonly().newSelectCommand(sql));
+}
+DatabaseClient::SelectPtr
+DatabaseClient::Select(const std::string & sql, const std::list<VariableType> & vs) const
+{
+ SelectPtr sel(Select(sql));
+ unsigned int offset = 0;
+ BOOST_FOREACH(const auto & v, vs) {
+ boost::apply_visitor<const SqlVariableBinder, const VariableType>(SqlVariableBinder(sel.get(), offset++), v);
+ }
+ return sel;
+}
+
+
diff --git a/p2pvr/lib/dbClient.h b/p2pvr/lib/dbClient.h
new file mode 100644
index 0000000..62dafef
--- /dev/null
+++ b/p2pvr/lib/dbClient.h
@@ -0,0 +1,18 @@
+#ifndef DBCLIENT_H
+#define DBCLIENT_H
+
+#include <commonObjects.h>
+#include <variableType.h>
+#include <list>
+#include <selectcommand.h>
+
+class DatabaseClient : public virtual CommonObjects {
+ public:
+ typedef boost::shared_ptr<DB::SelectCommand> SelectPtr;
+ protected:
+ SelectPtr Select(const std::string &) const;
+ SelectPtr Select(const std::string &, const std::list<VariableType> &) const;
+};
+
+#endif
+
diff --git a/p2pvr/lib/si.cpp b/p2pvr/lib/si.cpp
index 98b2316..e63e060 100644
--- a/p2pvr/lib/si.cpp
+++ b/p2pvr/lib/si.cpp
@@ -2,26 +2,7 @@
#include "dvbsiHelpers.h"
#include "sqlContainerCreator.h"
#include <linux/dvb/frontend.h>
-#include <rdbmsDataSource.h>
#include <logger.h>
-#include <sqlVariableBinder.h>
-
-SI::SelectPtr
-SI::Select(const std::string & sql) const
-{
- auto db = dataSource<RdbmsDataSource>("postgres");
- return SelectPtr(db->getReadonly().newSelectCommand(sql));
-}
-SI::SelectPtr
-SI::Select(const std::string & sql, const std::list<VariableType> & vs) const
-{
- SelectPtr sel(Select(sql));
- unsigned int offset = 0;
- BOOST_FOREACH(const auto & v, vs) {
- boost::apply_visitor<const SqlVariableBinder, const VariableType>(SqlVariableBinder(sel.get(), offset++), v);
- }
- return sel;
-}
P2PVR::Deliveries
SI::GetAllDeliveries(short type, const Ice::Current &)
diff --git a/p2pvr/lib/si.h b/p2pvr/lib/si.h
index 508c0fe..053ac77 100644
--- a/p2pvr/lib/si.h
+++ b/p2pvr/lib/si.h
@@ -2,21 +2,15 @@
#define P2PVR_SI_H
#include <p2pvr.h>
-#include <commonObjects.h>
-#include <selectcommand.h>
+#include "dbClient.h"
-class SI : public P2PVR::SI, public virtual CommonObjects {
+class SI : public P2PVR::SI, public DatabaseClient {
public:
- typedef boost::shared_ptr<DB::SelectCommand> SelectPtr;
-
P2PVR::Deliveries GetAllDeliveries(short type, const Ice::Current &);
DVBSI::DeliveryPtr GetDeliveryForService(int id, const Ice::Current &);
DVBSI::DeliveryPtr GetDeliveryForTransport(int id, const Ice::Current &);
DVBSI::ServiceList GetServices(const Ice::Current &);
DVBSI::ServicePtr GetService(int id, const Ice::Current &);
- protected:
- SelectPtr Select(const std::string &) const;
- SelectPtr Select(const std::string &, const std::list<VariableType> &) const;
};
#endif