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;
64
65 QString displayName() const;
66 bool hasValue() const;
67 std::optional<ossia::value> value() const;
68};
69
70SCORE_LIB_PROCESS_EXPORT QDebug operator<<(QDebug d, const ProcessStateData& mess);
71SCORE_LIB_PROCESS_EXPORT QDebug operator<<(QDebug d, const StateNodeData& mess);
72
74
75SCORE_LIB_PROCESS_EXPORT State::AddressAccessor address(const MessageNode& treeNode);
76SCORE_LIB_PROCESS_EXPORT State::Message message(const MessageNode& node);
77SCORE_LIB_PROCESS_EXPORT State::Message userMessage(const MessageNode& node);
78
79SCORE_LIB_PROCESS_EXPORT Process::MessageNode*
80try_getNodeFromAddress(Process::MessageNode& root, const State::AddressAccessor& addr);
81SCORE_LIB_PROCESS_EXPORT std::vector<Process::MessageNode*>
82try_getNodesFromAddress(Process::MessageNode& root, const State::AddressAccessor& addr);
83SCORE_LIB_PROCESS_EXPORT State::MessageList flatten(const MessageNode&);
84SCORE_LIB_PROCESS_EXPORT State::MessageList getUserMessages(const MessageNode&);
85SCORE_LIB_PROCESS_EXPORT bool hasMatchingAddress(
86 const MessageNode& root, const std::vector<State::AddressAccessor>& addr,
87 State::MessageList& msglist, std::vector<QString>& converted_addresses);
88SCORE_LIB_PROCESS_EXPORT bool hasMatchingText(
89 const MessageNode& root, const QString& text, State::MessageList& msglist,
90 std::vector<QString>& converted_addresses);
91}
92
93#if SCORE_EXTERN_TEMPLATES_IN_SHARED_LIBRARIES
94extern template class SCORE_LIB_PROCESS_EXPORT TreeNode<Process::StateNodeData>;
95#endif
The id_base_t class.
Definition Identifier.hpp:57
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Definition MessageNode.hpp:23
Definition MessageNode.hpp:61
Definition MessageNode.hpp:36
The AddressAccessorHead struct.
Definition Address.hpp:147
Definition Address.hpp:108
The Message struct.
Definition Message.hpp:15