| object-statements.txx | | object-statements.txx | |
| // file : odb/sqlite/object-statements.txx | | // file : odb/sqlite/object-statements.txx | |
| // author : Boris Kolpackov <boris@codesynthesis.com> | | // author : Boris Kolpackov <boris@codesynthesis.com> | |
| // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC | | // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC | |
| // license : GNU GPL v2; see accompanying LICENSE file | | // license : GNU GPL v2; see accompanying LICENSE file | |
| | | | |
| #include <cstddef> // std::size_t | | #include <cstddef> // std::size_t | |
| #include <cstring> // std::memset | | #include <cstring> // std::memset | |
| | | | |
| #include <odb/session.hxx> | | #include <odb/session.hxx> | |
|
| | | #include <odb/callback.hxx> | |
| #include <odb/exceptions.hxx> | | #include <odb/exceptions.hxx> | |
| | | | |
| #include <odb/sqlite/connection.hxx> | | #include <odb/sqlite/connection.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace sqlite | | namespace sqlite | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| object_statements<T>:: | | object_statements<T>:: | |
| | | | |
| skipping to change at line 46 | | skipping to change at line 47 | |
| std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); | | std::memset (out_image_truncated_, 0, sizeof (out_image_truncated_)); | |
| | | | |
| for (std::size_t i (0); i < object_traits::out_column_count; ++i) | | for (std::size_t i (0); i < object_traits::out_column_count; ++i) | |
| out_image_bind_[i].truncated = out_image_truncated_ + i; | | out_image_bind_[i].truncated = out_image_truncated_ + i; | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void object_statements<T>:: | | void object_statements<T>:: | |
| load_delayed_ () | | load_delayed_ () | |
| { | | { | |
|
| // We should be careful here: the delayed vector can change | | | |
| // from under us as a result of a recursive load. | | | |
| // | | | |
| database& db (connection ().database ()); | | database& db (connection ().database ()); | |
| | | | |
|
| while (!delayed_.empty ()) | | delayed_loads dls; | |
| | | swap_guard sg (*this, dls); | |
| | | | |
| | | while (!dls.empty ()) | |
| { | | { | |
|
| delayed_load l (delayed_.back ()); | | delayed_load l (dls.back ()); | |
| typename object_cache_traits::insert_guard g (l.pos); | | typename object_cache_traits::insert_guard g (l.pos); | |
|
| delayed_.pop_back (); | | dls.pop_back (); | |
| | | | |
| if (!object_traits::find_ (*this, l.id)) | | if (!object_traits::find_ (*this, l.id)) | |
| throw object_not_persistent (); | | throw object_not_persistent (); | |
| | | | |
|
| | | object_traits::callback (db, *l.obj, callback_event::pre_load); | |
| | | | |
| | | // Our calls to init/load below can result in additional delayed | |
| | | // loads being added to the delayed_ vector. We need to process | |
| | | // those before we call the post callback. | |
| | | // | |
| object_traits::init (*l.obj, image (), db); | | object_traits::init (*l.obj, image (), db); | |
| object_traits::load_ (*this, *l.obj); // Load containers, etc. | | object_traits::load_ (*this, *l.obj); // Load containers, etc. | |
|
| | | | |
| | | if (!delayed_.empty ()) | |
| | | load_delayed_ (); | |
| | | | |
| | | object_traits::callback (db, *l.obj, callback_event::post_load); | |
| | | | |
| g.release (); | | g.release (); | |
| } | | } | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| void object_statements<T>:: | | void object_statements<T>:: | |
| clear_delayed_ () | | clear_delayed_ () | |
| { | | { | |
| // Remove the objects from the session cache. | | // Remove the objects from the session cache. | |
| // | | // | |
| | | | |
End of changes. 7 change blocks. |
| 6 lines changed or deleted | | 19 lines changed or added | |
|
| result.txx | | result.txx | |
| // file : odb/sqlite/result.txx | | // file : odb/sqlite/result.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/callback.hxx> | |
| #include <odb/exceptions.hxx> | | #include <odb/exceptions.hxx> | |
| | | | |
| namespace odb | | namespace odb | |
| { | | { | |
| namespace sqlite | | namespace sqlite | |
| { | | { | |
| template <typename T> | | template <typename T> | |
| result_impl<T>:: | | result_impl<T>:: | |
| ~result_impl () | | ~result_impl () | |
| { | | { | |
| | | | |
| skipping to change at line 40 | | skipping to change at line 41 | |
| void result_impl<T>:: | | void result_impl<T>:: | |
| load (object_type& obj) | | load (object_type& obj) | |
| { | | { | |
| load_image (); | | load_image (); | |
| | | | |
| // This is a top-level call so the statements cannot be locked. | | // This is a top-level call so the statements cannot be locked. | |
| // | | // | |
| assert (!statements_.locked ()); | | assert (!statements_.locked ()); | |
| typename object_statements<object_type>::auto_lock l (statements_); | | typename object_statements<object_type>::auto_lock l (statements_); | |
| | | | |
|
| | | odb::database& db (this->database ()); | |
| | | object_traits::callback (db, obj, callback_event::pre_load); | |
| | | | |
| typename object_traits::image_type& i (statements_.image ()); | | typename object_traits::image_type& i (statements_.image ()); | |
|
| object_traits::init (obj, i, this->database ()); | | object_traits::init (obj, i, db); | |
| | | | |
| // Initialize the id image and binding and load the rest of the objec
t | | // Initialize the id image and binding and load the rest of the objec
t | |
| // (containers, etc). | | // (containers, etc). | |
| // | | // | |
| typename object_traits::id_image_type& idi (statements_.id_image ()); | | typename object_traits::id_image_type& idi (statements_.id_image ()); | |
| object_traits::init (idi, object_traits::id (i)); | | object_traits::init (idi, object_traits::id (i)); | |
| | | | |
| binding& idb (statements_.id_image_binding ()); | | binding& idb (statements_.id_image_binding ()); | |
| if (idi.version != statements_.id_image_version () || idb.version ==
0) | | if (idi.version != statements_.id_image_version () || idb.version ==
0) | |
| { | | { | |
| object_traits::bind (idb.bind, idi); | | object_traits::bind (idb.bind, idi); | |
| statements_.id_image_version (idi.version); | | statements_.id_image_version (idi.version); | |
| idb.version++; | | idb.version++; | |
| } | | } | |
| | | | |
| object_traits::load_ (statements_, obj); | | object_traits::load_ (statements_, obj); | |
|
| | | | |
| statements_.load_delayed (); | | statements_.load_delayed (); | |
|
| | | object_traits::callback (db, obj, callback_event::post_load); | |
| | | | |
| l.unlock (); | | l.unlock (); | |
| } | | } | |
| | | | |
| template <typename T> | | template <typename T> | |
| typename result_impl<T>::id_type result_impl<T>:: | | typename result_impl<T>::id_type result_impl<T>:: | |
| load_id () | | load_id () | |
| { | | { | |
| load_image (); | | load_image (); | |
| return object_traits::id (statements_.image ()); | | return object_traits::id (statements_.image ()); | |
| } | | } | |
| | | | |
End of changes. 5 change blocks. |
| 2 lines changed or deleted | | 7 lines changed or added | |
|