aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/simple-object-statements.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-02-05 15:50:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-02-05 15:50:07 +0200
commit32613d718b36a6c400d6f05da50d30b3fd25c3b8 (patch)
tree5e6816a5133fc4de18dc6442c727528bbaa6875c /odb/sqlite/simple-object-statements.hxx
parent3a9feb01e8cda69c41af126a7266ae7a6e545499 (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/sqlite/simple-object-statements.hxx')
-rw-r--r--odb/sqlite/simple-object-statements.hxx21
1 files changed, 13 insertions, 8 deletions
diff --git a/odb/sqlite/simple-object-statements.hxx b/odb/sqlite/simple-object-statements.hxx
index 9ff3faf..9fe3675 100644
--- a/odb/sqlite/simple-object-statements.hxx
+++ b/odb/sqlite/simple-object-statements.hxx
@@ -45,36 +45,41 @@ namespace odb
typedef sqlite::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);
+ }
T&
- get (connection_type& c)
+ get (connection_type& c, binding& id)
{
if (p_ == 0)
- allocate (&c);
+ allocate (&c, &id);
return *p_;
}
private:
void
- allocate (connection_type*);
+ allocate (connection_type*, binding*);
private:
T* p_;
- void (container_statement_cache_ptr::*deleter_) (connection_type*);
+ void (container_statement_cache_ptr::*deleter_) (
+ connection_type*, binding*);
};
template <typename T>
void container_statement_cache_ptr<T>::
- allocate (connection_type* c)
+ allocate (connection_type* c, binding* id)
{
// 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);
deleter_ = &container_statement_cache_ptr<T>::allocate;
}
else
@@ -416,7 +421,7 @@ namespace odb
container_statement_cache_type&
container_statment_cache ()
{
- return container_statement_cache_.get (conn_);
+ return container_statement_cache_.get (conn_, id_image_binding_);
}
public: