diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-10-27 15:53:35 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-11-01 13:14:54 +0200 |
commit | 02e8f9f8d3276433398bc04bf66ff8e55e8d3d31 (patch) | |
tree | dd57100b709f867a93feb95296db40f4c50466e5 | |
parent | 35dd30f3304027fc4b6167a64bb8d2fe1152d5bf (diff) |
Implement query image change callback machinery
-rw-r--r-- | odb/oracle/binding.hxx | 5 | ||||
-rw-r--r-- | odb/oracle/object-statements.txx | 4 | ||||
-rw-r--r-- | odb/oracle/oracle-types.hxx | 12 | ||||
-rw-r--r-- | odb/oracle/statement.cxx | 5 | ||||
-rw-r--r-- | odb/oracle/view-statements.txx | 2 |
5 files changed, 27 insertions, 1 deletions
diff --git a/odb/oracle/binding.hxx b/odb/oracle/binding.hxx index 778e7fc..64f4782 100644 --- a/odb/oracle/binding.hxx +++ b/odb/oracle/binding.hxx @@ -23,9 +23,10 @@ namespace odb { public: typedef oracle::bind bind_type; + typedef oracle::change_callback change_callback_type; binding (bind_type* b, std::size_t n) - : bind (b), count (n), version (0) + : bind (b), count (n), version (0), change_callback (0) { } @@ -33,6 +34,8 @@ namespace odb std::size_t count; std::size_t version; + change_callback_type* change_callback; + private: binding (const binding&); binding& operator= (const binding&); diff --git a/odb/oracle/object-statements.txx b/odb/oracle/object-statements.txx index 037d82c..948251f 100644 --- a/odb/oracle/object-statements.txx +++ b/odb/oracle/object-statements.txx @@ -45,6 +45,8 @@ namespace odb id_image_.version = 0; id_image_version_ = 0; + select_image_binding_.change_callback = &image_.change_callback; + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); std::memset (update_image_bind_, 0, sizeof (update_image_bind_)); std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); @@ -137,6 +139,8 @@ namespace odb select_image_version_ = 0; insert_image_version_ = 0; + select_image_binding_.change_callback = &image_.change_callback; + std::memset (insert_image_bind_, 0, sizeof (insert_image_bind_)); std::memset (select_image_bind_, 0, sizeof (select_image_bind_)); } diff --git a/odb/oracle/oracle-types.hxx b/odb/oracle/oracle-types.hxx index 1e48129..7f2c46d 100644 --- a/odb/oracle/oracle-types.hxx +++ b/odb/oracle/oracle-types.hxx @@ -114,6 +114,18 @@ namespace odb // lob_context* context; }; + + // An instance of this structure specifies the function to invoke and + // the context to pass just prior to the image associated with a query + // is modified. + // + struct change_callback + { + change_callback (): callback (0), context (0) {}; + + void (*callback) (void*); + void* context; + }; } } diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index cd09e30..ebddf0c 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -521,6 +521,11 @@ namespace odb { if (!done_) { + change_callback* cc (data_.change_callback); + + if (cc != 0 && cc->callback != 0) + (cc->callback) (cc->context); + sword r (OCIStmtFetch2 (stmt_, conn_.error_handle (), 1, diff --git a/odb/oracle/view-statements.txx b/odb/oracle/view-statements.txx index 2bf7e68..eefe503 100644 --- a/odb/oracle/view-statements.txx +++ b/odb/oracle/view-statements.txx @@ -25,6 +25,8 @@ namespace odb image_.version = 0; image_version_ = 0; + image_binding_.change_callback = &image_.change_callback; + std::memset (image_bind_, 0, sizeof (image_bind_)); std::memset (image_indicator_, 0, sizeof (image_indicator_)); |