From 8d82c02a90cd7cc3f161828624db5b973585c34c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 27 Oct 2011 15:16:49 +0200 Subject: Add support for persistent classes without object ids New pragma id (object). New test: common/no-id. --- odb/relational/inline.hxx | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'odb/relational/inline.hxx') 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 -- cgit v1.1