From 8faada3aee1fc38d0b19271ada36a4efc4c41622 Mon Sep 17 00:00:00 2001 From: Frank Park Date: Wed, 12 Apr 2017 01:00:24 -0400 Subject: [PATCH] replace query_task with bind, rename helper functions, clean up implementation --- include/sqlpp11/connection_pool.h | 24 ++++++++++++------------ include/sqlpp11/pool_connection.h | 22 +++++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/sqlpp11/connection_pool.h b/include/sqlpp11/connection_pool.h index 2c90c924..b29bb2e5 100644 --- a/include/sqlpp11/connection_pool.h +++ b/include/sqlpp11/connection_pool.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include namespace sqlpp { @@ -131,7 +131,7 @@ namespace sqlpp template ::value, Connection_config::connection>::type> - class connection_pool + class connection_pool_t { friend pool_connection; @@ -164,15 +164,15 @@ namespace sqlpp } public: - connection_pool(const std::shared_ptr& config, size_t pool_size) + connection_pool_t(const std::shared_ptr& config, size_t pool_size) : config(config), maximum_pool_size(pool_size), connection_validator(Connection_validator()) {} - ~connection_pool() = default; - connection_pool(const connection_pool&) = delete; - connection_pool(connection_pool&& other) + ~connection_pool_t() = default; + connection_pool_t(const connection_pool_t&) = delete; + connection_pool_t(connection_pool_t&& other) : config(std::move(other.config)), maximum_pool_size(std::move(other.maximum_pool_size)), connection_validator(std::move(other.connection_validator)) {} - connection_pool& operator=(const connection_pool&) = delete; - connection_pool& operator=(connection_pool&&) = delete; + connection_pool_t& operator=(const connection_pool_t&) = delete; + connection_pool_t& operator=(connection_pool_t&&) = delete; auto get_connection() -> pool_connection @@ -214,7 +214,7 @@ namespace sqlpp template void operator()(Query query, Lambda callback) { - query_task(*this, query, callback)(); + sqlpp::bind(*this, query, callback)(); } template @@ -227,10 +227,10 @@ namespace sqlpp template::value, Connection_config::connection>::type> - auto make_connection_pool(const std::shared_ptr& config, size_t max_pool_size) - -> connection_pool + auto connection_pool(const std::shared_ptr& config, size_t max_pool_size) + -> connection_pool_t { - return connection_pool(config, max_pool_size); + return connection_pool_t(config, max_pool_size); } } diff --git a/include/sqlpp11/pool_connection.h b/include/sqlpp11/pool_connection.h index f4eea7dc..cc9bfe09 100644 --- a/include/sqlpp11/pool_connection.h +++ b/include/sqlpp11/pool_connection.h @@ -28,12 +28,13 @@ #define SQLPP_POOL_CONNECTION_H #include +#include #include namespace sqlpp { template > + typename Connection_pool = connection_pool_t> struct pool_connection : public sqlpp::connection { private: @@ -57,6 +58,13 @@ namespace sqlpp } } + pool_connection(const pool_connection&) = delete; + pool_connection(pool_connection&& other) : _impl(std::move(other._impl)), origin(other.origin) + { + } + pool_connection& operator=(const pool_connection&) = delete; + pool_connection& operator=(pool_connection&& other) = default; + template auto operator()(Args&&... args) -> decltype(_impl->args(std::forward(args)...)) { @@ -80,18 +88,6 @@ namespace sqlpp { return _impl->prepare(t); } - - pool_connection(const pool_connection&) = delete; - pool_connection(pool_connection&& other) : _impl(std::move(other._impl)), origin(other.origin) - { - } - pool_connection& operator=(const pool_connection&) = delete; - pool_connection& operator=(pool_connection&& other) - { - _impl = std::move(other._impl); - origin = other.origin; - return *this; - } }; }