From 42503207920b9264e04c97cb6a5c53214fd2eff8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Apr 2012 16:48:01 +0200 Subject: Polymorphic inheritance support --- odb/mysql/statement-cache.hxx | 44 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 36 deletions(-) (limited to 'odb/mysql/statement-cache.hxx') diff --git a/odb/mysql/statement-cache.hxx b/odb/mysql/statement-cache.hxx index e62c76c..f801972 100644 --- a/odb/mysql/statement-cache.hxx +++ b/odb/mysql/statement-cache.hxx @@ -11,11 +11,11 @@ #include #include +#include #include +#include #include -#include -#include #include #include @@ -26,49 +26,19 @@ namespace odb { namespace mysql { - class connection; - class LIBODB_MYSQL_EXPORT statement_cache { public: - statement_cache (connection& conn) - : conn_ (conn) - { - } + statement_cache (connection& conn): conn_ (conn) {} template - typename object_statements_selector::type& - find_object () - { - typedef typename object_statements_selector::type object_statements; - - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast (*i->second); - - details::shared_ptr p ( - new (details::shared) object_statements (conn_)); + typename object_traits::statements_type& + find_object (); - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } template view_statements& - find_view () - { - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast&> (*i->second); - - details::shared_ptr > p ( - new (details::shared) view_statements (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } + find_view (); private: typedef std::map + #include #endif // ODB_MYSQL_STATEMENT_CACHE_HXX -- cgit v1.1