diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-10-07 11:09:01 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-10-07 11:09:01 +0300 |
commit | 8a93dcabba6b1e6f5aafb715417e0a08b66d41ba (patch) | |
tree | 8bd1c02f8d582eeb853c32bccf9564b853851370 | |
parent | fb3be3dcb4b03d78ee35ebfa18d9c46d0664a055 (diff) |
Switch to using odb::nested_*() functions directly rather than via adapters for containers of value types with containers
-rw-r--r-- | libbrep/build-package.hxx | 74 | ||||
-rw-r--r-- | libbrep/common.hxx | 146 | ||||
-rw-r--r-- | libbrep/package.hxx | 74 |
3 files changed, 79 insertions, 215 deletions
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx index 13645eb..14217b2 100644 --- a/libbrep/build-package.hxx +++ b/libbrep/build-package.hxx @@ -288,50 +288,48 @@ namespace brep // #pragma db member(configs) id_column("") value_column("config_") - #pragma db member(config_builds) \ - virtual(build_class_exprs_map) \ - after(configs) \ - get(odb::nested_get ( \ - brep::build_package_config_builds (this.configs))) \ - set(brep::build_package_config_builds bs; \ - odb::nested_set (bs, std::move (?)); \ - move (bs).to_configs (this.configs)) \ - id_column("") key_column("") value_column("") \ + #pragma db member(config_builds) \ + virtual(build_class_exprs_map) \ + after(configs) \ + get(odb::nested_get (this.configs, \ + &brep::build_package_config::builds)) \ + set(odb::nested_set (this.configs, \ + &brep::build_package_config::builds, \ + std::move (?))) \ + id_column("") key_column("") value_column("") \ section(constraints_section) - #pragma db member(config_constraints) \ - virtual(build_constraints_map) \ - after(config_builds) \ - get(odb::nested_get ( \ - brep::build_package_config_constraints (this.configs))) \ - set(brep::build_package_config_constraints cs; \ - odb::nested_set (cs, std::move (?)); \ - move (cs).to_configs (this.configs)) \ - id_column("") key_column("") value_column("") \ + #pragma db member(config_constraints) \ + virtual(build_constraints_map) \ + after(config_builds) \ + get(odb::nested_get (this.configs, \ + &brep::build_package_config::constraints)) \ + set(odb::nested_set (this.configs, \ + &brep::build_package_config::constraints, \ + std::move (?))) \ + id_column("") key_column("") value_column("") \ section(constraints_section) - #pragma db member(config_auxiliaries) \ - virtual(build_auxiliaries_map) \ - after(config_constraints) \ - get(odb::nested_get ( \ - brep::build_package_config_auxiliaries (this.configs))) \ - set(brep::build_package_config_auxiliaries as; \ - odb::nested_set (as, std::move (?)); \ - move (as).to_configs (this.configs)) \ - id_column("") key_column("") value_column("") \ + #pragma db member(config_auxiliaries) \ + virtual(build_auxiliaries_map) \ + after(config_constraints) \ + get(odb::nested_get (this.configs, \ + &brep::build_package_config::auxiliaries)) \ + set(odb::nested_set (this.configs, \ + &brep::build_package_config::auxiliaries, \ + std::move (?))) \ + id_column("") key_column("") value_column("") \ section(auxiliaries_section) - #pragma db member(config_bot_keys) \ - virtual(build_package_bot_keys_map) \ - after(config_auxiliaries) \ - get(odb::nested_get ( \ - brep::build_package_config_bot_keys< \ - lazy_shared_ptr<brep::build_public_key>> (this.configs))) \ - set(brep::build_package_config_bot_keys< \ - lazy_shared_ptr<brep::build_public_key>> bks; \ - odb::nested_set (bks, std::move (?)); \ - move (bks).to_configs (this.configs)) \ - id_column("") key_column("") value_column("key_") \ + #pragma db member(config_bot_keys) \ + virtual(build_package_bot_keys_map) \ + after(config_auxiliaries) \ + get(odb::nested_get (this.configs, \ + &brep::build_package_config::bot_keys)) \ + set(odb::nested_set (this.configs, \ + &brep::build_package_config::bot_keys, \ + std::move (?))) \ + id_column("") key_column("") value_column("key_") \ section(bot_keys_section) #pragma db member(constraints_section) load(lazy) update(always) 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<K>::{builds,constraint,auxiliaries,bot_keys} - // via the separate nested containers using the adapter classes. - // + // Note that build_package_configs_template<K> is a container of the value + // type build_package_config_template<K>, 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<K>::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<K>::builds. - // - // Note: 1 as for build_package_configs_template. - // - class build_package_config_builds: public small_vector<build_class_exprs, 1> - { - public: - build_package_config_builds () = default; - - template <typename K> - explicit - build_package_config_builds (const build_package_configs_template<K>& cs) - { - reserve (cs.size ()); - for (const build_package_config_template<K>& c: cs) - push_back (c.builds); - } - - template <typename K> - void - to_configs (build_package_configs_template<K>& 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<K>::constraints // using build_constraint_key = odb::nested_key<build_constraints>; @@ -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<K>::constraints. - // - // Note: 1 as for build_package_configs_template. - // - class build_package_config_constraints: - public small_vector<build_constraints, 1> - { - public: - build_package_config_constraints () = default; - - template <typename K> - explicit - build_package_config_constraints ( - const build_package_configs_template<K>& cs) - { - reserve (cs.size ()); - for (const build_package_config_template<K>& c: cs) - push_back (c.constraints); - } - - template <typename K> - void - to_configs (build_package_configs_template<K>& 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<K>::auxiliaries // using build_auxiliary_key = odb::nested_key<build_auxiliaries>; @@ -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<K>::auxiliaries. - // - // Note: 1 as for build_package_configs_template. - // - class build_package_config_auxiliaries: - public small_vector<build_auxiliaries, 1> - { - public: - build_package_config_auxiliaries () = default; - - template <typename K> - explicit - build_package_config_auxiliaries ( - const build_package_configs_template<K>& cs) - { - reserve (cs.size ()); - for (const build_package_config_template<K>& c: cs) - push_back (c.auxiliaries); - } - - template <typename K> - void - to_configs (build_package_configs_template<K>& 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<K>::bot_keys // - // Adapter for build_package_config_template<K>::bot_keys. - // - // Note: 1 as for build_package_configs_template. - // - template <typename K> - class build_package_config_bot_keys: public small_vector<vector<K>, 1> - { - public: - build_package_config_bot_keys () = default; - - explicit - build_package_config_bot_keys (const build_package_configs_template<K>& cs) - { - this->reserve (cs.size ()); - for (const build_package_config_template<K>& c: cs) - this->push_back (c.bot_keys); - } - - void - to_configs (build_package_configs_template<K>& 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<K>& 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. diff --git a/libbrep/package.hxx b/libbrep/package.hxx index e2d2da5..79b2c68 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -902,50 +902,48 @@ namespace brep #pragma db member(build_configs) id_column("") value_column("config_") \ section(build_section) - #pragma db member(build_config_builds) \ - virtual(build_class_exprs_map) \ - after(build_configs) \ - get(odb::nested_get ( \ - brep::build_package_config_builds (this.build_configs))) \ - set(brep::build_package_config_builds bs; \ - odb::nested_set (bs, std::move (?)); \ - move (bs).to_configs (this.build_configs)) \ - id_column("") key_column("") value_column("") \ + #pragma db member(build_config_builds) \ + virtual(build_class_exprs_map) \ + after(build_configs) \ + get(odb::nested_get (this.build_configs, \ + &brep::package_build_config::builds)) \ + set(odb::nested_set (this.build_configs, \ + &brep::package_build_config::builds, \ + std::move (?))) \ + id_column("") key_column("") value_column("") \ section(build_section) - #pragma db member(build_config_constraints) \ - virtual(build_constraints_map) \ - after(build_config_builds) \ - get(odb::nested_get ( \ - brep::build_package_config_constraints (this.build_configs))) \ - set(brep::build_package_config_constraints cs; \ - odb::nested_set (cs, std::move (?)); \ - move (cs).to_configs (this.build_configs)) \ - id_column("") key_column("") value_column("") \ + #pragma db member(build_config_constraints) \ + virtual(build_constraints_map) \ + after(build_config_builds) \ + get(odb::nested_get (this.build_configs, \ + &brep::package_build_config::constraints)) \ + set(odb::nested_set (this.build_configs, \ + &brep::package_build_config::constraints, \ + std::move (?))) \ + id_column("") key_column("") value_column("") \ section(build_section) - #pragma db member(build_config_auxiliaries) \ - virtual(build_auxiliaries_map) \ - after(build_config_constraints) \ - get(odb::nested_get ( \ - brep::build_package_config_auxiliaries (this.build_configs))) \ - set(brep::build_package_config_auxiliaries as; \ - odb::nested_set (as, std::move (?)); \ - move (as).to_configs (this.build_configs)) \ - id_column("") key_column("") value_column("") \ + #pragma db member(build_config_auxiliaries) \ + virtual(build_auxiliaries_map) \ + after(build_config_constraints) \ + get(odb::nested_get (this.build_configs, \ + &brep::package_build_config::auxiliaries)) \ + set(odb::nested_set (this.build_configs, \ + &brep::package_build_config::auxiliaries, \ + std::move (?))) \ + id_column("") key_column("") value_column("") \ section(unused_section) - #pragma db member(build_config_bot_keys) \ - virtual(package_build_bot_keys_map) \ - after(build_config_auxiliaries) \ - get(odb::nested_get ( \ - brep::build_package_config_bot_keys< \ - lazy_shared_ptr<brep::public_key>> (this.build_configs))) \ - set(brep::build_package_config_bot_keys< \ - lazy_shared_ptr<brep::public_key>> bks; \ - odb::nested_set (bks, std::move (?)); \ - move (bks).to_configs (this.build_configs)) \ - id_column("") key_column("") value_column("key_") value_not_null \ + #pragma db member(build_config_bot_keys) \ + virtual(package_build_bot_keys_map) \ + after(build_config_auxiliaries) \ + get(odb::nested_get (this.build_configs, \ + &brep::package_build_config::bot_keys)) \ + set(odb::nested_set (this.build_configs, \ + &brep::package_build_config::bot_keys, \ + std::move (?))) \ + id_column("") key_column("") value_column("key_") value_not_null \ section(unused_section) #pragma db member(reviews) section(reviews_section) |