aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/statement-cache.hxx
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.hxx
parent4d0711124bb6cdca491e33a51911d20090a1879a (diff)
Polymorphic inheritance support
Diffstat (limited to 'odb/mysql/statement-cache.hxx')
-rw-r--r--odb/mysql/statement-cache.hxx44
1 files changed, 8 insertions, 36 deletions
diff --git a/odb/mysql/statement-cache.hxx b/odb/mysql/statement-cache.hxx
index e62c76c..f801972 100644
--- a/odb/mysql/statement-cache.hxx
+++ b/odb/mysql/statement-cache.hxx
@@ -11,11 +11,11 @@
#include <typeinfo>
#include <odb/forward.hxx>
+#include <odb/traits.hxx>
#include <odb/mysql/version.hxx>
+#include <odb/mysql/forward.hxx>
#include <odb/mysql/statements-base.hxx>
-#include <odb/mysql/object-statements.hxx>
-#include <odb/mysql/view-statements.hxx>
#include <odb/details/shared-ptr.hxx>
#include <odb/details/type-info.hxx>
@@ -26,49 +26,19 @@ namespace odb
{
namespace mysql
{
- class connection;
-
class LIBODB_MYSQL_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_));
+ typename object_traits<T>::statements_type&
+ find_object ();
- map_.insert (map::value_type (&typeid (T), p));
- return *p;
- }
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 +51,8 @@ namespace odb
}
}
+#include <odb/mysql/statement-cache.txx>
+
#include <odb/post.hxx>
#endif // ODB_MYSQL_STATEMENT_CACHE_HXX