From 6f0d40508286afc8cdd72a0b5f807d5c2a589cfc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Jun 2010 16:33:08 +0200 Subject: Initial implementation --- odb/database.hxx | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 odb/database.hxx (limited to 'odb/database.hxx') 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 +// 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 +#include + +namespace odb +{ + class transaction_impl; + + class database + { + public: + virtual + ~database (); + + template class P> + typename object_traits::id_type + persist (P obj); + + template + typename object_traits::shared_ptr + load (typename object_traits::id_type const&); + + template + typename object_traits::shared_ptr + find (typename object_traits::id_type const&); + + template class P> + void + erase (P obj); + + template class P> + void + modified (P 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 +#include + +#endif // ODB_DATABASE_HXX -- cgit v1.1