AddMessagesToState.hpp
1 #pragma once
2 #include <State/Message.hpp>
3 
4 #include <Process/ControlMessage.hpp>
5 #include <Process/State/MessageNode.hpp>
6 
7 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
8 
9 #include <score/command/Command.hpp>
10 #include <score/model/Identifier.hpp>
11 #include <score/model/path/Path.hpp>
12 
13 #include <ossia/detail/flat_map.hpp>
14 
15 #include <score_plugin_scenario_export.h>
16 namespace Process
17 {
18 class ProcessModel;
19 struct ControlMessage;
20 }
21 
22 namespace Scenario
23 {
24 class StateModel;
25 namespace Command
26 {
27 class SCORE_PLUGIN_SCENARIO_EXPORT ReplaceStateBase : public score::Command
28 {
29 public:
30  void undo(const score::DocumentContext& ctx) const override;
31  void redo(const score::DocumentContext& ctx) const override;
32 
33  void serializeImpl(DataStreamInput&) const override;
34  void deserializeImpl(DataStreamOutput&) override;
35 
36 protected:
37  void updateProcessMessages(
38  const Scenario::StateModel& state, const State::MessageList& messages);
39  Path<StateModel> m_path;
40 
41  Process::MessageNode m_oldState, m_newState;
42 
43  ossia::flat_map<Id<Process::ProcessModel>, State::MessageList> m_previousBackup;
44  ossia::flat_map<Id<Process::ProcessModel>, State::MessageList> m_followingBackup;
45 };
46 
47 class SCORE_PLUGIN_SCENARIO_EXPORT ReplaceState : public ReplaceStateBase
48 {
49  SCORE_COMMAND_DECL(CommandFactoryName(), ReplaceState, "Replace state")
50 public:
52  const Scenario::StateModel& state, const Process::MessageNode& oldnode,
53  const Process::MessageNode& newnode, const State::MessageList& messages);
54  ReplaceState(const Scenario::StateModel& state, const State::MessageList& messages);
55 };
56 
57 class SCORE_PLUGIN_SCENARIO_EXPORT AddMessagesToState final : public ReplaceState
58 {
59  SCORE_COMMAND_DECL(CommandFactoryName(), AddMessagesToState, "Add messages to state")
60 public:
62  const Scenario::StateModel& state, const State::MessageList& messages);
63 };
64 
66 {
67  SCORE_COMMAND_DECL(
68  CommandFactoryName(), RenameAddressInState, "Rename address in a state")
69 
70 public:
72  const Scenario::StateModel& state, const State::AddressAccessor& old,
73  const State::AddressAccessorHead& name);
75  const Scenario::StateModel& state, const State::AddressAccessor& old,
76  const State::AddressAccessor& replacement);
77 
78  void undo(const score::DocumentContext& ctx) const override;
79  void redo(const score::DocumentContext& ctx) const override;
80 
81 private:
82  void serializeImpl(DataStreamInput& s) const override;
83  void deserializeImpl(DataStreamOutput& s) override;
84 
85  Path<StateModel> m_state;
86  State::AddressAccessor m_oldName, m_newName;
87 };
88 
90 {
91  SCORE_COMMAND_DECL(
92  CommandFactoryName(), RenameAddressesInState, "Rename address in a state")
93 
94 public:
96  const Scenario::StateModel& state, const State::Address& find,
97  const State::Address& replace);
98 };
99 
100 class SCORE_PLUGIN_SCENARIO_EXPORT AddControlMessagesToState final
101  : public score::Command
102 {
103  SCORE_COMMAND_DECL(
104  CommandFactoryName(), AddControlMessagesToState, "Add control messages to state")
105 public:
107  const Scenario::StateModel& state,
108  std::vector<Process::ControlMessage>&& messages);
109 
110  void undo(const score::DocumentContext& ctx) const override;
111  void redo(const score::DocumentContext& ctx) const override;
112 
113 private:
114  void serializeImpl(DataStreamInput&) const override;
115  void deserializeImpl(DataStreamOutput&) override;
116  Path<StateModel> m_path;
117 
118  std::vector<Process::ControlMessage> m_old, m_new;
119 };
120 }
121 }
The Path class is a typesafe wrapper around ObjectPath.
Definition: Path.hpp:52
Definition: AddMessagesToState.hpp:102
Definition: AddMessagesToState.hpp:58
Definition: AddMessagesToState.hpp:66
Definition: AddMessagesToState.hpp:90
Definition: AddMessagesToState.hpp:28
Definition: AddMessagesToState.hpp:48
Definition: StateModel.hpp:63
The Command class.
Definition: Command.hpp:34
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:14
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
The AddressAccessorHead struct.
Definition: Address.hpp:147
Definition: Address.hpp:108
The Address struct.
Definition: Address.hpp:58
Definition: DocumentContext.hpp:18