From 6e90b57a442424876b1325b9209f79c8a885a479 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 4 Jul 2017 11:27:47 +0300 Subject: Make use of foreign package objects in build-related functionality --- libbrep/build.hxx | 59 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'libbrep/build.hxx') diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 7a231bd..7f0aba6 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -57,10 +57,36 @@ namespace brep inline bool operator< (const build_id& x, const build_id& y) { - return - x.package < y.package ? true : - y.package < x.package ? false : - x.configuration < y.configuration; + if (x.package != y.package) + return x.package < y.package; + + if (int r = x.configuration.compare (y.configuration)) + return r < 0; + + return compare_version_lt (x.toolchain_version, y.toolchain_version, true); + } + + // These allow comparing objects that have package, configuration and + // toolchain_version data members to build_id values. The idea is that this + // works for both query members of build id types as well as for values of + // the build_id type. + // + template + inline auto + operator== (const T& x, const build_id& y) + -> decltype (x.package == y.package) + { + return x.package == y.package && x.configuration == y.configuration && + compare_version_eq (x.toolchain_version, y.toolchain_version, true); + } + + template + inline auto + operator!= (const T& x, const build_id& y) + -> decltype (x.package == y.package) + { + return x.package != y.package || x.configuration != y.configuration || + compare_version_ne (x.toolchain_version, y.toolchain_version, true); } // build_state @@ -267,26 +293,23 @@ namespace brep // Build of an existing internal package. // - #pragma db view \ - object(build) \ - object(build_package inner: \ - build::id.package.name == build_package::id.name && \ - brep::compare_version_eq (build::id.package.version, \ - build_package::id.version, \ - true) && \ + // Note that ADL can't find the equal operator, so we use the function call + // notation. + // + #pragma db view \ + object(build) \ + object(build_package inner: \ + brep::operator== (build::id.package, build_package::id) && \ build_package::internal_repository.is_not_null ()) struct package_build { shared_ptr build; }; - #pragma db view \ - object(build) \ - object(build_package inner: \ - build::id.package.name == build_package::id.name && \ - brep::compare_version_eq (build::id.package.version, \ - build_package::id.version, \ - true) && \ + #pragma db view \ + object(build) \ + object(build_package inner: \ + brep::operator== (build::id.package, build_package::id) && \ build_package::internal_repository.is_not_null ()) struct package_build_count { -- cgit v1.1