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/database.hxx | 58 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'odb/database.hxx') diff --git a/odb/database.hxx b/odb/database.hxx index 2a904a4..bfd6b0b 100644 --- a/odb/database.hxx +++ b/odb/database.hxx @@ -19,43 +19,59 @@ namespace odb virtual ~database (); - template class P> + // Object persistence API. + // + public: + + // Make the object persistent. + // + template typename object_traits::id_type - persist (P obj); + persist (T& object); + + // Throw object_not_persistent if not found. + // + template + typename object_traits::pointer_type + load (typename object_traits::id_type const& id); + + template + void + load (typename object_traits::id_type const& id, T& object); + // Return NULL/false if not found. + // template - typename object_traits::shared_ptr - load (typename object_traits::id_type const&); + typename object_traits::pointer_type + find (typename object_traits::id_type const& id); template - typename object_traits::shared_ptr - find (typename object_traits::id_type const&); + bool + find (typename object_traits::id_type const& id, T& object); - template class P> + // Save the state of a modified objects. + // + template void - erase (P obj); + store (T& object); - template class P> + // Make the object transient. Throw object_not_persistent if not + // found. + // + template void - modified (P obj); + erase (const T& object); + + template + void + erase (typename object_traits::id_type const& id); // Transaction API. // public: - // Start a transaction. If an existing session can be obtained via - // session::current(), the transaction is run as part of that session. - // Otherwise a new session is created and will be automatically flushed - // and destroyed when transaction ends. - // virtual transaction_impl* begin_transaction () = 0; - // Start a transaction as part of an existing session. The session - // is not automatically flushed or destroyed when transaction ends. - // - virtual transaction_impl* - begin_transaction (session&) = 0; - protected: database (); -- cgit v1.1