From 6400b736456af65176c9c1959022f1eb49fcde32 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Jul 2010 11:02:07 +0200 Subject: Get rid of the session mechanism for now Add low-level API instead. --- odb/traits.hxx | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'odb/traits.hxx') diff --git a/odb/traits.hxx b/odb/traits.hxx index e8e109c..50d87eb 100644 --- a/odb/traits.hxx +++ b/odb/traits.hxx @@ -6,11 +6,9 @@ #ifndef ODB_TRAITS_HXX #define ODB_TRAITS_HXX -#include // std::auto_ptr - #include #include -#include +#include namespace odb { @@ -19,53 +17,55 @@ namespace odb ids_assigned /* Assigned by the application. */ }; - // Specializations should defined the following members: + // template + // class access::object_traits; + // + // Specializations should inherit from object_memory, object_factory + // and define the following members: // // id_type - object id (primary key) type // id_source - object id (primary key) source // id_type id (const T&) - get object id // - // void insert (database&, const T&) - // void update (database&, const T&) + // void insert (database&, T&) + // void update (database&, T&) // void erase (database&, const id_type&) - // memory_traits::shared_ptr find (database&, const id_type&) + // pointer_type find (database&, const id_type&) + // bool find (database&, const id_type&, T&) // - // And inherit from object_memory and object_factory. // - // template - // class access::object_traits; template class access::object_memory { public: - typedef odb::shared_ptr shared_ptr; - typedef std::auto_ptr unique_ptr; + typedef T* pointer_type; }; template class access::object_factory { public: - static typename object_memory::shared_ptr + static typename object_memory::pointer_type create () { - // By default use shared_ptr-specific construction. + // By default use pointer-specific construction. // - return shared_factory::shared_ptr>::create (); + return + pointer_factory::pointer_type>::create (); } }; template - class access::shared_factory + class access::pointer_factory { public: - typedef typename shared_ptr_traits

::type object_type; + typedef typename pointer_traits

::type object_type; static P create () { - void* v (shared_ptr_traits

::allocate (sizeof (object_type))); + void* v (pointer_traits

::allocate (sizeof (object_type))); guard g (v); P p (new (v) object_type); g.release (); @@ -75,7 +75,7 @@ namespace odb struct guard { guard (void* p): p_ (p) {} - ~guard () {if (p_) shared_ptr_traits

::free (p_);} + ~guard () {if (p_) pointer_traits

::free (p_);} void release () {p_ = 0;} void* p_; }; @@ -85,8 +85,8 @@ namespace odb struct object_traits: access::object_traits { typedef - shared_ptr_traits::shared_ptr> - shared_ops; + pointer_traits::pointer_type> + pointer_ops; }; } -- cgit v1.1