aboutsummaryrefslogtreecommitdiff
path: root/odb/database.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:33:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:33:08 +0200
commit6f0d40508286afc8cdd72a0b5f807d5c2a589cfc (patch)
treef22a38560560664cae731c37537c2bb04bffdc2a /odb/database.hxx
parente0f3efd9df3e7eefa06777717f23905022d1949e (diff)
Initial implementation
Diffstat (limited to 'odb/database.hxx')
-rw-r--r--odb/database.hxx71
1 files changed, 71 insertions, 0 deletions
diff --git a/odb/database.hxx b/odb/database.hxx
new file mode 100644
index 0000000..2a904a4
--- /dev/null
+++ b/odb/database.hxx
@@ -0,0 +1,71 @@
+// file : odb/database.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_DATABASE_HXX
+#define ODB_DATABASE_HXX
+
+#include <odb/traits.hxx>
+#include <odb/forward.hxx>
+
+namespace odb
+{
+ class transaction_impl;
+
+ class database
+ {
+ public:
+ virtual
+ ~database ();
+
+ template <typename T, template <typename> class P>
+ typename object_traits<T>::id_type
+ persist (P<T> obj);
+
+ template <typename T>
+ typename object_traits<T>::shared_ptr
+ load (typename object_traits<T>::id_type const&);
+
+ template <typename T>
+ typename object_traits<T>::shared_ptr
+ find (typename object_traits<T>::id_type const&);
+
+ template <typename T, template <typename> class P>
+ void
+ erase (P<T> obj);
+
+ template <typename T, template <typename> class P>
+ void
+ modified (P<T> obj);
+
+ // 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 ();
+
+ private:
+ database (const database&);
+ database& operator= (const database&);
+ };
+}
+
+#include <odb/database.ixx>
+#include <odb/database.txx>
+
+#endif // ODB_DATABASE_HXX