aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/inline.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-10-27 15:16:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-10-27 15:16:49 +0200
commit8d82c02a90cd7cc3f161828624db5b973585c34c (patch)
tree7b04f0b5e1b9e6eb3a2e76395df6a132be7a78d0 /odb/relational/inline.hxx
parent9d10c570acf1b7e8ed7c0a750ae3edfa70da200b (diff)
Add support for persistent classes without object ids
New pragma id (object). New test: common/no-id.
Diffstat (limited to 'odb/relational/inline.hxx')
-rw-r--r--odb/relational/inline.hxx34
1 files changed, 20 insertions, 14 deletions
diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx
index 78d81bf..3968dce 100644
--- a/odb/relational/inline.hxx
+++ b/odb/relational/inline.hxx
@@ -102,7 +102,7 @@ namespace relational
virtual void
traverse_object (type& c)
{
- bool abst (abstract (c));
+ bool abstract (context::abstract (c));
string const& type (c.fq_name ());
string traits ("access::object_traits< " + type + " >");
@@ -115,28 +115,34 @@ namespace relational
object_extra (c);
- if (id != 0)
+ // id (object_type)
+ //
+ if (id != 0 || !abstract)
{
- // id (object_type)
- //
os << "inline" << endl
<< traits << "::id_type" << endl
<< traits << "::" << endl
- << "id (const object_type& obj)"
+ << "id (const object_type&" << (id != 0 ? " obj" : "") << ")"
<< "{";
- if (base_id)
- os << "return object_traits< " << id->scope ().fq_name () <<
- " >::id (obj);";
- else
- os << "return obj." << id->name () << ";";
+ if (id != 0)
+ {
+ if (base_id)
+ os << "return object_traits< " << id->scope ().fq_name () <<
+ " >::id (obj);";
+ else
+ os << "return obj." << id->name () << ";";
+ }
os << "}";
+ }
- // id (image_type)
- //
+ if (id != 0)
+ {
if (options.generate_query () && base_id)
{
+ // id (image_type)
+ //
os << "inline" << endl
<< traits << "::id_type" << endl
<< traits << "::" << endl
@@ -175,7 +181,7 @@ namespace relational
//
// The rest only applies to concrete objects.
//
- if (abst)
+ if (abstract)
return;
// callback ()
@@ -244,7 +250,7 @@ namespace relational
// load_()
//
- if (!has_a (c, test_container))
+ if (id != 0 && !has_a (c, test_container))
{
os << "inline" << endl
<< "void " << traits << "::" << endl