| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/exportable.h" |
| 7 | #include "core/importable.h" |
| 8 | #include "core/item.h" |
| 9 | #include <memory> |
| 10 | #include <string> |
| 11 | #include <string_view> |
| 12 | |
| 13 | class IProfile |
| 14 | : public Item |
| 15 | , public Importable |
| 16 | , public Exportable |
| 17 | { |
| 18 | public: |
| 19 | static constexpr std::string_view ItemID{"PROFILE"}; |
| 20 | |
| 21 | struct Info |
| 22 | { |
| 23 | static constexpr std::string_view GlobalID{"_global_"}; |
| 24 | static constexpr std::string_view ManualID{"_manual_"}; |
| 25 | static constexpr std::string_view GlobalIconURL{":/images/GlobalIcon"}; |
| 26 | static constexpr std::string_view DefaultIconURL{":/images/DefaultIcon"}; |
| 27 | |
| 28 | Info(std::string name = "", std::string exe = "", |
| 29 | std::string iconURL = std::string(DefaultIconURL)) |
| 30 | : name(name) |
| 31 | , exe(exe) |
| 32 | , iconURL(iconURL) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | bool hasCustomIcon() const |
| 37 | { |
| 38 | return iconURL != IProfile::Info::DefaultIconURL && |
| 39 | iconURL != IProfile::Info::GlobalIconURL; |
| 40 | } |
| 41 | |
| 42 | std::string name{""}; |
| 43 | std::string exe{""}; |
| 44 | std::string iconURL{DefaultIconURL}; |
| 45 | }; |
| 46 | |
| 47 | class Importer : public Importable::Importer |
| 48 | { |
| 49 | public: |
| 50 | virtual bool provideActive() const = 0; |
| 51 | virtual IProfile::Info const &provideInfo() const = 0; |
| 52 | |
| 53 | virtual ~Importer() = default; |
| 54 | }; |
| 55 | |
| 56 | class Exporter : public Exportable::Exporter |
| 57 | { |
| 58 | public: |
| 59 | virtual void takeActive(bool active) = 0; |
| 60 | virtual void takeInfo(Info const &info) = 0; |
| 61 | |
| 62 | virtual ~Exporter() = default; |
| 63 | }; |
| 64 | |
| 65 | virtual std::unique_ptr<Exportable::Exporter> initializer() = 0; |
| 66 | |
| 67 | virtual bool active() const = 0; |
| 68 | virtual void activate(bool active) = 0; |
| 69 | |
| 70 | virtual IProfile::Info const &info() const = 0; |
| 71 | virtual void info(IProfile::Info const &info) = 0; |
| 72 | |
| 73 | virtual std::unique_ptr<IProfile> clone() const = 0; |
| 74 | |
| 75 | virtual ~IProfile() = default; |
| 76 | }; |