Solid

devicemanager.h
1/*
2 SPDX-FileCopyrightText: 2005 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_DEVICEMANAGER_H
8#define SOLID_IFACES_DEVICEMANAGER_H
9
10#include <QObject>
11
12#include <QStringList>
13
14#include <solid/deviceinterface.h>
15
16namespace Solid
17{
18namespace Ifaces
19{
20/**
21 * This class specifies the interface a backend will have to implement in
22 * order to be used in the system.
23 *
24 * A device manager allows to query the underlying platform to discover the
25 * available devices. It has also the responsibility to notify when a device
26 * appears or disappears.
27 */
28class DeviceManager : public QObject
29{
31
32public:
33 /**
34 * Constructs a DeviceManager
35 */
36 DeviceManager(QObject *parent = nullptr);
37 /**
38 * Destructs a DeviceManager object
39 */
40 ~DeviceManager() override;
41
42 /**
43 * Retrieves the prefix used for the UDIs off all the devices
44 * reported by the device manager
45 */
46 virtual QString udiPrefix() const = 0;
47
48 /**
49 * Retrieves a set of interfaces the backend supports
50 */
52
53 /**
54 * Retrieves the Universal Device Identifier (UDI) of all the devices
55 * available in the system. This identifier is unique for each device
56 * in the system.
57 *
58 * @returns the UDIs of all the devices in the system
59 */
60 virtual QStringList allDevices() = 0;
61
62 /**
63 * Retrieves the Universal Device Identifier (UDI) of all the devices
64 * matching the given constraints (parent and device interface)
65 *
66 * @param parentUdi UDI of the parent of the devices we're searching for, or QString()
67 * if there's no constraint on the parent
68 * @param type DeviceInterface type available on the devices we're looking for, or DeviceInterface::Unknown
69 * if there's no constraint on the device interfaces
70 * @returns the UDIs of all the devices having the given parent and device interface
71 */
72 virtual QStringList devicesFromQuery(const QString &parentUdi, Solid::DeviceInterface::Type type = Solid::DeviceInterface::Unknown) = 0;
73
74 /**
75 * Instantiates a new Device object from this backend given its UDI.
76 *
77 * @param udi the identifier of the device instantiated
78 * @returns a new Device object if there's a device having the given UDI, 0 otherwise
79 */
80 virtual QObject *createDevice(const QString &udi) = 0;
81
83 /**
84 * This signal is emitted when a new device appears in the system.
85 *
86 * @param udi the new device identifier
87 */
88 void deviceAdded(const QString &udi);
89
90 /**
91 * This signal is emitted when a device disappears from the system.
92 *
93 * @param udi the old device identifier
94 */
95 void deviceRemoved(const QString &udi);
96};
97}
98}
99
100#endif
Type
This enum type defines the type of device interface that a Device can have.
This class specifies the interface a backend will have to implement in order to be used in the system...
virtual QString udiPrefix() const =0
Retrieves the prefix used for the UDIs off all the devices reported by the device manager.
virtual QStringList allDevices()=0
Retrieves the Universal Device Identifier (UDI) of all the devices available in the system.
void deviceAdded(const QString &udi)
This signal is emitted when a new device appears in the system.
void deviceRemoved(const QString &udi)
This signal is emitted when a device disappears from the system.
~DeviceManager() override
Destructs a DeviceManager object.
virtual QSet< Solid::DeviceInterface::Type > supportedInterfaces() const =0
Retrieves a set of interfaces the backend supports.
virtual QStringList devicesFromQuery(const QString &parentUdi, Solid::DeviceInterface::Type type=Solid::DeviceInterface::Unknown)=0
Retrieves the Universal Device Identifier (UDI) of all the devices matching the given constraints (pa...
virtual QObject * createDevice(const QString &udi)=0
Instantiates a new Device object from this backend given its UDI.
DeviceManager(QObject *parent=nullptr)
Constructs a DeviceManager.
The single responsibility of this class is to create arguments valid for logind Inhibit call.
Definition fakebattery.h:16
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:56:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.