Debian Codegraph @

src/core/ifilecache.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #pragma once
5
6 #include <filesystem>
7 #include <optional>
8 #include <string>
9 #include <vector>
10
11 class IFileCache
12 {
13 public:
14 /// Initializes the file chache.
15 virtual void init() = 0;
16
17 /// Adds an existing file to the cache.
18 /// @param path to the file to be cached
19 /// @param name target name for the cached file
20 /// @return path to the cached file when succeed
21 virtual std::optional<std::filesystem::path>
22 add(std::filesystem::path const &path, std::string const &name) = 0;
23
24 /// Adds a new file containing data to the cache.
25 /// @param data new file data to be cached
26 /// @param name target name for the cached file
27 /// @return path to the cached file when succeed
28 virtual std::optional<std::filesystem::path> add(std::vector<char> const &data,
29 std::string const &name) = 0;
30
31 /// Removes a cached file.
32 /// @param name name of the cached file to remove
33 virtual void remove(std::string const &name) = 0;
34
35 /// Gets the path of a file in the cache.
36 /// @param name name of the file
37 /// @param defaultPath path to be returned if no file exists on the cache
38 /// @return path to the file or defaultPath is set and no file with that name exists
39 /// on the cache
40 virtual std::optional<std::filesystem::path>
41 get(std::string const &name,
42 std::filesystem::path const &defaultPath = "") const = 0;
43
44 /// Gets the path to the cache.
45 virtual std::filesystem::path path() const = 0;
46
47 virtual ~IFileCache() = default;
48 };