Loading...
Searching...
No Matches
MessageNode.hpp
1#pragma once
2#include <State/Address.hpp>
3#include <State/Message.hpp>
4#include <State/Value.hpp>
5
6#include <score/config.hpp>
7#include <score/model/Identifier.hpp>
8#include <score/model/tree/TreeNode.hpp>
9#include <score/tools/std/Optional.hpp>
10
11#include <QString>
12#include <QVector>
13
14#include <score_lib_process_export.h>
15
16#include <array>
17
18namespace Process
19{
20class ProcessModel;
21
23{
25 std::optional<ossia::value> value;
26};
27
28enum class PriorityPolicy
29{
30 User,
31 Previous,
32 Following
33};
34
35struct SCORE_LIB_PROCESS_EXPORT StateNodeValues
36{
37 bool empty() const;
38
39 // TODO use lists or queues instead to manage the priorities
40 std::vector<ProcessStateData> previousProcessValues;
41 std::vector<ProcessStateData> followingProcessValues;
42 std::optional<ossia::value> userValue;
43
44 std::array<PriorityPolicy, 3> priorities{
45 {PriorityPolicy::Previous, PriorityPolicy::Following, PriorityPolicy::User}};
46
47 bool hasValue() const;
48
49 static bool hasValue(const std::vector<ProcessStateData>& vec);
50 static std::vector<ProcessStateData>::const_iterator
51 value(const std::vector<ProcessStateData>& vec);
52
53 // TODO here we have to choose a policy
54 // if we have both previous and following processes ?
55 std::optional<ossia::value> value() const;
56
57 QString displayValue() const;
58};
59
60struct SCORE_LIB_PROCESS_EXPORT StateNodeData
61{
63 StateNodeValues values;
65 std::shared_ptr<const State::Anchor> anchor;
66
67 QString displayName() const;
68 bool hasValue() const;
69 std::optional<ossia::value> value() const;
70};
71
72SCORE_LIB_PROCESS_EXPORT QDebug operator<<(QDebug d, const ProcessStateData& mess);
73SCORE_LIB_PROCESS_EXPORT QDebug operator<<(QDebug d, const StateNodeData& mess);
74
76
77SCORE_LIB_PROCESS_EXPORT State::AddressAccessor address(const MessageNode& treeNode);
78SCORE_LIB_PROCESS_EXPORT State::Message message(const MessageNode& node);
79SCORE_LIB_PROCESS_EXPORT State::Message userMessage(const MessageNode& node);
80
81SCORE_LIB_PROCESS_EXPORT Process::MessageNode*
82try_getNodeFromAddress(Process::MessageNode& root, const State::AddressAccessor& addr);
83SCORE_LIB_PROCESS_EXPORT std::vector<Process::MessageNode*>
84try_getNodesFromAddress(Process::MessageNode& root, const State::AddressAccessor& addr);
85SCORE_LIB_PROCESS_EXPORT State::MessageList flatten(const MessageNode&);
86SCORE_LIB_PROCESS_EXPORT State::MessageList getUserMessages(const MessageNode&);
87SCORE_LIB_PROCESS_EXPORT bool hasMatchingAddress(
88 const MessageNode& root, const std::vector<State::AddressAccessor>& addr,
89 State::MessageList& msglist, std::vector<QString>& converted_addresses);
90SCORE_LIB_PROCESS_EXPORT bool hasMatchingText(
91 const MessageNode& root, const QString& text, State::MessageList& msglist,
92 std::vector<QString>& converted_addresses);
93}
94
95#if SCORE_EXTERN_TEMPLATES_IN_SHARED_LIBRARIES
96extern template class SCORE_LIB_PROCESS_EXPORT TreeNode<Process::StateNodeData>;
97#endif
The id_base_t class.
Definition Identifier.hpp:59
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Definition MessageNode.hpp:23
Definition MessageNode.hpp:61
std::shared_ptr< const State::Anchor > anchor
Set on leaves that target an object of this document.
Definition MessageNode.hpp:65
Definition MessageNode.hpp:36
The AddressAccessorHead struct.
Definition Address.hpp:175
Definition Address.hpp:136
The Message struct.
Definition Message.hpp:15