Android-cuttlefish cvd tool
caching_build_api.h
Go to the documentation of this file.
1//
2// Copyright (C) 2024 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include <memory>
19#include <string>
20
26
27namespace cuttlefish {
28
29class CachingBuildApi : public BuildApi<BuildString, Build> {
30 public:
31 CachingBuildApi(BuildApi& build_api, std::string cache_base_path);
32
33 Result<Build> GetBuild(const BuildString& build_string) override;
35 const std::string& target_directory,
36 const std::string& artifact_name) override;
37
39 const Build&, const std::string& artifact) override;
40
41 private:
43 std::string cache_base_path_;
44};
45
46} // namespace cuttlefish
Definition: build_api.h:27
Definition: caching_build_api.h:29
Result< Build > GetBuild(const BuildString &build_string) override
Definition: caching_build_api.cpp:105
Result< std::string > DownloadFile(const Build &build, const std::string &target_directory, const std::string &artifact_name) override
Definition: caching_build_api.cpp:109
BuildApi & build_api_
Definition: caching_build_api.h:42
CachingBuildApi(BuildApi &build_api, std::string cache_base_path)
Definition: caching_build_api.cpp:101
Result< std::unique_ptr< ReaderSeeker > > FileReader(const Build &, const std::string &artifact) override
Definition: caching_build_api.cpp:140
std::string cache_base_path_
Definition: caching_build_api.h:43
Definition: alloc_driver.h:21
std::variant< DeviceBuild, DirectoryBuild, GcsBuild, HttpBuild > Build
Definition: android_build.h:110
std::variant< DeviceBuildString, DirectoryBuildString, GcsBuildString, HttpBuildString > BuildString
Definition: android_build_string.h:35
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30