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
28namespace Solid
29{
30class ProcessorPrivate;
31class Device;
32
33/**
34 * This device interface is available on processors.
35 */
36class SOLID_EXPORT Processor : public DeviceInterface
37{
38 Q_OBJECT
39 Q_PROPERTY(int number READ number)
40 Q_PROPERTY(qulonglong maxSpeed READ maxSpeed)
41 Q_PROPERTY(bool canChangeFrequency READ canChangeFrequency)
42 Q_PROPERTY(InstructionSets instructionSets READ instructionSets)
43 Q_DECLARE_PRIVATE(Processor)
44 friend class Device;
45
46private:
47 /**
48 * Creates a new Processor object.
49 * You generally won't need this. It's created when necessary using
50 * Device::as().
51 *
52 * @param backendObject the device interface object provided by the backend
53 * @see Solid::Device::as()
54 */
55 explicit Processor(QObject *backendObject);
56
57public:
58 /**
59 * This enum contains the list of architecture extensions you
60 * can query.
61 */
62 enum InstructionSet {
63 NoExtensions = 0x0,
64 IntelMmx = 0x1,
65 IntelSse = 0x2,
66 IntelSse2 = 0x4,
67 IntelSse3 = 0x8,
68 IntelSsse3 = 0x80,
69 IntelSse4 = 0x10,
70 IntelSse41 = 0x10,
71 IntelSse42 = 0x100,
72 Amd3DNow = 0x20,
73 AltiVec = 0x40
74 };
75 Q_ENUM(InstructionSet)
76
77 /*
78 * The flags for the Extension enum.
79 */
80 Q_DECLARE_FLAGS(InstructionSets, InstructionSet)
81 Q_FLAG(InstructionSets)
82
83 /**
84 * Destroys a Processor object.
85 */
86 virtual ~Processor();
87
88 /**
89 * Get the Solid::DeviceInterface::Type of the Processor device interface.
90 *
91 * @return the Processor device interface type
92 * @see Solid::Ifaces::Enums::DeviceInterface::Type
93 */
94 static Type deviceInterfaceType()
95 {
96 return DeviceInterface::Processor;
97 }
98
99 /**
100 * Retrieves the processor number in the system.
101 *
102 * @return the internal processor number in the system, starting from zero
103 */
104 int number() const;
105
106 /**
107 * Retrieves the maximum speed of the processor.
108 *
109 * @return the maximum speed in MHz, or 0 if the device can't be queried for this
110 * information.
111 */
112 int maxSpeed() const;
113
114 /**
115 * Indicates if the processor can change the CPU frequency.
116 *
117 * True if a processor is able to change its own CPU frequency.
118 * (generally for power management).
119 *
120 * @return true if the processor can change CPU frequency, false otherwise
121 */
122 bool canChangeFrequency() const;
123
124 /**
125 * Queries the instructions set extensions of the CPU.
126 *
127 * @return the extensions supported by the CPU
128 * @see Solid::Processor::InstructionSet
129 */
130 InstructionSets instructionSets() const;
131};
132}
133
134Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Processor::InstructionSets)
135
136#endif
137