| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "../icpuinfo.h" |
| 7 | #include "core/idatasource.h" |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <string_view> |
| 11 | #include <utility> |
| 12 | #include <vector> |
| 13 | |
| 14 | class CPUInfoProcCpuInfo final : public ICPUInfo::IProvider |
| 15 | { |
| 16 | public: |
| 17 | CPUInfoProcCpuInfo(std::unique_ptr<IDataSource<std::vector<std::string>>> |
| 18 | &&dataSource) noexcept; |
| 19 | |
| 20 | std::vector<std::pair<std::string, std::string>> provideInfo( |
| 21 | int physicalId, |
| 22 | std::vector<ICPUInfo::ExecutionUnit> const &executionUnits) override; |
| 23 | |
| 24 | std::vector<std::string> provideCapabilities( |
| 25 | int physicalId, |
| 26 | std::vector<ICPUInfo::ExecutionUnit> const &executionUnits) override; |
| 27 | |
| 28 | private: |
| 29 | void addInfo(std::string_view target, std::string_view key, int cpuId, |
| 30 | std::vector<std::pair<std::string, std::string>> &info, |
| 31 | std::vector<std::string> const &lines) const; |
| 32 | |
| 33 | std::unique_ptr<IDataSource<std::vector<std::string>>> const dataSource_; |
| 34 | static bool registered_; |
| 35 | }; |