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

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_DEVICEINTERFACE_H
0008 #define SOLID_DEVICEINTERFACE_H
0009 
0010 #include <QObject>
0011 
0012 #include <solid/solid_export.h>
0013 
0014 namespace Solid
0015 {
0016 class Device;
0017 class DevicePrivate;
0018 class Predicate;
0019 class DeviceInterfacePrivate;
0020 
0021 /**
0022  * @class Solid::DeviceInterface deviceinterface.h <Solid/DeviceInterface>
0023  *
0024  * Base class of all the device interfaces.
0025  *
0026  * A device interface describes what a device can do. A device generally has
0027  * a set of device interfaces.
0028  */
0029 class SOLID_EXPORT DeviceInterface : public QObject
0030 {
0031     Q_OBJECT
0032     Q_DECLARE_PRIVATE(DeviceInterface)
0033 
0034 public:
0035     /**
0036      * This enum type defines the type of device interface that a Device can have.
0037      *
0038      * - Unknown : An undetermined device interface
0039      * - Processor : A processor
0040      * - Block : A block device
0041      * - StorageAccess : A mechanism to access data on a storage device
0042      * - StorageDrive : A storage drive
0043      * - OpticalDrive : An optical drive (CD-ROM, DVD, ...)
0044      * - StorageVolume : A volume
0045      * - OpticalDisc : An optical disc
0046      * - Camera : A digital camera
0047      * - PortableMediaPlayer: A portable media player
0048      * - NetworkShare: A network share interface
0049      */
0050     enum Type {
0051         Unknown = 0,
0052         GenericInterface = 1,
0053         Processor = 2,
0054         Block = 3,
0055         StorageAccess = 4,
0056         StorageDrive = 5,
0057         OpticalDrive = 6,
0058         StorageVolume = 7,
0059         OpticalDisc = 8,
0060         Camera = 9,
0061         PortableMediaPlayer = 10,
0062         Battery = 12,
0063         NetworkShare = 14,
0064         Last = 0xffff,
0065     };
0066     Q_ENUM(Type)
0067 
0068     /**
0069      * Destroys a DeviceInterface object.
0070      */
0071     ~DeviceInterface() override;
0072 
0073     /**
0074      * Indicates if this device interface is valid.
0075      * A device interface is considered valid if the device it is referring is available in the system.
0076      *
0077      * @return true if this device interface's device is available, false otherwise
0078      */
0079     bool isValid() const;
0080 
0081     /**
0082      *
0083      * @return the class name of the device interface type
0084      */
0085     static QString typeToString(Type type);
0086 
0087     /**
0088      *
0089      * @return the device interface type for the given class name
0090      */
0091     static Type stringToType(const QString &type);
0092 
0093     /**
0094      *
0095      * @return a description suitable to display in the UI of the device interface type
0096      * @since 4.4
0097      */
0098     static QString typeDescription(Type type);
0099 
0100 protected:
0101     /**
0102      * @internal
0103      * Creates a new DeviceInterface object.
0104      *
0105      * @param dd the private d member. It will take care of deleting it upon destruction.
0106      * @param backendObject the device interface object provided by the backend
0107      */
0108     SOLID_NO_EXPORT DeviceInterface(DeviceInterfacePrivate &dd, QObject *backendObject);
0109 
0110     DeviceInterfacePrivate *d_ptr;
0111 
0112 private:
0113     friend class Device;
0114     friend class DevicePrivate;
0115 };
0116 }
0117 
0118 #endif