| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "controlgroupprofilepart.h" |
| 7 | #include "core/profilepartxmlparser.h" |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <string_view> |
| 11 | #include <vector> |
| 12 | |
| 13 | class ControlGroupXMLParser |
| 14 | : public ProfilePartXMLParser |
| 15 | , public ControlGroupProfilePart::Exporter |
| 16 | , public ControlGroupProfilePart::Importer |
| 17 | { |
| 18 | public: |
| 19 | ControlGroupXMLParser(std::string_view id) noexcept; |
| 20 | |
| 21 | std::unique_ptr<Exportable::Exporter> factory( |
| 22 | IProfilePartXMLParserProvider const &profilePartParserProvider) override; |
| 23 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 24 | |
| 25 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 26 | provideExporter(Item const &i) final override; |
| 27 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 28 | provideImporter(Item const &i) final override; |
| 29 | |
| 30 | void takeActive(bool active) final override; |
| 31 | bool provideActive() const final override; |
| 32 | |
| 33 | void appendTo(pugi::xml_node &parentNode) final override; |
| 34 | |
| 35 | protected: |
| 36 | void resetAttributes() final override; |
| 37 | void loadPartFrom(pugi::xml_node const &parentNode) override; |
| 38 | |
| 39 | void loadComponents(pugi::xml_node const &parentNode); |
| 40 | bool activeDefault() const; |
| 41 | |
| 42 | private: |
| 43 | class Factory; |
| 44 | class Initializer; |
| 45 | |
| 46 | std::vector<std::unique_ptr<IProfilePartXMLParser>> parsers_; |
| 47 | |
| 48 | bool active_; |
| 49 | bool activeDefault_; |
| 50 | }; |