From 8a93dcabba6b1e6f5aafb715417e0a08b66d41ba Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 7 Oct 2024 11:09:01 +0300 Subject: Switch to using odb::nested_*() functions directly rather than via adapters for containers of value types with containers --- libbrep/common.hxx | 146 +++-------------------------------------------------- 1 file changed, 7 insertions(+), 139 deletions(-) (limited to 'libbrep/common.hxx') diff --git a/libbrep/common.hxx b/libbrep/common.hxx index 4be9ce9..8312b61 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -421,11 +421,10 @@ namespace brep return i != cs.end () ? &*i : nullptr; } - // Note that ODB doesn't support containers of value types which contain - // containers. Thus, we will persist/load - // build_package_config_template::{builds,constraint,auxiliaries,bot_keys} - // via the separate nested containers using the adapter classes. - // + // Note that build_package_configs_template is a container of the value + // type build_package_config_template, which contains multiple + // containers: builds, constraint, auxiliaries, bot_keys. We will + // persist/load each of them via a separate virtual container. // build_package_config_template::builds // @@ -436,39 +435,6 @@ namespace brep #pragma db member(build_class_expr_key::outer) column("config_index") #pragma db member(build_class_expr_key::inner) column("index") - // Adapter for build_package_config_template::builds. - // - // Note: 1 as for build_package_configs_template. - // - class build_package_config_builds: public small_vector - { - public: - build_package_config_builds () = default; - - template - explicit - build_package_config_builds (const build_package_configs_template& cs) - { - reserve (cs.size ()); - for (const build_package_config_template& c: cs) - push_back (c.builds); - } - - template - void - to_configs (build_package_configs_template& cs) && - { - // Note that the empty trailing entries will be missing (see ODB's - // nested-container.hxx for details). - // - assert (size () <= cs.size ()); - - auto i (cs.begin ()); - for (build_class_exprs& ces: *this) - i++->builds = move (ces); - } - }; - // build_package_config_template::constraints // using build_constraint_key = odb::nested_key; @@ -478,41 +444,6 @@ namespace brep #pragma db member(build_constraint_key::outer) column("config_index") #pragma db member(build_constraint_key::inner) column("index") - // Adapter for build_package_config_template::constraints. - // - // Note: 1 as for build_package_configs_template. - // - class build_package_config_constraints: - public small_vector - { - public: - build_package_config_constraints () = default; - - template - explicit - build_package_config_constraints ( - const build_package_configs_template& cs) - { - reserve (cs.size ()); - for (const build_package_config_template& c: cs) - push_back (c.constraints); - } - - template - void - to_configs (build_package_configs_template& cs) && - { - // Note that the empty trailing entries will be missing (see ODB's - // nested-container.hxx for details). - // - assert (size () <= cs.size ()); - - auto i (cs.begin ()); - for (build_constraints& bcs: *this) - i++->constraints = move (bcs); - } - }; - // build_package_config_template::auxiliaries // using build_auxiliary_key = odb::nested_key; @@ -522,74 +453,11 @@ namespace brep #pragma db member(build_auxiliary_key::outer) column("config_index") #pragma db member(build_auxiliary_key::inner) column("index") - // Adapter for build_package_config_template::auxiliaries. - // - // Note: 1 as for build_package_configs_template. - // - class build_package_config_auxiliaries: - public small_vector - { - public: - build_package_config_auxiliaries () = default; - - template - explicit - build_package_config_auxiliaries ( - const build_package_configs_template& cs) - { - reserve (cs.size ()); - for (const build_package_config_template& c: cs) - push_back (c.auxiliaries); - } - - template - void - to_configs (build_package_configs_template& cs) && - { - // Note that the empty trailing entries will be missing (see ODB's - // nested-container.hxx for details). - // - assert (size () <= cs.size ()); - - auto i (cs.begin ()); - for (build_auxiliaries& bas: *this) - i++->auxiliaries = move (bas); - } - }; - // build_package_config_template::bot_keys // - // Adapter for build_package_config_template::bot_keys. - // - // Note: 1 as for build_package_configs_template. - // - template - class build_package_config_bot_keys: public small_vector, 1> - { - public: - build_package_config_bot_keys () = default; - - explicit - build_package_config_bot_keys (const build_package_configs_template& cs) - { - this->reserve (cs.size ()); - for (const build_package_config_template& c: cs) - this->push_back (c.bot_keys); - } - - void - to_configs (build_package_configs_template& cs) && - { - // Note that the empty trailing entries will be missing (see ODB's - // nested-container.hxx for details). - // - assert (this->size () <= cs.size ()); - - auto i (cs.begin ()); - for (vector& bks: *this) - i++->bot_keys = move (bks); - } - }; + // Note that the nested container support types (*_key, *_map, etc) are + // package object type-specific for this container and are defined in the + // package.hxx and build-package.hxx headers, respectively. // The primary reason why a package is unbuildable by the build bot // controller service. -- cgit v1.1