diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-05 15:50:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-02-05 15:50:07 +0200 |
commit | 4443c9284e35c070478045b4e5963c64cd108e42 (patch) | |
tree | 57f395b2c18dd1a946046e9c6c2eb155fd941a1c /odb/pgsql/simple-object-statements.hxx | |
parent | 4e33546b4c0a29d879a38029ad103374d4a779ef (diff) |
Add support for change-tracking containers
ODB now supports "smart" ordered containers. Such containers get extra
functions for updating and deleting individual elements. Based on this
functionality implement two change-tracking containers: odb::vector
(equivalent to std::vector) and QOdbList (equivalent to QList). New
tests: common/container/change-tracking and qt/common/container/change-
tracking.
Diffstat (limited to 'odb/pgsql/simple-object-statements.hxx')
-rw-r--r-- | odb/pgsql/simple-object-statements.hxx | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/odb/pgsql/simple-object-statements.hxx b/odb/pgsql/simple-object-statements.hxx index 772ff24..3dbdff3 100644 --- a/odb/pgsql/simple-object-statements.hxx +++ b/odb/pgsql/simple-object-statements.hxx @@ -45,36 +45,43 @@ namespace odb typedef pgsql::connection connection_type; container_statement_cache_ptr (): p_ (0) {} - ~container_statement_cache_ptr () {if (p_ != 0) (this->*deleter_) (0);} + ~container_statement_cache_ptr () + { + if (p_ != 0) + (this->*deleter_) (0, 0, 0, 0); + } T& - get (connection_type& c) + get (connection_type& c, + binding& id, native_binding& idn, const Oid* idt) { if (p_ == 0) - allocate (&c); + allocate (&c, &id, &idn, idt); return *p_; } private: void - allocate (connection_type*); + allocate (connection_type*, binding*, native_binding*, const Oid*); private: T* p_; - void (container_statement_cache_ptr::*deleter_) (connection_type*); + void (container_statement_cache_ptr::*deleter_) ( + connection_type*, binding*, native_binding*, const Oid*); }; template <typename T> void container_statement_cache_ptr<T>:: - allocate (connection_type* c) + allocate (connection_type* c, + binding* id, native_binding* idn, const Oid* idt) { // To reduce object code size, this function acts as both allocator // and deleter. // if (p_ == 0) { - p_ = new T (*c); + p_ = new T (*c, *id, *idn, idt); deleter_ = &container_statement_cache_ptr<T>::allocate; } else @@ -432,7 +439,11 @@ namespace odb container_statement_cache_type& container_statment_cache () { - return container_statement_cache_.get (conn_); + return container_statement_cache_.get ( + conn_, + id_image_binding_, + id_image_native_binding_, + object_traits::find_statement_types); } public: |