From 09d7377f81aeb8fde4aa1698e946457f03380d45 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 6 May 2013 12:05:39 +0200 Subject: Add support for object sections Sections are an optimization mechanism that allows the partitioning of data members of a persistent class into groups that can be separately loaded and/or updated. --- odb/header.cxx | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) (limited to 'odb/header.cxx') diff --git a/odb/header.cxx b/odb/header.cxx index 9af82c8..f09c1e8 100644 --- a/odb/header.cxx +++ b/odb/header.cxx @@ -60,6 +60,8 @@ traverse_object (type& c) bool abst (abstract (c)); bool reuse_abst (abst && !poly); + user_sections& uss (c.get ("user-sections")); + string const& type (class_fq_name (c)); os << "// " << class_name (c) << endl @@ -384,27 +386,37 @@ traverse_object (type& c) os << "void (*erase2) (database&, const object_type&" << (poly ? ", bool, bool" : "") << ");"; + + // Sections. + // + if (uss.count (user_sections::count_total | + user_sections::count_load | + (poly ? user_sections::count_load_empty : 0)) != 0) + os << "bool (*load_section) (connection&, object_type&, section&" << + (poly ? ", const info_type*" : "") << ");"; + + if (uss.count (user_sections::count_total | + user_sections::count_update | + (poly ? user_sections::count_update_empty : 0)) != 0) + os << "bool (*update_section) (connection&, const object_type&, " << + "const section&" << (poly ? ", const info_type*" : "") << ");"; } if (options.generate_query ()) { if (!options.omit_unprepared ()) - os << "result (*query) (database&, const query_base_type&);" - << endl; + os << "result (*query) (database&, const query_base_type&);"; os << "unsigned long long (*erase_query) (database&, " << - "const query_base_type&);" - << endl; + "const query_base_type&);"; if (options.generate_prepared ()) { os << "odb::details::shared_ptr " << - "(*prepare_query) (connection&, const char*, const query_base_type&);" - << endl; + "(*prepare_query) (connection&, const char*, const query_base_type&);"; os << "odb::details::shared_ptr (*execute_query) (" - "prepared_query_impl&);" - << endl; + "prepared_query_impl&);"; } } @@ -461,6 +473,22 @@ traverse_object (type& c) os << "static void" << endl << "erase (database&, const object_type&);" << endl; + + // Sections. + // + if (uss.count (user_sections::count_total | + user_sections::count_load | + (poly ? user_sections::count_load_empty : 0)) != 0) + os << "static bool" << endl + << "load (connection&, object_type&, section&);" + << endl; + + if (uss.count (user_sections::count_total | + user_sections::count_update | + (poly ? user_sections::count_update_empty : 0)) != 0) + os << "static bool" << endl + << "update (connection&, const object_type&, const section&);" + << endl; } if (options.generate_query ()) -- cgit v1.1