aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/inline.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-04-22 14:07:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-04-22 14:07:32 +0200
commit587db8c7ca28d5cd1722307073aa31aed5b89d0a (patch)
treeb5295accedf2cd946d5df22ed5fbfa78290e89dc /odb/relational/inline.hxx
parent584f3602038919957f62848a03deb5b5bd9cc9ba (diff)
Initial support for non-polymorphic inheritance
Every class gets a separate table. New test: common/inheritance.
Diffstat (limited to 'odb/relational/inline.hxx')
-rw-r--r--odb/relational/inline.hxx54
1 files changed, 50 insertions, 4 deletions
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_()
//