Loading...
Searching...
No Matches
MessageItemModelAlgorithms.hpp
1#pragma once
2#include <State/Message.hpp>
3
4#include <Process/State/MessageNode.hpp>
5
6namespace Process
7{
8class ProcessModel;
9}
10#include <score/model/Identifier.hpp>
11
12namespace Scenario
13{
14// An enum that says if a process is before or after the state.
15enum class ProcessPosition
16{
17 Previous,
18 Following
19};
20
21// User messages
22void updateTreeWithMessageList(Process::MessageNode& rootNode, State::MessageList lst);
23void renameAddress(
24 Process::MessageNode& rootNode, const State::AddressAccessor& oldAddr,
25 const State::AddressAccessor& newAddr);
26void findAndReplaceAddresses(
27 Process::MessageNode& rootNode, const State::Address& oldAddr,
28 const State::Address& newAddr);
29
30// Messages from a process
31void updateTreeWithMessageList(
32 Process::MessageNode& rootNode, State::MessageList lst,
33 const Id<Process::ProcessModel>& proc, ProcessPosition pos);
34
35void updateTreeWithRemovedProcess(
37 ProcessPosition pos);
38
39void updateTreeWithRemovedInterval(Process::MessageNode& rootNode, ProcessPosition pos);
40
41void updateTreeWithRemovedUserMessage(
43
44void updateTreeWithRemovedNode(
45 Process::MessageNode& rootNode, const State::AddressAccessor& addr);
46
47void removeAllUserMessages(Process::MessageNode& rootNode);
48
49int countNodes(Process::MessageNode& rootNode);
50Process::MessageNode* getNthChild(Process::MessageNode& rootNode, int n);
51int getChildIndex(Process::MessageNode& rootNode, Process::MessageNode* n);
52}
53
54#include <Scenario/Document/State/ItemModel/MessageItemModel.hpp>
55namespace Scenario
56{
57// User messages
58inline void updateModelWithMessageList(MessageItemModel& model, State::MessageList lst)
59{
60 model.beginResetModel();
61 updateTreeWithMessageList(model.rootNode(), std::move(lst));
62 model.endResetModel();
63}
64
65inline void renameAddress(
66 MessageItemModel& model, const State::AddressAccessor& oldAddr,
67 const State::AddressAccessor& newAddr)
68{
69 model.beginResetModel();
70 renameAddress(model.rootNode(), oldAddr, newAddr);
71 model.endResetModel();
72}
73
74// Messages from a process
75inline void updateModelWithMessageList(
76 MessageItemModel& model, State::MessageList lst,
77 const Id<Process::ProcessModel>& proc, ProcessPosition pos)
78{
79 model.beginResetModel();
80 updateTreeWithMessageList(model.rootNode(), std::move(lst), proc, pos);
81 model.endResetModel();
82}
83
84inline void updateModelWithRemovedProcess(
85 MessageItemModel& model, const Id<Process::ProcessModel>& proc, ProcessPosition pos)
86{
87 model.beginResetModel();
88 updateTreeWithRemovedProcess(model.rootNode(), proc, pos);
89 model.endResetModel();
90}
91
92inline void updateModelWithRemovedInterval(MessageItemModel& model, ProcessPosition pos)
93{
94 model.beginResetModel();
95 updateTreeWithRemovedInterval(model.rootNode(), pos);
96 model.endResetModel();
97}
98
99inline void updateModelWithRemovedUserMessage(
100 MessageItemModel& model, const State::AddressAccessor& addr)
101{
102 model.beginResetModel();
103 updateTreeWithRemovedUserMessage(model.rootNode(), addr);
104 model.endResetModel();
105}
106
107inline void
108updateModelWithRemovedNode(MessageItemModel& model, const State::AddressAccessor& addr)
109{
110 model.beginResetModel();
111 updateTreeWithRemovedNode(model.rootNode(), addr);
112 model.endResetModel();
113}
114
115inline void removeAllUserMessages(MessageItemModel& model)
116{
117 model.beginResetModel();
118 removeAllUserMessages(model.rootNode());
119 model.endResetModel();
120}
121}
The id_base_t class.
Definition Identifier.hpp:57
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1324
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Definition Address.hpp:108
The Address struct.
Definition Address.hpp:58