aboutsummaryrefslogtreecommitdiff
path: root/libbrep/build.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-07-04 11:27:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-07-05 15:22:37 +0300
commit6e90b57a442424876b1325b9209f79c8a885a479 (patch)
treebcdc8ee050c05799e17dcca12d7afc80274840d0 /libbrep/build.hxx
parent17d44ec2c41a5b485cecae51a07396f85a601248 (diff)
Make use of foreign package objects in build-related functionality
Diffstat (limited to 'libbrep/build.hxx')
-rw-r--r--libbrep/build.hxx59
1 files changed, 41 insertions, 18 deletions
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 <typename T>
+ 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 <typename T>
+ 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<brep::build> 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
{