summaryrefslogtreecommitdiff
path: root/odb/relational/header.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-07-16 13:45:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-07-16 13:45:31 +0200
commit2a2a9d9efb9209d3b251b62bf347df1dbb8dfae5 (patch)
treed98722760833c7b01bc52242a81dcf62a2560a26 /odb/relational/header.hxx
parent808f6cc2d9c25da6dbacf44cbe045a64a5596673 (diff)
Simplify query inheritance hierarchy
This should also allow Sun CC handle queries for objects with circular dependencies.
Diffstat (limited to 'odb/relational/header.hxx')
-rw-r--r--odb/relational/header.hxx70
1 files changed, 15 insertions, 55 deletions
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<size_t> ("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<size_t> ("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<size_t> ("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.