From dbac8a19685b83dd1d656201da900a20e11428f2 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Mon, 24 Jun 2024 12:20:32 +0200 Subject: Introduce a type allias for an optional ptr to IExecutionApi ...and replace verbose constructions. --- src/buildtool/execution_api/common/execution_api.hpp | 3 ++- src/buildtool/execution_api/git/git_api.hpp | 3 +-- src/buildtool/execution_api/local/local_api.hpp | 5 ++--- src/buildtool/execution_api/remote/bazel/bazel_api.cpp | 3 +-- src/buildtool/execution_api/remote/bazel/bazel_api.hpp | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/buildtool/execution_api') diff --git a/src/buildtool/execution_api/common/execution_api.hpp b/src/buildtool/execution_api/common/execution_api.hpp index 72663c2e..b86ddd1f 100644 --- a/src/buildtool/execution_api/common/execution_api.hpp +++ b/src/buildtool/execution_api/common/execution_api.hpp @@ -35,6 +35,7 @@ class IExecutionApi { public: using Ptr = std::shared_ptr; + using OptionalPtr = std::optional>; IExecutionApi() = default; IExecutionApi(IExecutionApi const&) = delete; @@ -70,7 +71,7 @@ class IExecutionApi { [[nodiscard]] virtual auto RetrieveToPaths( std::vector const& artifacts_info, std::vector const& output_paths, - std::optional> const& alternative = + IExecutionApi::OptionalPtr const& alternative = std::nullopt) const noexcept -> bool = 0; /// \brief Retrieve artifacts from CAS and write to file descriptors. diff --git a/src/buildtool/execution_api/git/git_api.hpp b/src/buildtool/execution_api/git/git_api.hpp index 53184988..d35000fd 100644 --- a/src/buildtool/execution_api/git/git_api.hpp +++ b/src/buildtool/execution_api/git/git_api.hpp @@ -54,8 +54,7 @@ class GitApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector const& artifacts_info, std::vector const& output_paths, - std::optional< - gsl::not_null> const& /*alternative*/ + IExecutionApi::OptionalPtr const& /*alternative*/ = std::nullopt) const noexcept -> bool override { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Error, diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 928fb5b8..cbb904ef 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -78,9 +78,8 @@ class LocalApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector const& artifacts_info, std::vector const& output_paths, - std::optional< - gsl::not_null> const& /*alternative*/ - = std::nullopt) const noexcept -> bool final { + IExecutionApi::OptionalPtr const& /*alternative*/ = + std::nullopt) const noexcept -> bool final { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Error, "different number of digests and output paths."); diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp index b475dfe8..f636c265 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp @@ -221,8 +221,7 @@ auto BazelApi::CreateAction( [[nodiscard]] auto BazelApi::RetrieveToPaths( std::vector const& artifacts_info, std::vector const& output_paths, - std::optional> const& alternative) - const noexcept -> bool { + IExecutionApi::OptionalPtr const& alternative) const noexcept -> bool { if (artifacts_info.size() != output_paths.size()) { Logger::Log(LogLevel::Warning, "different number of digests and output paths."); diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp index a9149450..e5669933 100644 --- a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp +++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp @@ -62,7 +62,7 @@ class BazelApi final : public IExecutionApi { [[nodiscard]] auto RetrieveToPaths( std::vector const& artifacts_info, std::vector const& output_paths, - std::optional> const& alternative = + IExecutionApi::OptionalPtr const& alternative = std::nullopt) const noexcept -> bool final; [[nodiscard]] auto RetrieveToFds( -- cgit v1.2.3