| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "exportable.h" |
| 7 | #include "iprofile.h" |
| 8 | #include "iprofilepartview.h" |
| 9 | #include "iprofileview.h" |
| 10 | #include <functional> |
| 11 | #include <memory> |
| 12 | #include <optional> |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
| 16 | class ProfileView final : public IProfileView |
| 17 | { |
| 18 | public: |
| 19 | std::string const &name() const override; |
| 20 | std::vector<std::unique_ptr<IProfilePartView>> const &parts() const override; |
| 21 | |
| 22 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 23 | provideImporter(Item const &i) override; |
| 24 | |
| 25 | class Initializer : public IProfile::Exporter |
| 26 | { |
| 27 | public: |
| 28 | Initializer(ProfileView &profileView, |
| 29 | std::optional<std::reference_wrapper<IProfileView>> base = |
| 30 | std::nullopt) noexcept; |
| 31 | |
| 32 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 33 | provideExporter(Item const &i) override; |
| 34 | |
| 35 | void takeActive(bool active) override; |
| 36 | void takeInfo(IProfile::Info const &info) override; |
| 37 | |
| 38 | private: |
| 39 | ProfileView &profileView_; |
| 40 | std::optional<std::reference_wrapper<IProfileView>> base_; |
| 41 | }; |
| 42 | |
| 43 | private: |
| 44 | std::string name_; |
| 45 | std::vector<std::unique_ptr<IProfilePartView>> parts_; |
| 46 | }; |