From 475a7c89e1c858ae8fec466670af4628129a42d4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 28 Aug 2011 11:39:17 +0200 Subject: Add wrapper support for containers --- odb/relational/source.hxx | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'odb/relational/source.hxx') diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx index 7d0c079..c825159 100644 --- a/odb/relational/source.hxx +++ b/odb/relational/source.hxx @@ -86,7 +86,7 @@ namespace relational { semantics::class_* c (object_pointer (m.type ())); - if (container (im->type ())) + if (container_wrapper (im->type ())) { // This container is a direct member of the class so the table // prefix is just the class table name. @@ -220,7 +220,7 @@ namespace relational if (semantics::data_member* im = inverse (m)) { - if (container (im->type ())) + if (container_wrapper (im->type ())) { // This container is a direct member of the class so the table // prefix is just the class table name. @@ -619,12 +619,12 @@ namespace relational } virtual void - container_extra (semantics::data_member&) + container_extra (semantics::data_member&, semantics::type&) { } virtual void - container (semantics::data_member& m) + container (semantics::data_member& m, semantics::type& t) { using semantics::type; @@ -644,7 +644,6 @@ namespace relational abst = true; // Always abstract. } - type& t (m.type ()); container_kind_type ck (container_kind (t)); type& vt (container_vt (t)); @@ -695,7 +694,7 @@ namespace relational << "//" << endl << endl; - container_extra (m); + container_extra (m, t); // // Statements. @@ -717,7 +716,7 @@ namespace relational string inv_id; // Other id column. string inv_fid; // Other foreign id column (ref to us). - if (context::container (im->type ())) + if (container_wrapper (im->type ())) { // many(i)-to-many // @@ -1637,7 +1636,7 @@ namespace relational } virtual void - container (semantics::data_member& m) + container (semantics::data_member& m, semantics::type&) { string traits (prefix_ + public_name (m) + "_traits"); os << db << "::container_statements_impl< " << traits << " > " << @@ -1655,7 +1654,7 @@ namespace relational } virtual void - container (semantics::data_member& m) + container (semantics::data_member& m, semantics::type&) { if (first_) { @@ -1732,7 +1731,7 @@ namespace relational } virtual void - container (semantics::data_member& m) + container (semantics::data_member& m, semantics::type&) { using semantics::type; @@ -1743,6 +1742,20 @@ namespace relational string sts_name (prefix_ + name); string traits (prefix_ + public_name (m) + "_traits"); + // If this is a wrapped container, then we need to "unwrap" it. + // + { + semantics::type& t (m.type ()); + if (wrapper (t)) + { + string const& type (t.fq_name (m.belongs ().hint ())); + + obj_name = "wrapper_traits< " + type + " >::" + + (call_ == load_call ? "set_ref" : "get_ref") + + " (" + obj_name + ")"; + } + } + switch (call_) { case persist_call: -- cgit v1.1