summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2013-12-10 22:29:45 +0000
committerrandomdan <randomdan@localhost>2013-12-10 22:29:45 +0000
commitedbe412526f1722fb0538ea2db979296f705847d (patch)
treeab604a0c0d50e0429dbdeb931352de6195a48969
parentCentralise the DB code (diff)
downloadp2pvr-edbe412526f1722fb0538ea2db979296f705847d.tar.bz2
p2pvr-edbe412526f1722fb0538ea2db979296f705847d.tar.xz
p2pvr-edbe412526f1722fb0538ea2db979296f705847d.zip
Extend container helpers to support different pointer types
-rw-r--r--p2pvr/lib/containerCreator.h10
-rw-r--r--p2pvr/lib/sqlContainerCreator.h8
2 files changed, 10 insertions, 8 deletions
diff --git a/p2pvr/lib/containerCreator.h b/p2pvr/lib/containerCreator.h
index da4eced..9804d9b 100644
--- a/p2pvr/lib/containerCreator.h
+++ b/p2pvr/lib/containerCreator.h
@@ -2,8 +2,10 @@
#define CONTAINERCREATOR_H
#include <boost/function.hpp>
+#include <Ice/Handle.h>
+#include "objectRowState.h"
-template <typename T, typename V>
+template <typename T, typename V, typename P = IceInternal::Handle<V>>
class ContainerCreator {
public:
ContainerCreator(T & c) : container(c) { }
@@ -14,13 +16,13 @@ class ContainerCreator {
unsigned int columnCount)
{
while (fetch()) {
- auto v = new V;
+ auto v = P(new V);
container.push_back(v);
- ObjectRowState<IceInternal::Handle<V>> rs;
+ ObjectRowState<P> rs;
for (unsigned int c = 0; c < columnCount; c++) {
rs.fields[c] = get(c);
}
- UnbindColumns<IceInternal::Handle<V>>(rs, v);
+ UnbindColumns<P>(rs, v);
}
}
private:
diff --git a/p2pvr/lib/sqlContainerCreator.h b/p2pvr/lib/sqlContainerCreator.h
index 896a6de..5c8d8f8 100644
--- a/p2pvr/lib/sqlContainerCreator.h
+++ b/p2pvr/lib/sqlContainerCreator.h
@@ -6,15 +6,15 @@
#include <selectcommand.h>
#include <sqlHandleAsVariableType.h>
-template <typename T, typename V>
-class SqlContainerCreator : public ContainerCreator<T, V> {
+template <typename T, typename V, typename P = IceInternal::Handle<V>>
+class SqlContainerCreator : public ContainerCreator<T, V, P> {
public:
- SqlContainerCreator(T & c) : ContainerCreator<T, V>(c) { }
+ SqlContainerCreator(T & c) : ContainerCreator<T, V, P>(c) { }
void populate(boost::shared_ptr<DB::SelectCommand> sel)
{
sel->execute();
- ContainerCreator<T, V>::populate(boost::bind(&DB::SelectCommand::fetch, sel), [sel](unsigned int c) {
+ ContainerCreator<T, V, P>::populate(boost::bind(&DB::SelectCommand::fetch, sel), [sel](unsigned int c) {
HandleAsVariableType h;
const DB::Column & col = (*sel)[c];
col.apply(h);