| 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 "graphitemprofilepart.h" |
| 8 | #include <pugixml.hpp> |
| 9 | #include <string> |
| 10 | #include <string_view> |
| 11 | |
| 12 | class GraphItemXMLParser final |
| 13 | : public ProfilePartXMLParser |
| 14 | , public GraphItemProfilePart::Exporter |
| 15 | , public GraphItemProfilePart::Importer |
| 16 | { |
| 17 | public: |
| 18 | GraphItemXMLParser(std::string_view id) noexcept; |
| 19 | |
| 20 | std::unique_ptr<Exportable::Exporter> factory( |
| 21 | IProfilePartXMLParserProvider const &profilePartParserProvider) override; |
| 22 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 23 | |
| 24 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 25 | provideImporter(const Item &i) override; |
| 26 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 27 | provideExporter(const Item &i) override; |
| 28 | |
| 29 | void takeActive(bool active) override; |
| 30 | bool provideActive() const override; |
| 31 | |
| 32 | void takeColor(const std::string &color) override; |
| 33 | std::string const &provideColor() const override; |
| 34 | |
| 35 | void appendTo(pugi::xml_node &parentNode) override; |
| 36 | |
| 37 | protected: |
| 38 | void resetAttributes() override; |
| 39 | void loadPartFrom(pugi::xml_node const &parentNode) override; |
| 40 | |
| 41 | private: |
| 42 | class Initializer; |
| 43 | |
| 44 | bool active_; |
| 45 | bool activeDefault_; |
| 46 | |
| 47 | std::string colorDefault_; |
| 48 | }; |