Solid

frontend/device.h
1 /*
2  SPDX-FileCopyrightText: 2005-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_DEVICE_H
8 #define SOLID_DEVICE_H
9 
10 
11 #include <QList>
12 #include <QSharedData>
13 
14 #include <solid/solid_export.h>
15 
16 #include <solid/deviceinterface.h>
17 
18 namespace Solid
19 {
20 class DevicePrivate;
21 
32 class SOLID_EXPORT Device
33 {
34 public:
40  static QList<Device> allDevices();
41 
53  static QList<Device> listFromType(const DeviceInterface::Type &type,
54  const QString &parentUdi = QString());
55 
66  static QList<Device> listFromQuery(const Predicate &predicate,
67  const QString &parentUdi = QString());
68 
76  static QList<Device> listFromQuery(const QString &predicate,
77  const QString &parentUdi = QString());
78 
84  explicit Device(const QString &udi = QString());
85 
91  Device(const Device &device);
92 
96  ~Device();
97 
104  Device &operator=(const Device &device);
105 
112  bool isValid() const;
113 
126  QString udi() const;
127 
134  QString parentUdi() const;
135 
142  Device parent() const;
143 
149  QString vendor() const;
150 
156  QString product() const;
157 
164  QString icon() const;
165 
173  QStringList emblems() const;
174 
182  QString displayName() const;
183 
190  QString description() const;
191 
198  bool isDeviceInterface(const DeviceInterface::Type &type) const;
199 
207  DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type);
208 
216  const DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type) const;
217 
224  template <class DevIface> DevIface *as()
225  {
226  DeviceInterface::Type type = DevIface::deviceInterfaceType();
227  DeviceInterface *iface = asDeviceInterface(type);
228  return qobject_cast<DevIface *>(iface);
229  }
230 
237  template <class DevIface> const DevIface *as() const
238  {
239  DeviceInterface::Type type = DevIface::deviceInterfaceType();
240  const DeviceInterface *iface = asDeviceInterface(type);
241  return qobject_cast<const DevIface *>(iface);
242  }
243 
249  template <class DevIface> bool is() const
250  {
251  return isDeviceInterface(DevIface::deviceInterfaceType());
252  }
253 
254 private:
256  friend class DeviceManagerPrivate;
257 };
258 }
259 
260 #endif
DevIface * as()
Retrieves a specialized interface to interact with the device corresponding to a given device interfa...
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.
const DevIface * as() const
Retrieves a specialized interface to interact with the device corresponding to a given device interfa...
bool is() const
Tests if a device provides a given device interface.
This class implements predicates for devices.
Definition: predicate.h:31
The single responsibility of this class is to create arguments valid for logind Inhibit call...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 3 2020 22:48:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.