From 2a2a9d9efb9209d3b251b62bf347df1dbb8dfae5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Jul 2012 13:45:31 +0200 Subject: Simplify query inheritance hierarchy This should also allow Sun CC handle queries for objects with circular dependencies. --- odb/relational/header.cxx | 4 --- odb/relational/header.hxx | 70 +++++++++-------------------------------- odb/relational/inline.hxx | 80 ----------------------------------------------- odb/relational/source.cxx | 2 +- 4 files changed, 16 insertions(+), 140 deletions(-) diff --git a/odb/relational/header.cxx b/odb/relational/header.cxx index 987da38..538962b 100644 --- a/odb/relational/header.cxx +++ b/odb/relational/header.cxx @@ -453,10 +453,6 @@ traverse_object (type& c) // os << "typedef " << db << "::query query_base_type;" << endl; - - // query_type - // - os << "struct query_type;"; } // diff --git a/odb/relational/header.hxx b/odb/relational/header.hxx index a1af1f6..c7a7445 100644 --- a/odb/relational/header.hxx +++ b/odb/relational/header.hxx @@ -1039,25 +1039,16 @@ namespace relational // Query. // - // query_base_type + // query_base_type and query_columns (definition generated by class2). // os << "typedef " << db << "::query query_base_type;" - << endl; - - // query_type (definition generated by class2). - // - size_t obj_count (c.get ("object-count")); - - if (obj_count != 0) - { - if (obj_count > 1) - os << "struct query_columns;"; + << "struct query_columns"; - os << "struct query_type;" - << endl; - } + if (c.get ("object-count") == 0) + os << "{" + << "};"; else - os << "typedef query_base_type query_type;" + os << ";" << endl; // @@ -1247,15 +1238,11 @@ namespace relational virtual void traverse_object (type& c) { - bool reuse_abst (abstract (c) && !polymorphic (c)); - - string const& type (class_fq_name (c)); - if (options.generate_query ()) { bool has_ptr (has_a (c, test_pointer | include_base)); - if (has_ptr || !reuse_abst) + if (has_ptr) os << "// " << class_name (c) << endl << "//" << endl; @@ -1271,23 +1258,6 @@ namespace relational query_columns_type_->traverse (c); } - - // query_type - // - if (!reuse_abst) - os << "struct access::object_traits< " << type << " >::" << - "query_type:" << endl - << " query_base_type," << endl - << " query_columns<" << endl - << " " << type << "," << endl - << " access::object_traits< " << type << " > >" - << "{" - << "query_type ();" - << "query_type (bool);" - << "query_type (const char*);" - << "query_type (const std::string&);" - << "query_type (const query_base_type&);" - << "};"; } // Move header comment out of if-block if adding any code here. @@ -1298,7 +1268,7 @@ namespace relational { string const& type (class_fq_name (c)); - // query_type + // query_columns // size_t obj_count (c.get ("object-count")); @@ -1336,10 +1306,11 @@ namespace relational } } + os << "struct access::view_traits< " << type << " >::query_columns"; + if (obj_count > 1) { - os << "struct access::view_traits< " << type << " >::query_columns" - << "{"; + os << "{"; for (view_objects::const_iterator i (objs.begin ()); i < objs.end (); @@ -1377,10 +1348,6 @@ namespace relational } os << "};"; - - os << "struct access::view_traits< " << type << " >::" << - "query_type:" << endl - << " query_base_type, query_columns"; } else { @@ -1401,9 +1368,7 @@ namespace relational string const& otype (class_fq_name (o)); qname const& table (table_name (o)); - os << "struct access::view_traits< " << type << " >::" << - "query_type:" << endl - << " query_base_type," << endl + os << ":" << endl << " odb::pointer_query_columns<" << endl << " " << otype << "," << endl; @@ -1417,15 +1382,10 @@ namespace relational } else os << " odb::access::object_traits< " << otype << " > >"; - } - os << "{" - << "query_type ();" - << "query_type (bool);" - << "query_type (const char*);" - << "query_type (const std::string&);" - << "query_type (const query_base_type&);" - << "};"; + os << "{" + << "};"; + } } // Move header comment out of if-block if adding any code here. diff --git a/odb/relational/inline.hxx b/odb/relational/inline.hxx index add4741..39801cb 100644 --- a/odb/relational/inline.hxx +++ b/odb/relational/inline.hxx @@ -423,45 +423,6 @@ namespace relational callback_calls_->traverse (c, true); os << "}"; - // query_type - // - if (options.generate_query ()) - { - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type ()" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (bool v)" << endl - << " : query_base_type (v)" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (const char* q)" << endl - << " : query_base_type (q)" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (const std::string& q)" << endl - << " : query_base_type (q)" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (const query_base_type& q)" << endl - << " : query_base_type (q)" - << "{" - << "}"; - } - // load_() // if (id != 0 && !(poly_derived || has_a (c, test_container))) @@ -569,47 +530,6 @@ namespace relational view_extra (c); - // query_type - // - size_t obj_count (c.get ("object-count")); - - if (obj_count != 0) - { - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type ()" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (bool v)" << endl - << " : query_base_type (v)" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (const char* q)" << endl - << " : query_base_type (q)" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (const std::string& q)" << endl - << " : query_base_type (q)" - << "{" - << "}"; - - os << "inline" << endl - << traits << "::query_type::" << endl - << "query_type (const query_base_type& q)" << endl - << " : query_base_type (q)" - << "{" - << "}"; - } - // callback () // os << "inline" << endl diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx index adc7a0e..5338730 100644 --- a/odb/relational/source.cxx +++ b/odb/relational/source.cxx @@ -3371,7 +3371,7 @@ namespace relational bool multi_obj ((amap.size () + omap.size ()) > 1); - string r ("query_type"); + string r ("query_columns"); string name; bool fail (false); -- cgit v1.1