Solid

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

KDE's Doxygen guidelines are available online.