summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-09-20 21:20:58 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-09-20 21:20:58 +0100
commit4ed084c468e806ffbaae15e0858d2aa6030d2529 (patch)
treeeba0da2840576de00fb1cf5f1a18a3c129d0834d
parentRename target .so (diff)
downloadlibdbpp-4ed084c468e806ffbaae15e0858d2aa6030d2529.tar.bz2
libdbpp-4ed084c468e806ffbaae15e0858d2aa6030d2529.tar.xz
libdbpp-4ed084c468e806ffbaae15e0858d2aa6030d2529.zip
Add adhoc factory support
-rw-r--r--libdbpp/connection.cpp11
-rw-r--r--libdbpp/connection.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp
index c42c4fb..2d93ce3 100644
--- a/libdbpp/connection.cpp
+++ b/libdbpp/connection.cpp
@@ -1,5 +1,7 @@
#include "connection.h"
#include "modifycommand.h"
+#include <factory.impl.h>
+#include <buffer.h>
DB::Connection::~Connection()
{
@@ -37,3 +39,12 @@ DB::Connection::releaseSavepoint(const std::string & sp) const
execute("RELEASE SAVEPOINT " + sp);
}
+boost::optional<std::string>
+DB::Connection::resolvePlugin(const std::type_info &, const std::string & name)
+{
+ return stringbf("libdbpp-%s.so", name);
+}
+
+INSTANIATEFACTORY(DB::Connection, std::string);
+PLUGINRESOLVER(DB::ConnectionFactory, DB::Connection::resolvePlugin);
+
diff --git a/libdbpp/connection.h b/libdbpp/connection.h
index 2da3f05..9c6b46e 100644
--- a/libdbpp/connection.h
+++ b/libdbpp/connection.h
@@ -2,6 +2,7 @@
#define CONNECTION_H
#include <string>
+#include <factory.h>
#include <visibility.h>
namespace DB {
@@ -41,8 +42,11 @@ namespace DB {
virtual void endBulkUpload(const char *) const = 0;
virtual size_t bulkUploadData(const char *, size_t) const = 0;
+ static boost::optional<std::string> resolvePlugin(const std::type_info &, const std::string &);
private:
};
+
+ typedef AdHoc::Factory<Connection, std::string> ConnectionFactory;
}
#endif