| 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 "iprofileview.h" |
| 8 | #include "isysmodel.h" |
| 9 | #include "profilepart.h" |
| 10 | #include <memory> |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | |
| 14 | class IProfilePartProvider; |
| 15 | |
| 16 | class Profile final |
| 17 | : public IProfile |
| 18 | , public IProfileView::View |
| 19 | { |
| 20 | public: |
| 21 | Profile() noexcept; |
| 22 | |
| 23 | Profile(Profile const &) = delete; |
| 24 | Profile &operator=(Profile const &) = delete; |
| 25 | |
| 26 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 27 | |
| 28 | bool active() const override; |
| 29 | void activate(bool active) override; |
| 30 | |
| 31 | IProfile::Info const &info() const override; |
| 32 | void info(IProfile::Info const &info) override; |
| 33 | |
| 34 | std::unique_ptr<IProfile> clone() const override; |
| 35 | |
| 36 | std::string const &ID() const override; |
| 37 | void importWith(Importable::Importer &i) override; |
| 38 | void exportWith(Exportable::Exporter &e) const override; |
| 39 | |
| 40 | std::string const &name() const override; |
| 41 | std::vector<std::shared_ptr<IProfilePart>> const &parts() const override; |
| 42 | |
| 43 | class Factory final |
| 44 | : public ProfilePart::Factory |
| 45 | , public ISysModel::Exporter |
| 46 | { |
| 47 | public: |
| 48 | Factory(IProfilePartProvider const &profilePartProvider, |
| 49 | Profile &outer) noexcept; |
| 50 | |
| 51 | void takeProfilePart(std::unique_ptr<IProfilePart> &&part) override; |
| 52 | |
| 53 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 54 | provideExporter(Item const &i) override; |
| 55 | |
| 56 | private: |
| 57 | Profile &outer_; |
| 58 | }; |
| 59 | |
| 60 | private: |
| 61 | class Initializer; |
| 62 | |
| 63 | std::string const id_; |
| 64 | std::vector<std::shared_ptr<IProfilePart>> parts_; |
| 65 | |
| 66 | IProfile::Info info_; |
| 67 | bool active_{true}; |
| 68 | }; |