From b2f0cd834b8f5651985357f8acbe82edd7d11c63 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Oct 2011 16:52:45 +0200 Subject: Split 'in' binding into insert/update pair; rename 'out' to select Also add the initial infrastructure for the readonly members support. Right now the split insert/update bindings allows us to avoid sending object id in UPDATE statements. It will also allows us to support readonly members. --- odb/context.cxx | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'odb/context.cxx') diff --git a/odb/context.cxx b/odb/context.cxx index fec6457..45dd55b 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -968,61 +968,61 @@ namespace { struct column_count_impl: object_members_base { - column_count_impl (bool out) - : out_ (out), count_ (0) - { - } + typedef context::column_count_type count_type; virtual void traverse (semantics::class_& c) { - char const* key (out_ ? "out-column-count" : "in-column-count"); + if (c.count ("column-count")) + { + count_type const& bc (c.get ("column-count")); - if (c.count (key)) - count_ += c.get (key); + c_.total += bc.total; + c_.id += bc.id; + c_.inverse += bc.inverse; + c_.readonly += bc.readonly; + } else { - size_t n (count_); + count_type t (c_); object_members_base::traverse (c); - c.set (key, count_ - n); + + t.total = c_.total - t.total; + t.id = c_.id - t.id; + t.inverse = c_.inverse - t.inverse; + t.readonly = c_.readonly - t.readonly; + + c.set ("column-count", t); } } virtual void traverse_simple (semantics::data_member& m) { - if (out_ || !context::inverse (m)) - count_++; + c_.total++; + + if (m.count ("id")) + c_.id++; + + if (context::inverse (m)) + c_.inverse++; } private: - bool out_; - size_t count_; + count_type c_; }; } -size_t context:: -in_column_count (semantics::class_& c) -{ - if (!c.count ("in-column-count")) - { - column_count_impl t (false); - t.traverse (c); - } - - return c.get ("in-column-count"); -} - -size_t context:: -out_column_count (semantics::class_& c) +context::column_count_type context:: +column_count (semantics::class_& c) { - if (!c.count ("out-column-count")) + if (!c.count ("column-count")) { - column_count_impl t (true); + column_count_impl t; t.traverse (c); } - return c.get ("out-column-count"); + return c.get ("column-count"); } namespace -- cgit v1.1