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/relational/mysql | |
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/relational/mysql')
-rw-r--r-- | odb/relational/mysql/context.cxx | 32 | ||||
-rw-r--r-- | odb/relational/mysql/context.hxx | 2 |
2 files changed, 23 insertions, 11 deletions
diff --git a/odb/relational/mysql/context.cxx b/odb/relational/mysql/context.cxx index 52c1dcc..75b71e9 100644 --- a/odb/relational/mysql/context.cxx +++ b/odb/relational/mysql/context.cxx @@ -145,8 +145,8 @@ namespace relational { struct has_grow: traversal::class_ { - has_grow (bool& r) - : r_ (r) + has_grow (bool& r, user_section* s) + : r_ (r), section_ (s) { *this >> inherits_ >> *this; } @@ -161,7 +161,7 @@ namespace relational if (!(context::object (c) || view || context::composite (c))) return; - if (c.count ("mysql-grow")) + if (section_ == 0 && c.count ("mysql-grow")) r_ = c.get<bool> ("mysql-grow"); else { @@ -173,29 +173,41 @@ namespace relational if (!r_) names (c); - c.set ("mysql-grow", r_); + if (section_ == 0) + c.set ("mysql-grow", r_); } } private: bool& r_; + user_section* section_; traversal::inherits inherits_; }; struct has_grow_member: member_base { has_grow_member (bool& r, + user_section* section = 0, semantics::type* type = 0, string const& key_prefix = string ()) - : relational::member_base (type, string (), key_prefix), + : relational::member_base (type, string (), key_prefix, section), r_ (r) { } + virtual bool + pre (member_info& mi) + { + return (section_ == 0 && !separate_load (mi.m)) || + (section_ != 0 && *section_ == section (mi.m)); + } + virtual void traverse_composite (member_info& mi) { // By calling grow() instead of recursing, we reset any overrides. + // We also don't pass section since they don't apply inside + // composites. // r_ = r_ || context::grow (dynamic_cast<semantics::class_&> (mi.t)); } @@ -236,14 +248,14 @@ namespace relational } bool context:: - grow_impl (semantics::class_& c) + grow_impl (semantics::class_& c, user_section* section) { - if (c.count ("mysql-grow")) + if (section == 0 && c.count ("mysql-grow")) return c.get<bool> ("mysql-grow"); bool r (false); - has_grow ct (r); - has_grow_member mt (r); + has_grow ct (r, section); + has_grow_member mt (r, section); traversal::names names; ct >> names >> mt; ct.traverse (c); @@ -263,7 +275,7 @@ namespace relational grow_impl (semantics::data_member& m, semantics::type& t, string const& kp) { bool r (false); - has_grow_member mt (r, &t, kp); + has_grow_member mt (r, 0, &t, kp); mt.traverse (m); return r; } diff --git a/odb/relational/mysql/context.hxx b/odb/relational/mysql/context.hxx index 5d5571e..681a56e 100644 --- a/odb/relational/mysql/context.hxx +++ b/odb/relational/mysql/context.hxx @@ -113,7 +113,7 @@ namespace relational convert_expr (string const&, semantics::data_member&, bool); virtual bool - grow_impl (semantics::class_&); + grow_impl (semantics::class_&, user_section*); virtual bool grow_impl (semantics::data_member&); |