Solid

ifaces/genericinterface.h
1/*
2 SPDX-FileCopyrightText: 2006 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_IFACES_GENERICINTERFACE_H
8#define SOLID_IFACES_GENERICINTERFACE_H
9
10#include <QObject>
11
12#include <QMap>
13#include <QVariant>
14
15namespace Solid
16{
17namespace Ifaces
18{
19/**
20 * Generic interface to deal with a device. It exposes a set of properties
21 * and is organized a a key/value set.
22 *
23 * Warning: Using this class could expose some backend specific details
24 * and lead to non portable code. Use it at your own risk, or during
25 * transitional phases when the provided device interfaces don't
26 * provide the necessary methods.
27 */
29{
30public:
31 /**
32 * Destroys a GenericInterface object.
33 */
34 virtual ~GenericInterface();
35
36 /**
37 * Retrieves the value of a property.
38 *
39 * @param key the property name
40 * @returns the property value or QVariant() if the property doesn't exist
41 */
42 virtual QVariant property(const QString &key) const = 0;
43
44 /**
45 * Retrieves all the properties of this device.
46 *
47 * @returns all properties in a map
48 */
50
51 /**
52 * Tests if a property exist.
53 *
54 * @param key the property name
55 * @returns true if the property exists in this device, false otherwise
56 */
57 virtual bool propertyExists(const QString &key) const = 0;
58
59protected:
60 // Q_SIGNALS:
61 /**
62 * This signal is emitted when a property is changed in the device.
63 *
64 * @param changes the map describing the property changes that
65 * occurred in the device, keys are property name and values
66 * describe the kind of change done on the device property
67 * (added/removed/modified), it's one of the type Solid::Device::PropertyChange
68 */
69 virtual void propertyChanged(const QMap<QString, int> &changes) = 0;
70
71 /**
72 * This signal is emitted when an event occurred in the device.
73 * For example when a button is pressed.
74 *
75 * @param condition the condition name
76 * @param reason a message explaining why the condition has been raised
77 */
78 virtual void conditionRaised(const QString &condition, const QString &reason) = 0;
79};
80}
81}
82
83Q_DECLARE_INTERFACE(Solid::Ifaces::GenericInterface, "org.kde.Solid.Ifaces.GenericInterface/0.1")
84
85#endif
Generic interface to deal with a device.
virtual QVariant property(const QString &key) const =0
Retrieves the value of a property.
virtual void propertyChanged(const QMap< QString, int > &changes)=0
This signal is emitted when a property is changed in the device.
virtual void conditionRaised(const QString &condition, const QString &reason)=0
This signal is emitted when an event occurred in the device.
virtual QMap< QString, QVariant > allProperties() const =0
Retrieves all the properties of this device.
virtual bool propertyExists(const QString &key) const =0
Tests if a property exist.
virtual ~GenericInterface()
Destroys a GenericInterface object.
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.