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