Solid

frontend/genericinterface.h
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_GENERICINTERFACE_H
8#define SOLID_GENERICINTERFACE_H
9
10#include <QMap>
11#include <QVariant>
12
13#include <solid/deviceinterface.h>
14#include <solid/solid_export.h>
15
16namespace Solid
17{
18class GenericInterfacePrivate;
19class Device;
20
21/**
22 * @class Solid::GenericInterface genericinterface.h <Solid/GenericInterface>
23 *
24 * Generic interface to deal with a device. It exposes a set of properties
25 * and is organized as a key/value set.
26 *
27 * Warning: Using this class could expose some backend specific details
28 * and lead to non portable code. Use it at your own risk, or during
29 * transitional phases when the provided device interfaces don't
30 * provide the necessary methods.
31 */
32class SOLID_EXPORT GenericInterface : public DeviceInterface
33{
34 Q_OBJECT
35 Q_DECLARE_PRIVATE(GenericInterface)
36 friend class Device;
37
38public:
39 /**
40 * This enum type defines the type of change that can occur to a GenericInterface
41 * property.
42 *
43 * - PropertyModified : A property value has changed in the device
44 * - PropertyAdded : A new property has been added to the device
45 * - PropertyRemoved : A property has been removed from the device
46 */
48 PropertyModified,
49 PropertyAdded,
50 PropertyRemoved,
51 };
52 Q_ENUM(PropertyChange)
53
54private:
55 /**
56 * Creates a new GenericInterface object.
57 * You generally won't need this. It's created when necessary using
58 * Device::as().
59 *
60 * @param backendObject the device interface object provided by the backend
61 * @see Solid::Device::as()
62 */
63 SOLID_NO_EXPORT explicit GenericInterface(QObject *backendObject);
64
65public:
66 /**
67 * Destroys a Processor object.
68 */
69 ~GenericInterface() override;
70
71 /**
72 * Get the Solid::DeviceInterface::Type of the GenericInterface device interface.
73 *
74 * @return the Processor device interface type
75 * @see Solid::Ifaces::Enums::DeviceInterface::Type
76 */
78 {
79 return DeviceInterface::GenericInterface;
80 }
81
82 /**
83 * Retrieves a property of the device.
84 *
85 * Warning: Using this method could expose some backend specific details
86 * and lead to non portable code. Use it at your own risk, or during
87 * transitional phases when the provided device interfaces don't
88 * provide the necessary methods.
89 *
90 * @param key the property key
91 * @return the actual value of the property, or QVariant() if the
92 * property is unknown
93 */
94 QVariant property(const QString &key) const;
95
96 /**
97 * Retrieves a key/value map of all the known properties for the device.
98 *
99 * Warning: Using this method could expose some backend specific details
100 * and lead to non portable code. Use it at your own risk, or during
101 * transitional phases when the provided device interfaces don't
102 * provide the necessary methods.
103 *
104 * @return all the properties of the device
105 */
106 QMap<QString, QVariant> allProperties() const;
107
108 /**
109 * Tests if a property exist in the device.
110 *
111 * Warning: Using this method could expose some backend specific details
112 * and lead to non portable code. Use it at your own risk, or during
113 * transitional phases when the provided device interfaces don't
114 * provide the necessary methods.
115 *
116 * @param key the property key
117 * @return true if the property is available in the device, false
118 * otherwise
119 */
120 bool propertyExists(const QString &key) const;
121
122Q_SIGNALS:
123 /**
124 * This signal is emitted when a property is changed in the device.
125 *
126 * @param changes the map describing the property changes that
127 * occurred in the device, keys are property name and values
128 * describe the kind of change done on the device property
129 * (added/removed/modified), it's one of the type Solid::Device::PropertyChange
130 */
132
133 /**
134 * This signal is emitted when an event occurred in the device.
135 * For example when a button is pressed.
136 *
137 * @param condition the condition name
138 * @param reason a message explaining why the condition has been raised
139 */
140 void conditionRaised(const QString &condition, const QString &reason);
141};
142}
143
144#endif
Base class of all the device interfaces.
Type
This enum type defines the type of device interface that a Device can have.
This class allows applications to deal with devices available in the underlying system.
Generic interface to deal with a device.
void conditionRaised(const QString &condition, const QString &reason)
This signal is emitted when an event occurred in the device.
static Type deviceInterfaceType()
Get the Solid::DeviceInterface::Type of the GenericInterface device interface.
void propertyChanged(const QMap< QString, int > &changes)
This signal is emitted when a property is changed in the device.
PropertyChange
This enum type defines the type of change that can occur to a GenericInterface property.
The single responsibility of this class is to create arguments valid for logind Inhibit call.
Definition fakebattery.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.