| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "controlmode.h" |
| 7 | #include "core/profilepart.h" |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <string_view> |
| 11 | #include <vector> |
| 12 | |
| 13 | class ControlModeProfilePart |
| 14 | : public ProfilePart |
| 15 | , public ControlMode::Importer |
| 16 | { |
| 17 | public: |
| 18 | class Importer : public IProfilePart::Importer |
| 19 | { |
| 20 | public: |
| 21 | virtual std::string const &provideMode() const = 0; |
| 22 | }; |
| 23 | |
| 24 | class Exporter : public IProfilePart::Exporter |
| 25 | { |
| 26 | public: |
| 27 | virtual void takeMode(std::string const &mode) = 0; |
| 28 | }; |
| 29 | |
| 30 | ControlModeProfilePart(std::string_view id) noexcept; |
| 31 | |
| 32 | std::unique_ptr<Exportable::Exporter> |
| 33 | factory(IProfilePartProvider const &profilePartProvider) final override; |
| 34 | std::unique_ptr<Exportable::Exporter> initializer() final override; |
| 35 | |
| 36 | std::string const &ID() const final override; |
| 37 | |
| 38 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 39 | provideImporter(Item const &i) final override; |
| 40 | |
| 41 | bool provideActive() const final override; |
| 42 | std::string const &provideMode() const final override; |
| 43 | |
| 44 | protected: |
| 45 | void importProfilePart(IProfilePart::Importer &i) final override; |
| 46 | void exportProfilePart(IProfilePart::Exporter &e) const final override; |
| 47 | std::unique_ptr<IProfilePart> cloneProfilePart() const final override; |
| 48 | |
| 49 | virtual std::unique_ptr<ControlModeProfilePart> instance() const = 0; |
| 50 | |
| 51 | private: |
| 52 | void mode(std::string const &mode); |
| 53 | |
| 54 | class Factory; |
| 55 | class Initializer; |
| 56 | |
| 57 | std::vector<std::unique_ptr<IProfilePart>> parts_; |
| 58 | std::string const id_; |
| 59 | std::string mode_; |
| 60 | }; |