| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "igpu.h" |
| 7 | #include "igpuprofilepart.h" |
| 8 | #include <memory> |
| 9 | #include <optional> |
| 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | class GPUProfilePart final |
| 14 | : public IGPUProfilePart |
| 15 | , public IGPU::Importer |
| 16 | { |
| 17 | public: |
| 18 | GPUProfilePart() noexcept; |
| 19 | |
| 20 | std::unique_ptr<Exportable::Exporter> |
| 21 | factory(IProfilePartProvider const &profilePartProvider) override; |
| 22 | std::unique_ptr<Exportable::Exporter> initializer() override; |
| 23 | |
| 24 | std::string const &ID() const override; |
| 25 | |
| 26 | bool belongsTo(Item const &i) const override; |
| 27 | std::string const &key() const override; |
| 28 | |
| 29 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 30 | provideImporter(Item const &i) override; |
| 31 | |
| 32 | bool provideActive() const override; |
| 33 | |
| 34 | protected: |
| 35 | void importProfilePart(IProfilePart::Importer &i) override; |
| 36 | void exportProfilePart(IProfilePart::Exporter &e) const override; |
| 37 | std::unique_ptr<IProfilePart> cloneProfilePart() const override; |
| 38 | |
| 39 | private: |
| 40 | void updateKey(); |
| 41 | |
| 42 | class Factory; |
| 43 | class Initializer; |
| 44 | |
| 45 | std::vector<std::unique_ptr<IProfilePart>> parts_; |
| 46 | std::string const id_; |
| 47 | std::string deviceID_; |
| 48 | std::string revision_; |
| 49 | std::string key_; |
| 50 | int index_{0}; |
| 51 | std::optional<std::string> uniqueID_; |
| 52 | |
| 53 | static bool const registered_; |
| 54 | }; |