Debian Codegraph @

src/core/iprofileiconcache.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 "iprofile.h"
7 #include <filesystem>
8 #include <functional>
9 #include <optional>
10 #include <utility>
11 #include <vector>
12
13 class IProfileIconCache
14 {
15 public:
16 /// Initialization method.
17 virtual void init() = 0;
18
19 /// Tries to use an icon from the cache, caching the fallback icon when no icon
20 /// was cached. If this also fails, it will try to use the fallback default icon.
21 /// @param info info of the profile to cache the icon for. His iconURL will be
22 /// updated on success
23 /// @param fallbackIcon data of the fallback icon to be cached
24 /// @returns true on success
25 virtual bool tryOrCache(IProfile::Info &info,
26 std::vector<char> const &fallbackIcon) = 0;
27
28 /// Adds an icon to the cache, overwriting any previous icon for the profile.
29 /// If this fails or there is no icon data, it will try to use the fallback
30 /// default icon.
31 /// @param info info of the profile to cache the icon for. His iconURL will be
32 /// updated on success
33 /// @param iconData data of the icon to be cached
34 /// @returns true on success
35 virtual bool cache(IProfile::Info &info, std::vector<char> const &iconData) = 0;
36
37 /// Syncs the cache icon when necessary.
38 /// @param info info of the profile whose icon will be synced in the cache
39 /// @return [success, updated] pair. Updated will be true when a new icon is
40 /// cached.
41 virtual std::pair<bool, bool> syncCache(IProfile::Info &info) = 0;
42
43 /// Cleans the profile cached icon on the cache.
44 virtual void clean(IProfile::Info &info) = 0;
45
46 virtual ~IProfileIconCache() = default;
47 };