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 
86  static Device storageAccessFromPath(const QString &path);
87 
93  explicit Device(const QString &udi = QString());
94 
100  Device(const Device &device);
101 
105  ~Device();
106 
113  Device &operator=(const Device &device);
114 
121  bool isValid() const;
122 
135  QString udi() const;
136 
143  QString parentUdi() const;
144 
151  Device parent() const;
152 
158  QString vendor() const;
159 
165  QString product() const;
166 
173  QString icon() const;
174 
182  QStringList emblems() const;
183 
191  QString displayName() const;
192 
199  QString description() const;
200 
207  bool isDeviceInterface(const DeviceInterface::Type &type) const;
208 
216  DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type);
217 
225  const DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type) const;
226 
233  template <class DevIface> DevIface *as()
234  {
235  DeviceInterface::Type type = DevIface::deviceInterfaceType();
236  DeviceInterface *iface = asDeviceInterface(type);
237  return qobject_cast<DevIface *>(iface);
238  }
239 
246  template <class DevIface> const DevIface *as() const
247  {
248  DeviceInterface::Type type = DevIface::deviceInterfaceType();
249  const DeviceInterface *iface = asDeviceInterface(type);
250  return qobject_cast<const DevIface *>(iface);
251  }
252 
258  template <class DevIface> bool is() const
259  {
260  return isDeviceInterface(DevIface::deviceInterfaceType());
261  }
262 
263 private:
265  friend class DeviceManagerPrivate;
266 };
267 }
268 
269 #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 Mon Oct 26 2020 22:53:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.