diff options
Diffstat (limited to 'odb/pgsql/statement-cache.hxx')
-rw-r--r-- | odb/pgsql/statement-cache.hxx | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/odb/pgsql/statement-cache.hxx b/odb/pgsql/statement-cache.hxx index dc9d171..90bc2f6 100644 --- a/odb/pgsql/statement-cache.hxx +++ b/odb/pgsql/statement-cache.hxx @@ -11,14 +11,14 @@ #include <typeinfo> #include <odb/forward.hxx> +#include <odb/traits.hxx> #include <odb/details/shared-ptr.hxx> #include <odb/details/type-info.hxx> #include <odb/pgsql/version.hxx> +#include <odb/pgsql/forward.hxx> #include <odb/pgsql/statements-base.hxx> -#include <odb/pgsql/object-statements.hxx> -#include <odb/pgsql/view-statements.hxx> #include <odb/pgsql/details/export.hxx> @@ -26,49 +26,18 @@ namespace odb { namespace pgsql { - class connection; - class LIBODB_PGSQL_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/pgsql/statement-cache.txx> + #include <odb/post.hxx> #endif // ODB_PGSQL_STATEMENT_CACHE_HXX |