| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/profilepartxmlparser.h" |
| 7 | #include "icpuprofilepart.h" |
| 8 | #include <memory> |
| 9 | #include <pugixml.hpp> |
| 10 | #include <string> |
| 11 | #include <unordered_map> |
| 12 | |
| 13 | class CPUXMLParser final |
| 14 | : public ProfilePartXMLParser |
| 15 | , public ICPUProfilePart::Exporter |
| 16 | , public ICPUProfilePart::Importer |
| 17 | { |
| 18 | public: |
| 19 | CPUXMLParser() 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) override; |
| 27 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 28 | provideImporter(Item const &i) override; |
| 29 | |
| 30 | void takeActive(bool active) override; |
| 31 | bool provideActive() const override; |
| 32 | |
| 33 | void takePhysicalId(int id) override; |
| 34 | int providePhysicalId() const override; |
| 35 | |
| 36 | void appendTo(pugi::xml_node &parentNode) override; |
| 37 | |
| 38 | protected: |
| 39 | void resetAttributes() override; |
| 40 | void loadPartFrom(pugi::xml_node const &parentNode) override; |
| 41 | |
| 42 | private: |
| 43 | class Factory; |
| 44 | class Initializer; |
| 45 | |
| 46 | std::unordered_map<std::string, std::unique_ptr<IProfilePartXMLParser>> parsers_; |
| 47 | |
| 48 | bool active_; |
| 49 | bool activeDefault_; |
| 50 | |
| 51 | int physicalId_; |
| 52 | int physicalIdDefault_; |
| 53 | |
| 54 | static bool const registered_; |
| 55 | }; |