From 3067453a4c623c364286e7d68a446ce15e00b397 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Apr 2012 11:29:05 +0200 Subject: Make session optional --- odb/cache-traits.hxx | 180 +-------------------------------------------------- 1 file changed, 1 insertion(+), 179 deletions(-) (limited to 'odb/cache-traits.hxx') diff --git a/odb/cache-traits.hxx b/odb/cache-traits.hxx index 1e5ccdb..c0c1272 100644 --- a/odb/cache-traits.hxx +++ b/odb/cache-traits.hxx @@ -11,145 +11,15 @@ #include #include #include +#include namespace odb { - // pointer_cache_type - // - // Used to convert an object pointer to the canonical form (non-const), - // suitable for insertion into the cache. - // - template ::element_type, - typename O = typename object_traits::object_type, - pointer_kind pk = pointer_traits

::kind> - struct pointer_cache_type - { - typedef typename object_traits::pointer_type pointer_type; - - static pointer_type - convert (const P& p) - { - return pointer_traits

::const_pointer_cast (p); - } - }; - - template - struct pointer_cache_type - { - // If element_type and object_type are the same, then it is already - // the canonical pointer. - // - static const P& - convert (const P& p) {return p;} - }; - - template - struct pointer_cache_type - { - // If the pointer is unique, then casting it can transfer ownership. - // So return null pointer, which will be ignored down the chain. - // - typedef typename object_traits::pointer_type pointer_type; - - static pointer_type - convert (const P&) {return pointer_type ();} - }; - - template - struct pointer_cache_type - { - typedef typename object_traits::pointer_type pointer_type; - - static pointer_type - convert (const P&) {return pointer_type ();} - }; - - // reference_cache_type - // - // Used to convert an object reference to the canonical form (non-const), - // suitable for insertion into the cache. - // - template ::object_type> - struct reference_cache_type - { - static O& - convert (T& r) - { - return const_cast (r); - } - }; - - template - struct reference_cache_type - { - // If the types are the same, then it is already the canonical form. - // - static T& - convert (T& r) {return r;} - }; - // pointer_cache_traits // // Caching traits for objects passed by pointer. P should be the canonical // pointer (non-const). // - template - struct no_id_pointer_cache_traits - { - typedef P pointer_type; - struct position_type {}; - - static position_type - insert (odb::database&, const pointer_type&) - { - return position_type (); - } - }; - - template - struct no_op_pointer_cache_traits - { - typedef P pointer_type; - typedef typename pointer_traits::element_type object_type; - typedef typename object_traits::id_type id_type; - struct position_type {}; - - struct insert_guard - { - insert_guard () {} - insert_guard (const position_type&) {} - - position_type - position () const {return position_type ();} - - void - release () {} - - void - reset (const position_type&) {} - }; - - static position_type - insert (odb::database&, const id_type&, const pointer_type&) - { - return position_type (); - } - - static position_type - insert (odb::database&, const pointer_type&) {return position_type ();} - - static pointer_type - find (odb::database&, const id_type&) {return pointer_type ();} - - static void - erase (odb::database&, const id_type&) {} - - static void - erase (const position_type&) {} - }; - template struct pointer_cache_traits_impl { @@ -245,54 +115,6 @@ namespace odb // canonical object type (non-const). Only if the object pointer // kind is raw do we add the object to the session. // - template - struct no_id_reference_cache_traits - { - typedef T object_type; - struct position_type {}; - - static position_type - insert (odb::database&, object_type&) - { - return position_type (); - } - }; - - template - struct no_op_reference_cache_traits - { - typedef T object_type; - typedef typename object_traits::id_type id_type; - struct position_type {}; - - struct insert_guard - { - insert_guard () {} - insert_guard (const position_type&) {} - - position_type - position () const {return position_type ();} - - void - release () {} - - void - reset () {} - }; - - static position_type - insert (odb::database&, const id_type&, object_type&) - { - return position_type (); - } - - static position_type - insert (odb::database&, object_type&) - { - return position_type (); - } - }; - template struct reference_cache_traits_impl: no_op_reference_cache_traits {}; -- cgit v1.1