| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/profilepart.h" |
| 7 | #include "fancurve.h" |
| 8 | #include <string> |
| 9 | #include <utility> |
| 10 | #include <vector> |
| 11 | |
| 12 | namespace AMD { |
| 13 | |
| 14 | class FanCurveProfilePart final |
| 15 | : public ProfilePart |
| 16 | , public AMD::FanCurve::Importer |
| 17 | { |
| 18 | public: |
| 19 | class Importer : public IProfilePart::Importer |
| 20 | { |
| 21 | public: |
| 22 | virtual std::vector<FanCurve::Point> const &provideFanCurvePoints() const = 0; |
| 23 | virtual bool provideFanCurveFanStop() const = 0; |
| 24 | virtual units::concentration::percent_t |
| 25 | provideFanCurveFanStartValue() const = 0; |
| 26 | }; |
| 27 | |
| 28 | class Exporter : public IProfilePart::Exporter |
| 29 | { |
| 30 | public: |
| 31 | virtual void |
| 32 | takeFanCurvePoints(std::vector<FanCurve::Point> const &points) = 0; |
| 33 | virtual void takeFanCurveFanStop(bool enabled) = 0; |
| 34 | virtual void |
| 35 | takeFanCurveFanStartValue(units::concentration::percent_t value) = 0; |
| 36 | }; |
| 37 | |
| 38 | FanCurveProfilePart() noexcept; |
| 39 | |
| 40 | std::unique_ptr<Exportable::Exporter> |
| 41 | factory(IProfilePartProvider const &profilePartProvider) override; |
| 42 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 43 | |
| 44 | std::string const &ID() const override; |
| 45 | |
| 46 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 47 | provideImporter(Item const &i) override; |
| 48 | |
| 49 | bool provideActive() const override; |
| 50 | std::vector<FanCurve::Point> const &provideFanCurvePoints() const override; |
| 51 | bool provideFanCurveFanStop() const override; |
| 52 | units::concentration::percent_t provideFanCurveFanStartValue() const override; |
| 53 | |
| 54 | protected: |
| 55 | void importProfilePart(IProfilePart::Importer &i) override; |
| 56 | void exportProfilePart(IProfilePart::Exporter &e) const override; |
| 57 | std::unique_ptr<IProfilePart> cloneProfilePart() const override; |
| 58 | |
| 59 | private: |
| 60 | void points(std::vector<FanCurve::Point> const &points); |
| 61 | void startValue(units::concentration::percent_t value); |
| 62 | |
| 63 | class Initializer; |
| 64 | |
| 65 | std::string const id_; |
| 66 | |
| 67 | std::vector<FanCurve::Point> points_; |
| 68 | std::pair<units::temperature::celsius_t, units::temperature::celsius_t> tempRange_; |
| 69 | bool fanStop_; |
| 70 | units::concentration::percent_t fanStartValue_; |
| 71 | |
| 72 | static bool const registered_; |
| 73 | }; |
| 74 | |
| 75 | } // namespace AMD |