From 587db8c7ca28d5cd1722307073aa31aed5b89d0a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Apr 2011 14:07:32 +0200 Subject: Initial support for non-polymorphic inheritance Every class gets a separate table. New test: common/inheritance. --- odb/relational/inline.hxx | 54 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'odb/relational/inline.hxx') diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx index 1b3c492..9e76dea 100644 --- a/odb/relational/inline.hxx +++ b/odb/relational/inline.hxx @@ -34,7 +34,9 @@ namespace relational { string const& type (c.fq_name ()); string traits ("access::object_traits< " + type + " >"); + semantics::data_member& id (id_member (c)); + bool base_id (&id.scope () != &c); // Id comes from a base class. os << "// " << c.name () << endl << "//" << endl @@ -65,15 +67,59 @@ namespace relational << "}"; } - // id () + // id (object_type) // os << "inline" << endl << traits << "::id_type" << endl << traits << "::" << endl << "id (const object_type& obj)" - << "{" - << "return obj." << id.name () << ";" << endl - << "}"; + << "{"; + + if (base_id) + os << "return object_traits< " << id.scope ().fq_name () << + " >::id (obj);"; + else + os << "return obj." << id.name () << ";"; + + os << "}"; + + // id (image_type) + // + if (options.generate_query () && base_id) + { + os << "inline" << endl + << traits << "::id_type" << endl + << traits << "::" << endl + << "id (const image_type& i)" + << "{" + << "return object_traits< " << id.scope ().fq_name () << + " >::id (i);" + << "}"; + } + + // bind (id_image_type) + // + if (base_id) + { + os << "inline" << endl + << "void " << traits << "::" << endl + << "bind (" << bind_vector << " b, id_image_type& i)" + << "{" + << "object_traits< " << id.scope ().fq_name () << + " >::bind (b, i);" + << "}"; + } + + if (base_id) + { + os << "inline" << endl + << "void " << traits << "::" << endl + << "init (id_image_type& i, const id_type& id)" + << "{" + << "object_traits< " << id.scope ().fq_name () << + " >::init (i, id);" + << "}"; + } // load_() // -- cgit v1.1