| 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 "fanfixed.h" |
| 8 | #include <string> |
| 9 | |
| 10 | namespace AMD { |
| 11 | |
| 12 | class FanFixedProfilePart final |
| 13 | : public ProfilePart |
| 14 | , public AMD::FanFixed::Importer |
| 15 | { |
| 16 | public: |
| 17 | class Importer : public IProfilePart::Importer |
| 18 | { |
| 19 | public: |
| 20 | virtual units::concentration::percent_t provideFanFixedValue() const = 0; |
| 21 | virtual bool provideFanFixedFanStop() const = 0; |
| 22 | virtual units::concentration::percent_t |
| 23 | provideFanFixedFanStartValue() const = 0; |
| 24 | }; |
| 25 | |
| 26 | class Exporter : public IProfilePart::Exporter |
| 27 | { |
| 28 | public: |
| 29 | virtual void takeFanFixedValue(units::concentration::percent_t value) = 0; |
| 30 | virtual void takeFanFixedFanStop(bool enabled) = 0; |
| 31 | virtual void |
| 32 | takeFanFixedFanStartValue(units::concentration::percent_t value) = 0; |
| 33 | }; |
| 34 | |
| 35 | FanFixedProfilePart() noexcept; |
| 36 | |
| 37 | std::unique_ptr<Exportable::Exporter> |
| 38 | factory(IProfilePartProvider const &profilePartProvider) override; |
| 39 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 40 | |
| 41 | std::string const &ID() const override; |
| 42 | |
| 43 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 44 | provideImporter(Item const &i) override; |
| 45 | |
| 46 | bool provideActive() const override; |
| 47 | units::concentration::percent_t provideFanFixedValue() const override; |
| 48 | bool provideFanFixedFanStop() const override; |
| 49 | units::concentration::percent_t provideFanFixedFanStartValue() const override; |
| 50 | |
| 51 | protected: |
| 52 | void importProfilePart(IProfilePart::Importer &i) override; |
| 53 | void exportProfilePart(IProfilePart::Exporter &e) const override; |
| 54 | std::unique_ptr<IProfilePart> cloneProfilePart() const override; |
| 55 | |
| 56 | private: |
| 57 | void value(units::concentration::percent_t value); |
| 58 | void startValue(units::concentration::percent_t value); |
| 59 | |
| 60 | class Initializer; |
| 61 | |
| 62 | std::string const id_; |
| 63 | |
| 64 | units::concentration::percent_t value_; |
| 65 | |
| 66 | bool fanStop_; |
| 67 | units::concentration::percent_t fanStartValue_; |
| 68 | |
| 69 | static bool const registered_; |
| 70 | }; |
| 71 | |
| 72 | } // namespace AMD |