diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-10-11 16:52:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-10-21 19:25:06 +0200 |
commit | b2f0cd834b8f5651985357f8acbe82edd7d11c63 (patch) | |
tree | 591f652e2f49631a0920828598eba4fff28fcfc8 /odb/context.cxx | |
parent | 5ff1382aeae38946889b1e09a21bde1c48475dfd (diff) |
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.
Diffstat (limited to 'odb/context.cxx')
-rw-r--r-- | odb/context.cxx | 60 |
1 files changed, 30 insertions, 30 deletions
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<count_type> ("column-count")); - if (c.count (key)) - count_ += c.get<size_t> (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<size_t> ("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<size_t> ("out-column-count"); + return c.get<column_count_type> ("column-count"); } namespace |