aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/inline.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-04-25 15:02:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-04-25 15:02:43 +0200
commit1a6a0652a6ef5b319cfc8ad05a0acee6910f7560 (patch)
tree40605db91ed90c342a9074308bd7406008b4f10b /odb/relational/inline.hxx
parent9c5b2f928699a6752d7c3d1a062bac7efc247c64 (diff)
Add support for abstract object types
Diffstat (limited to 'odb/relational/inline.hxx')
-rw-r--r--odb/relational/inline.hxx122
1 files changed, 66 insertions, 56 deletions
diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx
index 9e76dea..73e0112 100644
--- a/odb/relational/inline.hxx
+++ b/odb/relational/inline.hxx
@@ -32,16 +32,80 @@ namespace relational
virtual void
traverse_object (type& c)
{
+ bool abst (abstract (c));
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.
+ semantics::data_member* id (id_member (c));
+ bool base_id (id ? &id->scope () != &c : false); // Comes from base.
os << "// " << c.name () << endl
<< "//" << endl
<< endl;
+ if (id != 0)
+ {
+ // id (object_type)
+ //
+ os << "inline" << endl
+ << traits << "::id_type" << endl
+ << traits << "::" << endl
+ << "id (const object_type& obj)"
+ << "{";
+
+ 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);"
+ << "}";
+ }
+ }
+
+ //
+ // The rest only applies to concrete objects.
+ //
+ if (abst)
+ return;
+
// query_type
//
if (options.generate_query ())
@@ -67,60 +131,6 @@ namespace relational
<< "}";
}
- // id (object_type)
- //
- os << "inline" << endl
- << traits << "::id_type" << endl
- << traits << "::" << endl
- << "id (const object_type& obj)"
- << "{";
-
- 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_()
//
if (!has_a (c, test_container))