From 40267e1f40de8ea216688886ab1df1c7ec50e2b2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Apr 2012 16:48:02 +0200 Subject: Polymorphic inheritance support --- odb/pgsql/statement-cache.txx | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 odb/pgsql/statement-cache.txx (limited to 'odb/pgsql/statement-cache.txx') diff --git a/odb/pgsql/statement-cache.txx b/odb/pgsql/statement-cache.txx new file mode 100644 index 0000000..40ed170 --- /dev/null +++ b/odb/pgsql/statement-cache.txx @@ -0,0 +1,43 @@ +// file : odb/pgsql/statement-cache.txx +// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace pgsql + { + template + typename object_traits::statements_type& statement_cache:: + find_object () + { + typedef typename object_traits::statements_type statements_type; + + map::iterator i (map_.find (&typeid (T))); + + if (i != map_.end ()) + return static_cast (*i->second); + + details::shared_ptr p ( + new (details::shared) statements_type (conn_)); + + map_.insert (map::value_type (&typeid (T), p)); + return *p; + } + + template + view_statements& statement_cache:: + 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; + } + } +} -- cgit v1.1