From 1c6acd97737f4d49b5e0d1dbb97e3c1d75d0e145 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Fri, 24 May 2024 11:01:03 +0200 Subject: Use common interface for reading tree entries and leafs ...in LocalApi and BazelApi. --- .../execution_api/local/local_cas_reader.hpp | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/buildtool/execution_api/local/local_cas_reader.hpp (limited to 'src/buildtool/execution_api/local/local_cas_reader.hpp') diff --git a/src/buildtool/execution_api/local/local_cas_reader.hpp b/src/buildtool/execution_api/local/local_cas_reader.hpp new file mode 100644 index 00000000..69baf3a9 --- /dev/null +++ b/src/buildtool/execution_api/local/local_cas_reader.hpp @@ -0,0 +1,39 @@ +// Copyright 2024 Huawei Cloud Computing Technology Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_API_LOCAL_LOCAL_CAS_READER_HPP +#define INCLUDED_SRC_BUILDTOOL_EXECUTION_API_LOCAL_LOCAL_CAS_READER_HPP + +#include + +#include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/common/bazel_types.hpp" +#include "src/buildtool/file_system/git_repo.hpp" +#include "src/buildtool/storage/local_cas.hpp" + +class LocalCasReader final { + public: + explicit LocalCasReader(LocalCAS const& cas) noexcept : cas_(cas) {} + + [[nodiscard]] auto ReadDirectory(ArtifactDigest const& digest) + const noexcept -> std::optional; + + [[nodiscard]] auto ReadGitTree(ArtifactDigest const& digest) const noexcept + -> std::optional; + + private: + LocalCAS const& cas_; +}; + +#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_LOCAL_LOCAL_CAS_READER_HPP \ No newline at end of file -- cgit v1.2.3