aboutsummaryrefslogtreecommitdiff
path: root/odb/traits.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-07-20 11:02:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-07-20 11:02:07 +0200
commit6400b736456af65176c9c1959022f1eb49fcde32 (patch)
treecdf457de88eda70b89d4cd98e83334e690c96ef1 /odb/traits.hxx
parent8b416ee938662901e1d75cf631c198cde17bb8c8 (diff)
Get rid of the session mechanism for now
Add low-level API instead.
Diffstat (limited to 'odb/traits.hxx')
-rw-r--r--odb/traits.hxx42
1 files changed, 21 insertions, 21 deletions
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 <memory> // std::auto_ptr
-
#include <odb/forward.hxx>
#include <odb/shared-ptr.hxx>
-#include <odb/shared-ptr-traits.hxx>
+#include <odb/pointer-traits.hxx>
namespace odb
{
@@ -19,53 +17,55 @@ namespace odb
ids_assigned /* Assigned by the application. */
};
- // Specializations should defined the following members:
+ // template <typename T>
+ // 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<T>::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 <typename T>
- // class access::object_traits;
template <typename T>
class access::object_memory
{
public:
- typedef odb::shared_ptr<T> shared_ptr;
- typedef std::auto_ptr<T> unique_ptr;
+ typedef T* pointer_type;
};
template <typename T>
class access::object_factory
{
public:
- static typename object_memory<T>::shared_ptr
+ static typename object_memory<T>::pointer_type
create ()
{
- // By default use shared_ptr-specific construction.
+ // By default use pointer-specific construction.
//
- return shared_factory<typename object_memory<T>::shared_ptr>::create ();
+ return
+ pointer_factory<typename object_memory<T>::pointer_type>::create ();
}
};
template <typename P>
- class access::shared_factory
+ class access::pointer_factory
{
public:
- typedef typename shared_ptr_traits<P>::type object_type;
+ typedef typename pointer_traits<P>::type object_type;
static P
create ()
{
- void* v (shared_ptr_traits<P>::allocate (sizeof (object_type)));
+ void* v (pointer_traits<P>::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<P>::free (p_);}
+ ~guard () {if (p_) pointer_traits<P>::free (p_);}
void release () {p_ = 0;}
void* p_;
};
@@ -85,8 +85,8 @@ namespace odb
struct object_traits: access::object_traits<T>
{
typedef
- shared_ptr_traits<typename access::object_traits<T>::shared_ptr>
- shared_ops;
+ pointer_traits<typename access::object_traits<T>::pointer_type>
+ pointer_ops;
};
}