| database.ixx | | database.ixx | |
| | | | |
| skipping to change at line 107 | | skipping to change at line 107 | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline void database:: | | inline void database:: | |
| update (const typename object_traits<T>::pointer_type& pobj) | | update (const typename object_traits<T>::pointer_type& pobj) | |
| { | | { | |
| update_<T> (pobj); | | update_<T> (pobj); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline void database:: | | inline void database:: | |
|
| erase (T& obj) | | | |
| { | | | |
| // T can be const T while object_type will always be T. | | | |
| // | | | |
| typedef typename odb::object_traits<T>::object_type object_type; | | | |
| typedef odb::object_traits<object_type> object_traits; | | | |
| | | | |
| erase<T> (object_traits::id (obj)); | | | |
| } | | | |
| | | | |
| template <typename T> | | | |
| inline void database:: | | | |
| erase (T* p) | | erase (T* p) | |
| { | | { | |
| typedef typename object_traits<T>::pointer_type object_pointer; | | typedef typename object_traits<T>::pointer_type object_pointer; | |
| | | | |
| // The passed pointer should be the same or implicit-convertible | | // The passed pointer should be the same or implicit-convertible | |
| // to the object pointer. This way we make sure the object pointer | | // to the object pointer. This way we make sure the object pointer | |
| // does not assume ownership of the passed object. | | // does not assume ownership of the passed object. | |
| // | | // | |
| const object_pointer& pobj (p); | | const object_pointer& pobj (p); | |
| | | | |
| | | | |
| skipping to change at line 166 | | skipping to change at line 154 | |
| inline void database:: | | inline void database:: | |
| erase (const typename object_traits<T>::pointer_type& pobj) | | erase (const typename object_traits<T>::pointer_type& pobj) | |
| { | | { | |
| erase_<T> (pobj); | | erase_<T> (pobj); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline void database:: | | inline void database:: | |
| erase_ (const typename object_traits<T>::pointer_type& pobj) | | erase_ (const typename object_traits<T>::pointer_type& pobj) | |
| { | | { | |
|
| // T can be const T while object_type will always be T. | | typedef typename object_traits<T>::pointer_type pointer_type; | |
| // | | typedef pointer_traits<pointer_type> pointer_traits; | |
| typedef typename odb::object_traits<T>::object_type object_type; | | | |
| typedef odb::object_traits<object_type> object_traits; | | | |
| | | | |
| typedef typename odb::object_traits<T>::pointer_type pointer_type; | | | |
| typedef odb::pointer_traits<pointer_type> pointer_traits; | | | |
| | | | |
|
| erase<T> (object_traits::id (pointer_traits::get_ref (pobj))); | | erase<T> (pointer_traits::get_ref (pobj)); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| inline result<T> database:: | | inline result<T> database:: | |
| query (bool cache) | | query (bool cache) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| // | | // | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 20 lines changed or deleted | | 3 lines changed or added | |
|
| database.txx | | database.txx | |
| // file : odb/database.txx | | // file : odb/database.txx | |
| // author : Boris Kolpackov <boris@codesynthesis.com> | | // author : Boris Kolpackov <boris@codesynthesis.com> | |
| // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC | | // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
| #include <odb/exceptions.hxx> | | #include <odb/exceptions.hxx> | |
| #include <odb/transaction.hxx> | | #include <odb/transaction.hxx> | |
| #include <odb/session.hxx> | | #include <odb/session.hxx> | |
|
| | | #include <odb/callback.hxx> | |
| #include <odb/cache-traits.hxx> | | #include <odb/cache-traits.hxx> | |
| #include <odb/pointer-traits.hxx> | | #include <odb/pointer-traits.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| typename object_traits<T>::id_type database:: | | typename object_traits<T>::id_type database:: | |
| persist (T& obj) | | persist (T& obj) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| // | | // | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| typedef odb::object_traits<object_type> object_traits; | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| if (!transaction::has_current ()) | | if (!transaction::has_current ()) | |
| throw not_in_transaction (); | | throw not_in_transaction (); | |
| | | | |
|
| | | object_traits::callback (*this, obj, callback_event::pre_persist); | |
| object_traits::persist (*this, obj); | | object_traits::persist (*this, obj); | |
|
| | | object_traits::callback (*this, obj, callback_event::post_persist); | |
| | | | |
| const typename object_traits::id_type& id (object_traits::id (obj)); | | const typename object_traits::id_type& id (object_traits::id (obj)); | |
| reference_cache_traits<T>::insert (*this, id, obj); | | reference_cache_traits<T>::insert (*this, id, obj); | |
| return id; | | return id; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| typename object_traits<T>::id_type database:: | | typename object_traits<T>::id_type database:: | |
| persist_ (const typename object_traits<T>::pointer_type& pobj) | | persist_ (const typename object_traits<T>::pointer_type& pobj) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| | | | |
| skipping to change at line 48 | | skipping to change at line 52 | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| typedef odb::object_traits<object_type> object_traits; | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| typedef typename odb::object_traits<T>::pointer_type pointer_type; | | typedef typename odb::object_traits<T>::pointer_type pointer_type; | |
| typedef odb::pointer_traits<pointer_type> pointer_traits; | | typedef odb::pointer_traits<pointer_type> pointer_traits; | |
| | | | |
| if (!transaction::has_current ()) | | if (!transaction::has_current ()) | |
| throw not_in_transaction (); | | throw not_in_transaction (); | |
| | | | |
| T& obj (pointer_traits::get_ref (pobj)); | | T& obj (pointer_traits::get_ref (pobj)); | |
|
| | | | |
| | | object_traits::callback (*this, obj, callback_event::pre_persist); | |
| object_traits::persist (*this, obj); | | object_traits::persist (*this, obj); | |
|
| | | object_traits::callback (*this, obj, callback_event::post_persist); | |
| | | | |
| const typename object_traits::id_type& id (object_traits::id (obj)); | | const typename object_traits::id_type& id (object_traits::id (obj)); | |
| pointer_cache_traits<pointer_type>::insert (*this, id, pobj); | | pointer_cache_traits<pointer_type>::insert (*this, id, pobj); | |
| return id; | | return id; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| typename object_traits<T>::pointer_type database:: | | typename object_traits<T>::pointer_type database:: | |
| load (const typename object_traits<T>::id_type& id) | | load (const typename object_traits<T>::id_type& id) | |
| { | | { | |
| typedef typename object_traits<T>::pointer_type pointer_type; | | typedef typename object_traits<T>::pointer_type pointer_type; | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 143 | |
| update (T& obj) | | update (T& obj) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| // | | // | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| typedef odb::object_traits<object_type> object_traits; | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| if (!transaction::has_current ()) | | if (!transaction::has_current ()) | |
| throw not_in_transaction (); | | throw not_in_transaction (); | |
| | | | |
|
| | | object_traits::callback (*this, obj,callback_event::pre_update); | |
| object_traits::update (*this, obj); | | object_traits::update (*this, obj); | |
|
| | | object_traits::callback (*this, obj, callback_event::post_update); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void database:: | | void database:: | |
| update_ (const typename object_traits<T>::pointer_type& pobj) | | update_ (const typename object_traits<T>::pointer_type& pobj) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| // | | // | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| typedef odb::object_traits<object_type> object_traits; | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| typedef typename odb::object_traits<T>::pointer_type pointer_type; | | typedef typename odb::object_traits<T>::pointer_type pointer_type; | |
| typedef odb::pointer_traits<pointer_type> pointer_traits; | | typedef odb::pointer_traits<pointer_type> pointer_traits; | |
| | | | |
| if (!transaction::has_current ()) | | if (!transaction::has_current ()) | |
| throw not_in_transaction (); | | throw not_in_transaction (); | |
| | | | |
|
| object_traits::update (*this, pointer_traits::get_ref (pobj)); | | T& obj (pointer_traits::get_ref (pobj)); | |
| | | | |
| | | object_traits::callback (*this, obj, callback_event::pre_update); | |
| | | object_traits::update (*this, obj); | |
| | | object_traits::callback (*this, obj, callback_event::post_update); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void database:: | | void database:: | |
| erase (const typename object_traits<T>::id_type& id) | | erase (const typename object_traits<T>::id_type& id) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| // | | // | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| typedef odb::object_traits<object_type> object_traits; | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| skipping to change at line 175 | | skipping to change at line 189 | |
| typedef typename odb::object_traits<T>::pointer_type pointer_type; | | typedef typename odb::object_traits<T>::pointer_type pointer_type; | |
| | | | |
| if (!transaction::has_current ()) | | if (!transaction::has_current ()) | |
| throw not_in_transaction (); | | throw not_in_transaction (); | |
| | | | |
| object_traits::erase (*this, id); | | object_traits::erase (*this, id); | |
| pointer_cache_traits<pointer_type>::erase (*this, id); | | pointer_cache_traits<pointer_type>::erase (*this, id); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
|
| | | void database:: | |
| | | erase (T& obj) | |
| | | { | |
| | | // T can be const T while object_type will always be T. | |
| | | // | |
| | | typedef typename odb::object_traits<T>::object_type object_type; | |
| | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| | | typedef typename odb::object_traits<T>::pointer_type pointer_type; | |
| | | | |
| | | if (!transaction::has_current ()) | |
| | | throw not_in_transaction (); | |
| | | | |
| | | typename object_traits::id_type id (object_traits::id (obj)); | |
| | | | |
| | | object_traits::callback (*this, obj, callback_event::pre_erase); | |
| | | object_traits::erase (*this, id); | |
| | | pointer_cache_traits<pointer_type>::erase (*this, id); | |
| | | object_traits::callback (*this, obj, callback_event::post_erase); | |
| | | } | |
| | | | |
| | | template <typename T> | |
| result<T> database:: | | result<T> database:: | |
| query (const odb::query<typename object_traits<T>::object_type>& q, | | query (const odb::query<typename object_traits<T>::object_type>& q, | |
| bool cache) | | bool cache) | |
| { | | { | |
| // T can be const T while object_type will always be T. | | // T can be const T while object_type will always be T. | |
| // | | // | |
| typedef typename odb::object_traits<T>::object_type object_type; | | typedef typename odb::object_traits<T>::object_type object_type; | |
| typedef odb::object_traits<object_type> object_traits; | | typedef odb::object_traits<object_type> object_traits; | |
| | | | |
| if (!transaction::has_current ()) | | if (!transaction::has_current ()) | |
| | | | |
End of changes. 9 change blocks. |
| 1 lines changed or deleted | | 37 lines changed or added | |
|