diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-05-06 12:05:39 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-08-14 15:19:49 +0200 |
commit | 09d7377f81aeb8fde4aa1698e946457f03380d45 (patch) | |
tree | eaedf7045fde8354a3693ce77edc7d5f86824e4e /odb/header.cxx | |
parent | 548f0b10aa3adfc722198bf31f773ba85047f344 (diff) |
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.
Diffstat (limited to 'odb/header.cxx')
-rw-r--r-- | odb/header.cxx | 44 |
1 files changed, 36 insertions, 8 deletions
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> ("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<object_type> (*query) (database&, const query_base_type&);" - << endl; + os << "result<object_type> (*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<prepared_query_impl> " << - "(*prepare_query) (connection&, const char*, const query_base_type&);" - << endl; + "(*prepare_query) (connection&, const char*, const query_base_type&);"; os << "odb::details::shared_ptr<result_impl> (*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 ()) |