2 #include <State/Address.hpp>
3 #include <State/Message.hpp>
5 #include <Device/Address/AddressSettings.hpp>
6 #include <Device/Protocol/DeviceSettings.hpp>
8 #include <score/config.hpp>
9 #include <score/model/tree/TreeNode.hpp>
10 #include <score/model/tree/TreePath.hpp>
11 #include <score/model/tree/VariantBasedNode.hpp>
14 #include <QStringList>
16 #include <score_lib_device_export.h>
23 struct AddressSettings;
24 struct DeviceSettings;
29 SCORE_SERIALIZE_FRIENDS
50 : VariantBasedNode{std::move(t)}
56 return static_cast<const VariantBasedNode&
>(*this)
57 ==
static_cast<const VariantBasedNode&
>(other);
61 const QString& displayName()
const;
63 bool isSelectable()
const;
64 bool isEditable()
const;
78 using FreeNode = std::pair<State::Address, Device::Node>;
79 using NodeList = std::vector<Device::Node*>;
80 using FreeNodeList = std::vector<FreeNode>;
84 SCORE_LIB_DEVICE_EXPORT QString deviceName(
const Node& treeNode);
95 SCORE_LIB_DEVICE_EXPORT
void
101 SCORE_LIB_DEVICE_EXPORT
Device::Node* getNodeFromString(
103 const QStringList& str);
112 merge(
Device::Node base,
const State::MessageList& other);
116 inline auto findChildNode_it(
const Device::Node& node,
const QString& name)
118 return std::find_if(node.begin(), node.end(), [&](
const Device::Node& n) {
119 return n.get<Device::AddressSettings>().name == name;
126 auto it = findChildNode_it(node, name);
133 template <
typename Node_T,
typename It>
134 Node_T* try_getNodeFromString_impl(Node_T& n, It begin, It end)
141 if(child.displayName() == *begin)
143 return try_getNodeFromString_impl(child, ++begin, end);
150 template <
typename Node_T>
151 Node_T* try_getNodeFromString(Node_T& n,
const QStringList& parts)
153 return try_getNodeFromString_impl(n, parts.cbegin(), parts.cend());
156 template <
typename Node_T>
157 Node_T* try_getNodeFromAddress(Node_T& root,
const State::Address& addr)
159 if(addr.device.isEmpty())
162 auto dev = std::find_if(root.begin(), root.end(), [&](
const Node_T& n) {
163 return n.template is<Device::DeviceSettings>()
164 && n.template get<Device::DeviceSettings>().name == addr.device;
167 if(dev == root.end())
170 return try_getNodeFromString(*dev, addr.path);
176 #if SCORE_EXTERN_TEMPLATES_IN_SHARED_LIBRARIES
Definition: VisitorInterface.hpp:53
Definition: DeviceNode.hpp:28
Definition: VisitorInterface.hpp:61
Path in a tree of QAbstractItemModel objects.
Definition: TreePath.hpp:34
The VariantBasedNode class.
Definition: VariantBasedNode.hpp:23
Manipulation of Devices from Qt.
Definition: AddressSettings.cpp:14
void dumpTree(const Node &node, QString rec)
dumpTree An utility to print trees of Device::Nodes
Definition: DeviceNode.cpp:246
void parametersList(const Node &n, State::MessageList &ml)
parametersList Recursive list of parameters in this node
Definition: DeviceNode.cpp:119
Definition: Address.hpp:108
The Address struct.
Definition: Address.hpp:58
The Message struct.
Definition: Message.hpp:15