diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-24 12:20:32 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-25 13:59:48 +0200 |
commit | dbac8a19685b83dd1d656201da900a20e11428f2 (patch) | |
tree | 311ecff8b9498f3753d2df83b95d7301f11d90d8 /src/buildtool/execution_api | |
parent | f77492425703122c9b977ba3e0f9f5fdd80a08d1 (diff) | |
download | justbuild-dbac8a19685b83dd1d656201da900a20e11428f2.tar.gz |
Introduce a type allias for an optional ptr to IExecutionApi
...and replace verbose constructions.
Diffstat (limited to 'src/buildtool/execution_api')
5 files changed, 7 insertions, 9 deletions
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<IExecutionApi const>; + using OptionalPtr = std::optional<gsl::not_null<IExecutionApi const*>>; IExecutionApi() = default; IExecutionApi(IExecutionApi const&) = delete; @@ -70,7 +71,7 @@ class IExecutionApi { [[nodiscard]] virtual auto RetrieveToPaths( std::vector<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<const IExecutionApi*>> 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<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional< - gsl::not_null<const IExecutionApi*>> 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<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional< - gsl::not_null<const IExecutionApi*>> 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<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<const IExecutionApi*>> 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<Artifact::ObjectInfo> const& artifacts_info, std::vector<std::filesystem::path> const& output_paths, - std::optional<gsl::not_null<const IExecutionApi*>> const& alternative = + IExecutionApi::OptionalPtr const& alternative = std::nullopt) const noexcept -> bool final; [[nodiscard]] auto RetrieveToFds( |