| 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 "fancurveprofilepart.h" |
| 8 | #include <string> |
| 9 | #include <string_view> |
| 10 | #include <vector> |
| 11 | |
| 12 | namespace AMD { |
| 13 | |
| 14 | class FanCurveXMLParser final |
| 15 | : public ProfilePartXMLParser |
| 16 | , public AMD::FanCurveProfilePart::Exporter |
| 17 | , public AMD::FanCurveProfilePart::Importer |
| 18 | { |
| 19 | public: |
| 20 | FanCurveXMLParser() noexcept; |
| 21 | |
| 22 | std::unique_ptr<Exportable::Exporter> factory( |
| 23 | IProfilePartXMLParserProvider const &profilePartParserProvider) override; |
| 24 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 25 | |
| 26 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 27 | provideExporter(Item const &i) override; |
| 28 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 29 | provideImporter(Item const &i) override; |
| 30 | |
| 31 | void takeActive(bool active) override; |
| 32 | bool provideActive() const override; |
| 33 | |
| 34 | void takeFanCurvePoints(std::vector<FanCurve::Point> const &points) override; |
| 35 | std::vector<FanCurve::Point> const &provideFanCurvePoints() const override; |
| 36 | |
| 37 | void takeFanCurveFanStop(bool enabled) override; |
| 38 | bool provideFanCurveFanStop() const override; |
| 39 | |
| 40 | void takeFanCurveFanStartValue(units::concentration::percent_t value) override; |
| 41 | units::concentration::percent_t provideFanCurveFanStartValue() const override; |
| 42 | |
| 43 | void appendTo(pugi::xml_node &parentNode) override; |
| 44 | |
| 45 | protected: |
| 46 | void resetAttributes() override; |
| 47 | void loadPartFrom(pugi::xml_node const &parentNode) override; |
| 48 | |
| 49 | private: |
| 50 | static constexpr std::string_view CurveNodeName{"CURVE"}; |
| 51 | static constexpr std::string_view PointNodeName{"POINT"}; |
| 52 | |
| 53 | class Initializer; |
| 54 | |
| 55 | bool active_; |
| 56 | bool activeDefault_; |
| 57 | |
| 58 | std::vector<FanCurve::Point> points_; |
| 59 | std::vector<FanCurve::Point> pointsDefault_; |
| 60 | |
| 61 | bool fanStop_; |
| 62 | bool fanStopDefault_; |
| 63 | |
| 64 | unsigned int fanStartValue_; |
| 65 | unsigned int fanStartValueDefault_; |
| 66 | |
| 67 | static bool const registered_; |
| 68 | }; |
| 69 | |
| 70 | } // namespace AMD |