SwapSlots.hpp
1 #pragma once
2 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
3 #include <Scenario/Document/Interval/Slot.hpp>
4 
5 #include <score/command/Command.hpp>
6 #include <score/model/Identifier.hpp>
7 #include <score/model/path/Path.hpp>
8 #include <score/tools/std/Optional.hpp>
9 
10 struct DataStreamInput;
11 struct DataStreamOutput;
12 
13 namespace Scenario
14 {
15 class IntervalModel;
16 namespace Command
17 {
18 class ChangeSlotPosition final : public score::Command
19 {
20  SCORE_COMMAND_DECL(CommandFactoryName(), ChangeSlotPosition, "Change slot position")
21 public:
22  ChangeSlotPosition(Path<IntervalModel>&& rack, Slot::RackView, int pos1, int pos2);
23 
24  void undo(const score::DocumentContext& ctx) const override;
25  void redo(const score::DocumentContext& ctx) const override;
26 
27 protected:
28  void serializeImpl(DataStreamInput&) const override;
29  void deserializeImpl(DataStreamOutput&) override;
30 
31 private:
32  Path<IntervalModel> m_path;
33  Slot::RackView m_view{};
34  int m_first{}, m_second{};
35 };
36 
38 {
39 public:
40  SlotCommand() = default;
41  SlotCommand(const IntervalModel& c);
42  void undo(const score::DocumentContext& ctx) const override;
43  void redo(const score::DocumentContext& ctx) const override;
44 
45 protected:
46  void serializeImpl(DataStreamInput&) const override;
47  void deserializeImpl(DataStreamOutput&) override;
48 
49  Path<IntervalModel> m_path;
50  Scenario::Rack m_old{};
51  Scenario::Rack m_new{};
52 };
53 
54 class MoveLayerInNewSlot final : public SlotCommand
55 {
56  SCORE_COMMAND_DECL(CommandFactoryName(), MoveLayerInNewSlot, "Move layer in new slot")
57 public:
58  MoveLayerInNewSlot(const IntervalModel&, int pos1, int pos2);
59 };
60 
61 class MergeSlots final : public SlotCommand
62 {
63  SCORE_COMMAND_DECL(CommandFactoryName(), MergeSlots, "Merge slots")
64 
65 public:
66  MergeSlots(const IntervalModel&, int pos1, int pos2);
67 };
68 
69 class MergeLayerInSlot final : public SlotCommand
70 {
71  SCORE_COMMAND_DECL(CommandFactoryName(), MergeLayerInSlot, "Merge layer")
72 
73 public:
74  MergeLayerInSlot(const IntervalModel&, int pos1, int pos2);
75 };
76 }
77 }
The Path class is a typesafe wrapper around ObjectPath.
Definition: Path.hpp:52
Definition: SwapSlots.hpp:19
Definition: SwapSlots.hpp:70
Definition: SwapSlots.hpp:62
Definition: SwapSlots.hpp:55
Definition: SwapSlots.hpp:38
Definition: IntervalModel.hpp:50
The Command class.
Definition: Command.hpp:34
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: DocumentContext.hpp:18