1 | // Copyright (C) 2017 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "socketcanbackend.h" |
5 | |
6 | #include <QtSerialBus/qcanbus.h> |
7 | #include <QtSerialBus/qcanbusdevice.h> |
8 | #include <QtSerialBus/qcanbusfactory.h> |
9 | |
10 | #include <QtCore/qloggingcategory.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | Q_LOGGING_CATEGORY(QT_CANBUS_PLUGINS_SOCKETCAN, "qt.canbus.plugins.socketcan") |
15 | |
16 | //! [SocketCanFactory] |
17 | class SocketCanBusPlugin : public QObject, public QCanBusFactory |
18 | { |
19 | Q_OBJECT |
20 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QCanBusFactory"FILE "plugin.json") |
21 | Q_INTERFACES(QCanBusFactory) |
22 | |
23 | public: |
24 | QList<QCanBusDeviceInfo> availableDevices(QString *errorMessage) const override |
25 | { |
26 | Q_UNUSED(errorMessage); |
27 | return SocketCanBackend::interfaces(); |
28 | } |
29 | |
30 | QCanBusDevice *createDevice(const QString &interfaceName, QString *errorMessage) const override |
31 | { |
32 | Q_UNUSED(errorMessage); |
33 | auto device = new SocketCanBackend(interfaceName); |
34 | return device; |
35 | } |
36 | }; |
37 | //! [SocketCanFactory] |
38 | |
39 | QT_END_NAMESPACE |
40 | |
41 | #include "main.moc" |
42 |