diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-11-21 13:11:43 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-11-21 13:13:50 +0200 |
commit | 9ad0acf37561de9bf359a561faed53de17c2ca3b (patch) | |
tree | 4b38b866a4917992a6e22cde9f22539e08d4ed9e /odb/source.cxx | |
parent | d01c8e22abea35477f21488613f2474a2e4e8fc7 (diff) |
Add dynamic multi-database query support
Diffstat (limited to 'odb/source.cxx')
-rw-r--r-- | odb/source.cxx | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/odb/source.cxx b/odb/source.cxx index 94560ce..a26adc7 100644 --- a/odb/source.cxx +++ b/odb/source.cxx @@ -13,6 +13,12 @@ namespace source { struct class_: traversal::class_, virtual context { + class_ () + : query_columns_type_ (false, false), + view_query_columns_type_ (false) + { + } + virtual void traverse (type& c) { @@ -30,6 +36,10 @@ namespace source void traverse_view (type&); + + private: + instance<query_columns_type> query_columns_type_; + instance<view_query_columns_type> view_query_columns_type_; }; } @@ -40,19 +50,28 @@ traverse_object (type& c) bool abst (abstract (c)); bool reuse_abst (abst && !poly); - // The rest only applies to dynamic milti-database support and non- - // reuse-abstract objects. + // The rest only applies to dynamic milti-database support. // - if (reuse_abst || options.multi_database () != multi_database::dynamic) + if (!multi_dynamic) return; - string const& type (class_fq_name (c)); - string traits ("access::object_traits_impl< " + type + ", id_default >"); - os << "// " << class_name (c) << endl << "//" << endl << endl; + // query_columns + // + if (options.generate_query ()) + query_columns_type_->traverse (c); + + // The rest does not apply to reuse-abstract objects. + // + if (reuse_abst) + return; + + string const& type (class_fq_name (c)); + string traits ("access::object_traits_impl< " + type + ", id_common >"); + os << "const " << traits << "::" << endl << "function_table_type*" << endl << traits << "::" << endl @@ -61,8 +80,28 @@ traverse_object (type& c) } void source::class_:: -traverse_view (type&) +traverse_view (type& c) { + // The rest only applies to dynamic milti-database support. + // + if (!multi_dynamic) + return; + + os << "// " << class_name (c) << endl + << "//" << endl + << endl; + + if (c.get<size_t> ("object-count") != 0) + view_query_columns_type_->traverse (c); + + string const& type (class_fq_name (c)); + string traits ("access::view_traits_impl< " + type + ", id_common >"); + + os << "const " << traits << "::" << endl + << "function_table_type*" << endl + << traits << "::" << endl + << "function_table[database_count];" + << endl; } namespace source |