EditConnection.hpp
1 #pragma once
2 #include <Process/Dataflow/Port.hpp>
3 
4 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
5 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentModel.hpp>
6 
7 #include <score/model/path/Path.hpp>
8 
9 namespace Dataflow
10 {
11 class SCORE_PLUGIN_SCENARIO_EXPORT CreateCable final : public score::Command
12 {
13  SCORE_COMMAND_DECL(
14  Scenario::Command::CommandFactoryName(), CreateCable, "Create cable")
15 
16 public:
19  Process::CableType type, const Process::Port& source, const Process::Port& sink);
20 
21  void undo(const score::DocumentContext& ctx) const override;
22  void redo(const score::DocumentContext& ctx) const override;
23 
24 protected:
25  void serializeImpl(DataStreamInput& s) const override;
26  void deserializeImpl(DataStreamOutput& s) override;
27 
28 private:
30  Id<Process::Cable> m_cable;
31  Process::CableData m_dat;
32  std::optional<bool> m_previousPropagate{};
33 };
34 
35 class SCORE_PLUGIN_SCENARIO_EXPORT UpdateCable final : public score::Command
36 {
37  SCORE_COMMAND_DECL(
38  Scenario::Command::CommandFactoryName(), UpdateCable, "Update cable")
39 
40 public:
41  UpdateCable(const Process::Cable& theCable, Process::CableType newDat);
42 
43  void undo(const score::DocumentContext& ctx) const override;
44  void redo(const score::DocumentContext& ctx) const override;
45 
46 protected:
47  void serializeImpl(DataStreamInput& s) const override;
48  void deserializeImpl(DataStreamOutput& s) override;
49 
50 private:
51  Path<Process::Cable> m_model;
52  Process::CableType m_old{}, m_new{};
53 };
54 
55 class SCORE_PLUGIN_SCENARIO_EXPORT RemoveCable final : public score::Command
56 {
57  SCORE_COMMAND_DECL(
58  Scenario::Command::CommandFactoryName(), RemoveCable, "Remove cable")
59 
60 public:
62 
63  void undo(const score::DocumentContext& ctx) const override;
64  void redo(const score::DocumentContext& ctx) const override;
65 
66 protected:
67  void serializeImpl(DataStreamInput& s) const override;
68  void deserializeImpl(DataStreamOutput& s) override;
69 
70 private:
72  Id<Process::Cable> m_cable;
73  Process::CableData m_data;
74  std::optional<bool> m_previousPropagate{};
75 };
76 }
Definition: EditConnection.hpp:12
Definition: EditConnection.hpp:56
Definition: EditConnection.hpp:36
Definition: Cable.hpp:38
Definition: Port.hpp:102
Definition: ScenarioDocumentModel.hpp:29
The id_base_t class.
Definition: Identifier.hpp:57
The Command class.
Definition: Command.hpp:34
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: CableData.hpp:18
Definition: DocumentContext.hpp:18