Solid
device.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SOLID_DEVICE_H
00021 #define SOLID_DEVICE_H
00022
00023 #include <QtCore/QVariant>
00024
00025 #include <QtCore/QMap>
00026 #include <QtCore/QList>
00027 #include <QtCore/QSharedData>
00028
00029 #include <solid/solid_export.h>
00030
00031 #include <solid/deviceinterface.h>
00032
00033 namespace Solid
00034 {
00035 class DevicePrivate;
00036
00047 class SOLID_EXPORT Device
00048 {
00049 public:
00055 static QList<Device> allDevices();
00056
00068 static QList<Device> listFromType(const DeviceInterface::Type &type,
00069 const QString &parentUdi = QString());
00070
00081 static QList<Device> listFromQuery(const Predicate &predicate,
00082 const QString &parentUdi = QString());
00083
00091 static QList<Device> listFromQuery(const QString &predicate,
00092 const QString &parentUdi = QString());
00093
00094
00100 explicit Device(const QString &udi = QString());
00101
00107 Device(const Device &device);
00108
00112 ~Device();
00113
00114
00115
00122 Device &operator=(const Device &device);
00123
00130 bool isValid() const;
00131
00132
00145 QString udi() const;
00146
00153 QString parentUdi() const;
00154
00155
00162 Device parent() const;
00163
00164
00165
00171 QString vendor() const;
00172
00178 QString product() const;
00179
00186 QString icon() const;
00187
00188
00195 bool isDeviceInterface(const DeviceInterface::Type &type) const;
00196
00204 DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type);
00205
00213 const DeviceInterface *asDeviceInterface(const DeviceInterface::Type &type) const;
00214
00221 template <class DevIface> DevIface *as()
00222 {
00223 DeviceInterface::Type type = DevIface::deviceInterfaceType();
00224 DeviceInterface *iface = asDeviceInterface(type);
00225 return qobject_cast<DevIface *>(iface);
00226 }
00227
00234 template <class DevIface> const DevIface *as() const
00235 {
00236 DeviceInterface::Type type = DevIface::deviceInterfaceType();
00237 const DeviceInterface *iface = asDeviceInterface(type);
00238 return qobject_cast<const DevIface *>(iface);
00239 }
00240
00246 template <class DevIface> bool is() const
00247 {
00248 return isDeviceInterface(DevIface::deviceInterfaceType());
00249 }
00250
00251 private:
00252 QExplicitlySharedDataPointer<DevicePrivate> d;
00253 friend class DeviceManagerPrivate;
00254 };
00255 }
00256
00257 #endif