From 7ce07d1c371e32e474897e8b03da7e330aaefb57 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Sep 2011 16:56:07 +0200 Subject: Support for views; native part --- odb/pgsql/statement-cache.hxx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'odb/pgsql/statement-cache.hxx') diff --git a/odb/pgsql/statement-cache.hxx b/odb/pgsql/statement-cache.hxx index 8164cd8..986aa9a 100644 --- a/odb/pgsql/statement-cache.hxx +++ b/odb/pgsql/statement-cache.hxx @@ -13,12 +13,14 @@ #include -#include -#include - #include #include +#include +#include +#include +#include + #include namespace odb @@ -37,7 +39,7 @@ namespace odb template object_statements& - find () + find_object () { map::iterator i (map_.find (&typeid (T))); @@ -51,9 +53,25 @@ namespace odb 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; + } + private: typedef std::map, + details::shared_ptr, details::type_info_comparator> map; connection& conn_; -- cgit v1.1