Loading...
Searching...
No Matches
AddressSettings.hpp
1#pragma once
2#include <State/Domain.hpp>
3#include <State/Message.hpp>
4#include <State/Unit.hpp>
5
6#include <Device/Address/ClipMode.hpp>
7#include <Device/Address/IOType.hpp>
8
9#include <score/tools/Metadata.hpp>
10
11#include <ossia/detail/any_map.hpp>
12//#include <ossia/network/base/node_attributes.hpp>
13#include <ossia/network/common/parameter_properties.hpp>
14
15#include <QString>
16
17#include <score_lib_device_export.h>
18
19namespace Device
20{
21
22using RepetitionFilter = bool;
23struct SCORE_LIB_DEVICE_EXPORT AddressSettingsCommon
24{
25 AddressSettingsCommon() noexcept;
28 AddressSettingsCommon& operator=(const AddressSettingsCommon&) noexcept;
29 AddressSettingsCommon& operator=(AddressSettingsCommon&&) noexcept;
30 ~AddressSettingsCommon() noexcept;
31
32 ossia::value value;
33 State::Domain domain;
34
35 State::Unit unit;
36
37 std::optional<ossia::access_mode> ioType;
38 ossia::bounding_mode clipMode{};
39 ossia::repetition_filter repetitionFilter{};
40
41 ossia::extended_attributes extendedAttributes;
42
43 operator const ossia::extended_attributes&() const { return extendedAttributes; }
44 operator ossia::extended_attributes&() { return extendedAttributes; }
45};
46
47// this one has only the name of the current node (e.g. 'a' for dev:/azazd/a)
48struct SCORE_LIB_DEVICE_EXPORT AddressSettings : public Device::AddressSettingsCommon
49{
50 AddressSettings() noexcept;
51 AddressSettings(const AddressSettings&) noexcept;
53 AddressSettings& operator=(const AddressSettings&) noexcept;
54 AddressSettings& operator=(AddressSettings&&) noexcept;
55 ~AddressSettings() noexcept;
56
57 QString name;
58};
59
60// This one has the whole path of the node in address
61struct SCORE_LIB_DEVICE_EXPORT FullAddressSettings : public Device::AddressSettingsCommon
62{
63 FullAddressSettings() noexcept;
66 FullAddressSettings& operator=(const FullAddressSettings&) noexcept;
67 FullAddressSettings& operator=(FullAddressSettings&&) noexcept;
68 ~FullAddressSettings() noexcept;
69
70 // Maybe we should just use FullAddressSettings behind a flyweight
71 // pattern everywhere... (see mnmlstc/flyweight)
72 struct as_parent;
73 struct as_child;
74 State::Address address;
75
76 template <typename T>
77 SCORE_LIB_DEVICE_EXPORT static FullAddressSettings
78 make(const Device::AddressSettings& other, const State::Address& addr) noexcept;
79 template <typename T>
81 make(const Device::AddressSettings& other, const State::AddressAccessor& addr) noexcept
82 {
83 return make<T>(other, addr.address);
84 }
85
86 static FullAddressSettings make(const State::Message& mess) noexcept;
87
88 // Specializations are in FullAddressSettings.cpp
89};
90
91SCORE_LIB_DEVICE_EXPORT bool operator==(
93 const Device::AddressSettingsCommon& rhs) noexcept;
94
95inline bool operator!=(
97 const Device::AddressSettingsCommon& rhs) noexcept
98{
99 return !(lhs == rhs);
100}
101inline bool operator==(
102 const Device::AddressSettings& lhs, const Device::AddressSettings& rhs) noexcept
103{
104 return static_cast<const Device::AddressSettingsCommon&>(lhs)
105 == static_cast<const Device::AddressSettingsCommon&>(rhs)
106 && lhs.name == rhs.name;
107}
108
109inline bool operator!=(
110 const Device::AddressSettings& lhs, const Device::AddressSettings& rhs) noexcept
111{
112 return !(lhs == rhs);
113}
114inline bool operator==(
116 const Device::FullAddressSettings& rhs) noexcept
117{
118 return static_cast<const Device::AddressSettingsCommon&>(lhs)
119 == static_cast<const Device::AddressSettingsCommon&>(rhs)
120 && lhs.address == rhs.address;
121}
122
123inline bool operator!=(
125 const Device::FullAddressSettings& rhs) noexcept
126{
127 return !(lhs == rhs);
128}
129
130struct SCORE_LIB_DEVICE_EXPORT FullAddressAccessorSettings
131{
138
140 const State::AddressAccessor& addr, const AddressSettingsCommon& f) noexcept;
141
143
145 State::AddressAccessor&& addr, AddressSettingsCommon&& f) noexcept;
146
148 const State::AddressAccessor& addr, const ossia::value& min,
149 const ossia::value& max) noexcept;
150
151 ossia::value value;
152 State::Domain domain;
153
154 std::optional<ossia::access_mode> ioType;
155 ossia::bounding_mode clipMode{};
156 ossia::repetition_filter repetitionFilter{};
157
158 ossia::any_map extendedAttributes;
159
161};
162}
163
164// Important: keep in sync with strings.Address / strings.Device in score::Strings
165// as it is used with a manual switch in DeviceNodeSerialization and with the variant-based
166// switch in DeviceDocumentPluginSerialization (the node.impl() case).
167JSON_METADATA(Device::AddressSettings, "Address")
168
169SCORE_SERIALIZE_DATASTREAM_DECLARE(SCORE_LIB_DEVICE_EXPORT, Device::AddressSettings);
170SCORE_SERIALIZE_DATASTREAM_DECLARE(SCORE_LIB_DEVICE_EXPORT, Device::FullAddressSettings);
171SCORE_SERIALIZE_DATASTREAM_DECLARE(
172 SCORE_LIB_DEVICE_EXPORT, Device::FullAddressAccessorSettings);
173
174Q_DECLARE_METATYPE(Device::AddressSettings)
175Q_DECLARE_METATYPE(Device::FullAddressSettings)
176Q_DECLARE_METATYPE(Device::FullAddressAccessorSettings)
177
178W_REGISTER_ARGTYPE(Device::AddressSettings)
179W_REGISTER_ARGTYPE(Device::FullAddressSettings)
180W_REGISTER_ARGTYPE(Device::FullAddressAccessorSettings)
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
Definition AddressSettings.hpp:24
Definition AddressSettings.hpp:49
Definition AddressSettings.hpp:131
Definition AddressSettings.hpp:62
Definition Address.hpp:108
The Address struct.
Definition Address.hpp:58
Definition Domain.hpp:17
The Message struct.
Definition Message.hpp:15
Definition Unit.hpp:18