File indexing completed on 2024-05-12 04:01:51

0001 /*
0002     SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef SOLID_PROCESSOR_H
0008 #define SOLID_PROCESSOR_H
0009 
0010 #include <solid/solid_export.h>
0011 
0012 #include <solid/deviceinterface.h>
0013 
0014 namespace Solid
0015 {
0016 class ProcessorPrivate;
0017 class Device;
0018 
0019 /**
0020  * @class Solid::Processor processor.h <Solid/Processor>
0021  *
0022  * This device interface is available on processors.
0023  */
0024 class SOLID_EXPORT Processor : public DeviceInterface
0025 {
0026     Q_OBJECT
0027     Q_PROPERTY(int number READ number)
0028     Q_PROPERTY(qulonglong maxSpeed READ maxSpeed)
0029     Q_PROPERTY(bool canChangeFrequency READ canChangeFrequency)
0030     Q_PROPERTY(InstructionSets instructionSets READ instructionSets)
0031     Q_DECLARE_PRIVATE(Processor)
0032     friend class Device;
0033 
0034 private:
0035     /**
0036      * Creates a new Processor object.
0037      * You generally won't need this. It's created when necessary using
0038      * Device::as().
0039      *
0040      * @param backendObject the device interface object provided by the backend
0041      * @see Solid::Device::as()
0042      */
0043     SOLID_NO_EXPORT explicit Processor(QObject *backendObject);
0044 
0045 public:
0046     /**
0047      * This enum contains the list of architecture extensions you
0048      * can query.
0049      *
0050      * @see InstructionSets
0051      */
0052     enum InstructionSet {
0053         NoExtensions = 0x0,
0054         IntelMmx = 0x1,
0055         IntelSse = 0x2,
0056         IntelSse2 = 0x4,
0057         IntelSse3 = 0x8,
0058         IntelSsse3 = 0x80,
0059         IntelSse4 = 0x10,
0060         IntelSse41 = 0x10,
0061         IntelSse42 = 0x100,
0062         Amd3DNow = 0x20,
0063         AltiVec = 0x40,
0064     };
0065     Q_ENUM(InstructionSet)
0066 
0067     /*
0068      * Stores a combination of #InstructionSet values.
0069      */
0070     Q_DECLARE_FLAGS(InstructionSets, InstructionSet)
0071     Q_FLAG(InstructionSets)
0072 
0073     /**
0074      * Destroys a Processor object.
0075      */
0076     ~Processor() override;
0077 
0078     /**
0079      * Get the Solid::DeviceInterface::Type of the Processor device interface.
0080      *
0081      * @return the Processor device interface type
0082      * @see Solid::Ifaces::Enums::DeviceInterface::Type
0083      */
0084     static Type deviceInterfaceType()
0085     {
0086         return DeviceInterface::Processor;
0087     }
0088 
0089     /**
0090      * Retrieves the processor number in the system.
0091      *
0092      * @return the internal processor number in the system, starting from zero
0093      */
0094     int number() const;
0095 
0096     /**
0097      * Retrieves the maximum speed of the processor.
0098      *
0099      * @return the maximum speed in MHz, or 0 if the device can't be queried for this
0100      * information.
0101      */
0102     int maxSpeed() const;
0103 
0104     /**
0105      * Indicates if the processor can change the CPU frequency.
0106      *
0107      * True if a processor is able to change its own CPU frequency.
0108      *  (generally for power management).
0109      *
0110      * @return true if the processor can change CPU frequency, false otherwise
0111      */
0112     bool canChangeFrequency() const;
0113 
0114     /**
0115      * Queries the instructions set extensions of the CPU.
0116      *
0117      * @return the extensions supported by the CPU
0118      * @see Solid::Processor::InstructionSet
0119      */
0120     InstructionSets instructionSets() const;
0121 };
0122 
0123 Q_DECLARE_OPERATORS_FOR_FLAGS(Processor::InstructionSets)
0124 
0125 }
0126 
0127 #endif