From 4ed084c468e806ffbaae15e0858d2aa6030d2529 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 20 Sep 2015 21:20:58 +0100 Subject: Add adhoc factory support --- libdbpp/connection.cpp | 11 +++++++++++ libdbpp/connection.h | 4 ++++ 2 files changed, 15 insertions(+) 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 +#include DB::Connection::~Connection() { @@ -37,3 +39,12 @@ DB::Connection::releaseSavepoint(const std::string & sp) const execute("RELEASE SAVEPOINT " + sp); } +boost::optional +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 +#include #include 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 resolvePlugin(const std::type_info &, const std::string &); private: }; + + typedef AdHoc::Factory ConnectionFactory; } #endif -- cgit v1.2.3