Debian Codegraph @

src/core/profilestorage.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 "iprofilestorage.h"
7 #include <filesystem>
8 #include <memory>
9 #include <optional>
10 #include <string>
11 #include <vector>
12
13 class IProfileParser;
14 class IProfileFileParser;
15 class IProfileIconCache;
16
17 class ProfileStorage : public IProfileStorage
18 {
19 public:
20 ProfileStorage(std::filesystem::path &&path,
21 std::unique_ptr<IProfileParser> &&profileParser,
22 std::unique_ptr<IProfileFileParser> &&profileFileParser,
23 std::unique_ptr<IProfileIconCache> &&iconCache) noexcept;
24
25 void init(IProfile const &defaultProfile) override;
26
27 std::vector<std::unique_ptr<IProfile>>
28 profiles(IProfile const &baseProfile) override;
29 bool load(IProfile &profile) override;
30 bool save(IProfile &profile) override;
31 bool loadFrom(IProfile &profile,
32 std::filesystem::path const &path) const override;
33 bool exportTo(IProfile const &profile,
34 std::filesystem::path const &path) const override;
35 bool update(IProfile const &profile, IProfile::Info &newInfo) override;
36 void remove(IProfile::Info &info) override;
37
38 private:
39 void initProfilesDirectory() const;
40 bool profilesDirectoryExist() const;
41
42 bool loadProfileFromStorage(std::filesystem::path const &path,
43 IProfile &profile) const;
44 bool loadProfileFrom(std::filesystem::path const &path,
45 IProfile &profile) const;
46
47 std::filesystem::path const path_;
48 std::unique_ptr<IProfileParser> profileParser_;
49 std::unique_ptr<IProfileFileParser> profileFileParser_;
50 std::unique_ptr<IProfileIconCache> iconCache_;
51 std::string fileExtension_;
52 std::string profileDataFileName_;
53 };