Loading...
Searching...
No Matches
ProtocolFactoryInterface.hpp
1#pragma once
2#include <Device/Protocol/DeviceSettings.hpp>
3
4#include <score/document/DocumentContext.hpp>
5#include <score/plugins/Interface.hpp>
6#include <score/plugins/UuidKeySerialization.hpp>
8
9#include <QString>
10#include <QVariant>
11
12#include <score_lib_device_export.h>
13
14class QUrl;
15struct VisitorVariant;
16
17namespace Explorer
18{
19class DeviceDocumentPlugin;
20}
21namespace Device
22{
23struct DeviceSettings;
24struct AddressSettings;
25class DeviceInterface;
26class ProtocolSettingsWidget;
27class AddressDialog;
28class SCORE_LIB_DEVICE_EXPORT DeviceEnumerator : public QObject
29{
30 W_OBJECT(DeviceEnumerator)
31public:
32 virtual ~DeviceEnumerator();
33
34 virtual void
35 enumerate(std::function<void(const QString&, const Device::DeviceSettings&)>) const
36 = 0;
37
38 void deviceAdded(const QString& n, const Device::DeviceSettings& s)
39 E_SIGNAL(SCORE_LIB_DEVICE_EXPORT, deviceAdded, n, s)
40 void deviceRemoved(const QString& s)
41 E_SIGNAL(SCORE_LIB_DEVICE_EXPORT, deviceRemoved, s)
42
43 void sort() E_SIGNAL(SCORE_LIB_DEVICE_EXPORT, sort)
44};
45
46using DeviceEnumerators = std::vector<std::pair<QString, Device::DeviceEnumerator*>>;
47
48class SCORE_LIB_DEVICE_EXPORT ProtocolFactory : public score::InterfaceBase
49{
50 SCORE_INTERFACE(ProtocolFactory, "3f69d72e-318d-42dc-b48c-a806036592f1")
51
52public:
53 virtual ~ProtocolFactory();
55 {
56 static const constexpr auto osc = "Network";
57 static const constexpr auto audio = "Audio";
58 static const constexpr auto video = "Video";
59 static const constexpr auto web = "Web";
60 static const constexpr auto hardware = "Hardware";
61 static const constexpr auto software = "Software";
62 static const constexpr auto lights = "Lights";
63 static const constexpr auto util = "Utilities";
64 };
65
66 enum Flags
67 {
68 EditingReloadsEverything = (1 << 0)
69 };
70
71 virtual Flags flags() const noexcept;
72
73 virtual QString prettyName() const noexcept = 0;
74 virtual QString category() const noexcept = 0;
75 virtual QUrl manual() const noexcept;
76
79 virtual int visualPriority() const noexcept;
80
81 virtual DeviceEnumerators getEnumerators(const score::DocumentContext& ctx) const;
82
83 virtual DeviceInterface* makeDevice(
84 const Device::DeviceSettings& settings,
85 const Explorer::DeviceDocumentPlugin& plugin, const score::DocumentContext& ctx)
86 = 0;
87
88 virtual ProtocolSettingsWidget* makeSettingsWidget() = 0;
89
90 virtual AddressDialog* makeAddAddressDialog(
91 const Device::DeviceInterface& dev, const score::DocumentContext& ctx, QWidget*)
92 = 0;
93 virtual AddressDialog* makeEditAddressDialog(
94 const Device::AddressSettings&, const Device::DeviceInterface& dev,
95 const score::DocumentContext& ctx, QWidget*)
96 = 0;
97
98 virtual const Device::DeviceSettings& defaultSettings() const noexcept = 0;
99
100 // Save
101 virtual void serializeProtocolSpecificSettings(
102 const QVariant& data, const VisitorVariant& visitor) const
103 = 0;
104
105 template <typename T>
106 void serializeProtocolSpecificSettings_T(
107 const QVariant& data, const VisitorVariant& visitor) const
108 {
109 score::serialize_dyn(visitor, data.value<T>());
110 }
111
112 // Load
113 virtual QVariant makeProtocolSpecificSettings(const VisitorVariant& visitor) const = 0;
114
115 template <typename T>
116 QVariant makeProtocolSpecificSettings_T(const VisitorVariant& vis) const
117 {
118 return QVariant::fromValue(score::deserialize_dyn<T>(vis));
119 }
120
124 virtual bool checkResourcesAvailable(
125 const Device::DeviceSettings& a, const DeviceResourceMap&) const noexcept;
126
127 // Returns true if the two devicesettings can coexist at the same time.
128 virtual bool checkCompatibility(
129 const Device::DeviceSettings& a, const Device::DeviceSettings& b) const noexcept
130 = 0;
131};
132}
133
134Q_DECLARE_METATYPE(UuidKey<Device::ProtocolFactory>)
135W_REGISTER_ARGTYPE(UuidKey<Device::ProtocolFactory>)
Definition ProtocolSettingsWidget.hpp:41
Definition ProtocolFactoryInterface.hpp:29
Definition DeviceInterface.hpp:66
Definition ProtocolFactoryInterface.hpp:49
Definition ProtocolSettingsWidget.hpp:22
Definition UuidKey.hpp:343
Base class for plug-in interfaces.
Definition Interface.hpp:52
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition AddressSettings.hpp:49
Definition DeviceSettings.hpp:20
Definition ProtocolFactoryInterface.hpp:55
The VisitorVariant struct.
Definition VisitorInterface.hpp:26