1 | /* |
2 | Copyright 2006-2007 Kevin Ottens <ervin@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the License, or (at your option) version 3, or any |
8 | later version accepted by the membership of KDE e.V. (or its |
9 | successor approved by the membership of KDE e.V.), which shall |
10 | act as a proxy defined in Section 6 of version 3 of the license. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Lesser General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Lesser General Public |
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
19 | */ |
20 | |
21 | #ifndef SOLID_PROCESSOR_H |
22 | #define SOLID_PROCESSOR_H |
23 | |
24 | #include <solid/solid_export.h> |
25 | |
26 | #include <solid/deviceinterface.h> |
27 | |
28 | namespace Solid |
29 | { |
30 | class ProcessorPrivate; |
31 | class Device; |
32 | |
33 | /** |
34 | * This device interface is available on processors. |
35 | */ |
36 | class SOLID_EXPORT Processor : public DeviceInterface |
37 | { |
38 | Q_OBJECT |
39 | Q_ENUMS(InstructionSet) |
40 | Q_FLAGS(InstructionSets) |
41 | Q_PROPERTY(int number READ number) |
42 | Q_PROPERTY(qulonglong maxSpeed READ maxSpeed) |
43 | Q_PROPERTY(bool canChangeFrequency READ canChangeFrequency) |
44 | Q_PROPERTY(InstructionSets instructionSets READ instructionSets) |
45 | Q_DECLARE_PRIVATE(Processor) |
46 | friend class Device; |
47 | |
48 | private: |
49 | /** |
50 | * Creates a new Processor object. |
51 | * You generally won't need this. It's created when necessary using |
52 | * Device::as(). |
53 | * |
54 | * @param backendObject the device interface object provided by the backend |
55 | * @see Solid::Device::as() |
56 | */ |
57 | explicit Processor(QObject *backendObject); |
58 | |
59 | public: |
60 | /** |
61 | * This enum contains the list of architecture extensions you |
62 | * can query. |
63 | */ |
64 | enum InstructionSet { |
65 | NoExtensions = 0x0, |
66 | IntelMmx = 0x1, |
67 | IntelSse = 0x2, |
68 | IntelSse2 = 0x4, |
69 | IntelSse3 = 0x8, |
70 | IntelSse4 = 0x10, |
71 | Amd3DNow = 0x20, |
72 | AltiVec = 0x40 |
73 | }; |
74 | |
75 | /* |
76 | * The flags for the Extension enum. |
77 | */ |
78 | Q_DECLARE_FLAGS(InstructionSets, InstructionSet) |
79 | |
80 | |
81 | /** |
82 | * Destroys a Processor object. |
83 | */ |
84 | virtual ~Processor(); |
85 | |
86 | /** |
87 | * Get the Solid::DeviceInterface::Type of the Processor device interface. |
88 | * |
89 | * @return the Processor device interface type |
90 | * @see Solid::Ifaces::Enums::DeviceInterface::Type |
91 | */ |
92 | static Type deviceInterfaceType() { return DeviceInterface::Processor; } |
93 | |
94 | /** |
95 | * Retrieves the processor number in the system. |
96 | * |
97 | * @return the internal processor number in the system, starting from zero |
98 | */ |
99 | int number() const; |
100 | |
101 | /** |
102 | * Retrieves the maximum speed of the processor. |
103 | * |
104 | * @return the maximum speed in MHz, or 0 if the device can't be queried for this |
105 | * information. |
106 | */ |
107 | int maxSpeed() const; |
108 | |
109 | /** |
110 | * Indicates if the processor can change the CPU frequency. |
111 | * |
112 | * True if a processor is able to change its own CPU frequency. |
113 | * (generally for power management). |
114 | * |
115 | * @return true if the processor can change CPU frequency, false otherwise |
116 | */ |
117 | bool canChangeFrequency() const; |
118 | |
119 | /** |
120 | * Queries the instructions set extensions of the CPU. |
121 | * |
122 | * @return the extensions supported by the CPU |
123 | * @see Solid::Processor::InstructionSet |
124 | */ |
125 | InstructionSets instructionSets() const; |
126 | }; |
127 | } |
128 | |
129 | Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Processor::InstructionSets) |
130 | |
131 | #endif |
132 | |