1 | // Copyright (C) 2018 Andre Hartmann <aha_1980@gmx.de> |
---|---|
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 "virtualcanbackend.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_VIRTUALCAN, "qt.canbus.plugins.virtualcan") |
15 | |
16 | class VirtualCanBusPlugin : public QObject, public QCanBusFactory |
17 | { |
18 | Q_OBJECT |
19 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QCanBusFactory"FILE "plugin.json") |
20 | Q_INTERFACES(QCanBusFactory) |
21 | |
22 | public: |
23 | QList<QCanBusDeviceInfo> availableDevices(QString *errorMessage) const override |
24 | { |
25 | if (errorMessage != nullptr) |
26 | errorMessage->clear(); |
27 | |
28 | return VirtualCanBackend::interfaces(); |
29 | } |
30 | |
31 | QCanBusDevice *createDevice(const QString &interfaceName, QString *errorMessage) const override |
32 | { |
33 | if (errorMessage) |
34 | errorMessage->clear(); |
35 | |
36 | auto device = new VirtualCanBackend(interfaceName); |
37 | return device; |
38 | } |
39 | }; |
40 | |
41 | QT_END_NAMESPACE |
42 | |
43 | #include "main.moc" |
44 |