aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/statement-cache.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-04-23 16:48:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-04-23 16:48:01 +0200
commit42503207920b9264e04c97cb6a5c53214fd2eff8 (patch)
treedd192b60515188e2afd6f11e7cc54aac73f571e4 /odb/mysql/statement-cache.txx
parent4d0711124bb6cdca491e33a51911d20090a1879a (diff)
Polymorphic inheritance support
Diffstat (limited to 'odb/mysql/statement-cache.txx')
-rw-r--r--odb/mysql/statement-cache.txx43
1 files changed, 43 insertions, 0 deletions
diff --git a/odb/mysql/statement-cache.txx b/odb/mysql/statement-cache.txx
new file mode 100644
index 0000000..3acc5fe
--- /dev/null
+++ b/odb/mysql/statement-cache.txx
@@ -0,0 +1,43 @@
+// file : odb/mysql/statement-cache.txx
+// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+namespace odb
+{
+ namespace mysql
+ {
+ template <typename T>
+ typename object_traits<T>::statements_type& statement_cache::
+ find_object ()
+ {
+ typedef typename object_traits<T>::statements_type statements_type;
+
+ map::iterator i (map_.find (&typeid (T)));
+
+ if (i != map_.end ())
+ return static_cast<statements_type&> (*i->second);
+
+ details::shared_ptr<statements_type> p (
+ new (details::shared) statements_type (conn_));
+
+ map_.insert (map::value_type (&typeid (T), p));
+ return *p;
+ }
+
+ template <typename T>
+ view_statements<T>& statement_cache::
+ 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;
+ }
+ }
+}