| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 | */ |
| 6 | |
| 7 | #ifndef SOLID_PROCESSOR_H |
| 8 | #define SOLID_PROCESSOR_H |
| 9 | |
| 10 | #include <solid/solid_export.h> |
| 11 | |
| 12 | #include <solid/deviceinterface.h> |
| 13 | |
| 14 | namespace Solid |
| 15 | { |
| 16 | class ProcessorPrivate; |
| 17 | class Device; |
| 18 | |
| 19 | /*! |
| 20 | * \class Solid::Processor |
| 21 | * \inheaderfile Solid/Processor |
| 22 | * \inmodule Solid |
| 23 | * |
| 24 | * \brief This device interface is available on processors. |
| 25 | */ |
| 26 | class SOLID_EXPORT Processor : public DeviceInterface |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | |
| 30 | /*! |
| 31 | * \property Solid::Processor::number |
| 32 | */ |
| 33 | Q_PROPERTY(int number READ number) |
| 34 | |
| 35 | /*! |
| 36 | * \property Solid::Processor::maxSpeed |
| 37 | */ |
| 38 | Q_PROPERTY(qulonglong maxSpeed READ maxSpeed) |
| 39 | |
| 40 | /*! |
| 41 | * \property Solid::Processor::canChangeFrequency |
| 42 | */ |
| 43 | Q_PROPERTY(bool canChangeFrequency READ canChangeFrequency) |
| 44 | |
| 45 | /*! |
| 46 | * \property Solid::Processor::instructionSets |
| 47 | */ |
| 48 | Q_PROPERTY(InstructionSets instructionSets READ instructionSets) |
| 49 | |
| 50 | Q_DECLARE_PRIVATE(Processor) |
| 51 | friend class Device; |
| 52 | |
| 53 | private: |
| 54 | /*! |
| 55 | * \internal |
| 56 | * Creates a new Processor object. |
| 57 | * You generally won't need this. It's created when necessary using |
| 58 | * Device::as(). |
| 59 | * |
| 60 | * \a backendObject the device interface object provided by the backend |
| 61 | * \sa Solid::Device::as() |
| 62 | */ |
| 63 | SOLID_NO_EXPORT explicit Processor(QObject *backendObject); |
| 64 | |
| 65 | public: |
| 66 | /*! |
| 67 | * This enum contains the list of architecture extensions you |
| 68 | * can query. |
| 69 | * |
| 70 | * \value NoExtensions |
| 71 | * \value IntelMmx |
| 72 | * \value IntelSse |
| 73 | * \value IntelSse2 |
| 74 | * \value IntelSse3 |
| 75 | * \value IntelSsse3 |
| 76 | * \value IntelSse4 |
| 77 | * \value IntelSse41 |
| 78 | * \value IntelSse42 |
| 79 | * \value Amd3DNow |
| 80 | * \value AltiVec |
| 81 | */ |
| 82 | enum InstructionSet { |
| 83 | NoExtensions = 0x0, |
| 84 | IntelMmx = 0x1, |
| 85 | IntelSse = 0x2, |
| 86 | IntelSse2 = 0x4, |
| 87 | IntelSse3 = 0x8, |
| 88 | IntelSsse3 = 0x80, |
| 89 | IntelSse4 = 0x10, |
| 90 | IntelSse41 = 0x10, |
| 91 | IntelSse42 = 0x100, |
| 92 | Amd3DNow = 0x20, |
| 93 | AltiVec = 0x40, |
| 94 | }; |
| 95 | Q_ENUM(InstructionSet) |
| 96 | |
| 97 | Q_DECLARE_FLAGS(InstructionSets, InstructionSet) |
| 98 | Q_FLAG(InstructionSets) |
| 99 | |
| 100 | ~Processor() override; |
| 101 | |
| 102 | /*! |
| 103 | * Get the Solid::DeviceInterface::Type of the Processor device interface. |
| 104 | * |
| 105 | * Returns the Processor device interface type |
| 106 | * \sa Solid::Ifaces::Enums::DeviceInterface::Type |
| 107 | */ |
| 108 | static Type deviceInterfaceType() |
| 109 | { |
| 110 | return DeviceInterface::Processor; |
| 111 | } |
| 112 | |
| 113 | /*! |
| 114 | * Retrieves the processor number in the system. |
| 115 | * |
| 116 | * Returns the internal processor number in the system, starting from zero |
| 117 | */ |
| 118 | int number() const; |
| 119 | |
| 120 | /*! |
| 121 | * Retrieves the maximum speed of the processor. |
| 122 | * |
| 123 | * Returns the maximum speed in MHz, or 0 if the device can't be queried for this |
| 124 | * information. |
| 125 | */ |
| 126 | int maxSpeed() const; |
| 127 | |
| 128 | /*! |
| 129 | * Indicates if the processor can change the CPU frequency. |
| 130 | * |
| 131 | * True if a processor is able to change its own CPU frequency. |
| 132 | * (generally for power management). |
| 133 | * |
| 134 | * Returns true if the processor can change CPU frequency, false otherwise |
| 135 | */ |
| 136 | bool canChangeFrequency() const; |
| 137 | |
| 138 | /*! |
| 139 | * Queries the instructions set extensions of the CPU. |
| 140 | * |
| 141 | * Returns the extensions supported by the CPU |
| 142 | * \sa Solid::Processor::InstructionSet |
| 143 | */ |
| 144 | InstructionSets instructionSets() const; |
| 145 | }; |
| 146 | |
| 147 | Q_DECLARE_OPERATORS_FOR_FLAGS(Processor::InstructionSets) |
| 148 | |
| 149 | } |
| 150 | |
| 151 | #endif |
| 152 | |