diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-03-21 08:37:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-04-23 16:49:43 +0200 |
commit | 290d22210040a7b373e2dc9084240cdeffa1fa3a (patch) | |
tree | 78f090fe5d9da0e4b1d486a39c605c784637b67f /odb/mssql/statement-cache.hxx | |
parent | c1b8b6f16e4881e57aa0da67e6f09ad71ee6099d (diff) |
Polymorphic inheritance support
Diffstat (limited to 'odb/mssql/statement-cache.hxx')
-rw-r--r-- | odb/mssql/statement-cache.hxx | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/odb/mssql/statement-cache.hxx b/odb/mssql/statement-cache.hxx index d9476d4..9f2cb47 100644 --- a/odb/mssql/statement-cache.hxx +++ b/odb/mssql/statement-cache.hxx @@ -11,11 +11,11 @@ #include <typeinfo> #include <odb/forward.hxx> +#include <odb/traits.hxx> #include <odb/mssql/version.hxx> +#include <odb/mssql/forward.hxx> #include <odb/mssql/statements-base.hxx> -#include <odb/mssql/object-statements.hxx> -#include <odb/mssql/view-statements.hxx> #include <odb/details/shared-ptr.hxx> #include <odb/details/type-info.hxx> @@ -26,49 +26,18 @@ namespace odb { namespace mssql { - class connection; - class LIBODB_MSSQL_EXPORT statement_cache { public: - statement_cache (connection& conn) - : conn_ (conn) - { - } + statement_cache (connection& conn): conn_ (conn) {} template <typename T> - typename object_statements_selector<T>::type& - find_object () - { - typedef typename object_statements_selector<T>::type object_statements; - - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast<object_statements&> (*i->second); - - details::shared_ptr<object_statements> p ( - new (details::shared) object_statements (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } + typename object_traits<T>::statements_type& + find_object (); template <typename T> view_statements<T>& - find_view () - { - map::iterator i (map_.find (&typeid (T))); - - if (i != map_.end ()) - return static_cast<view_statements<T>&> (*i->second); - - details::shared_ptr<view_statements<T> > p ( - new (details::shared) view_statements<T> (conn_)); - - map_.insert (map::value_type (&typeid (T), p)); - return *p; - } + find_view (); private: typedef std::map<const std::type_info*, @@ -81,6 +50,8 @@ namespace odb } } +#include <odb/mssql/statement-cache.txx> + #include <odb/post.hxx> #endif // ODB_MSSQL_STATEMENT_CACHE_HXX |