SplitEvent.hpp
1 #pragma once
2 
3 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
4 
5 #include <score/command/AggregateCommand.hpp>
6 #include <score/command/Command.hpp>
7 #include <score/model/Identifier.hpp>
8 #include <score/model/path/Path.hpp>
9 #include <score/tools/std/Optional.hpp>
10 
11 #include <QString>
12 #include <QVector>
13 
14 struct DataStreamInput;
15 struct DataStreamOutput;
16 
17 namespace Scenario
18 {
19 class ProcessModel;
20 class EventModel;
21 class StateModel;
22 
23 namespace Command
24 {
25 class SplitEvent final : public score::Command
26 {
27  SCORE_COMMAND_DECL(CommandFactoryName(), SplitEvent, "Split an event")
28 
29 public:
30  SplitEvent(
31  const Scenario::ProcessModel& scenario, Id<EventModel> event,
32  std::vector<Id<StateModel>> movingstates);
33  SplitEvent(
34  const Scenario::ProcessModel& scenario, Id<EventModel> event,
35  Id<EventModel> new_event, std::vector<Id<StateModel>> movingstates);
36 
37  void undo(const score::DocumentContext& ctx) const override;
38  void redo(const score::DocumentContext& ctx) const override;
39 
40  const Id<EventModel>& newEvent() const { return m_newEvent; }
41 
42 protected:
43  void serializeImpl(DataStreamInput&) const override;
44  void deserializeImpl(DataStreamOutput&) override;
45 
46 private:
47  Path<Scenario::ProcessModel> m_scenarioPath;
48 
49  Id<EventModel> m_originalEvent;
50  Id<EventModel> m_newEvent;
51  QString m_createdName;
52  std::vector<Id<StateModel>> m_movingStates;
53 };
54 
55 class SCORE_PLUGIN_SCENARIO_EXPORT SplitWholeEvent final : public score::Command
56 {
57  SCORE_COMMAND_DECL(CommandFactoryName(), SplitWholeEvent, "Split an event")
58 public:
59  SplitWholeEvent(const EventModel& path);
60  void undo(const score::DocumentContext& ctx) const override;
61  void redo(const score::DocumentContext& ctx) const override;
62 
63 protected:
64  void serializeImpl(DataStreamInput&) const override;
65  void deserializeImpl(DataStreamOutput&) override;
66 
67 private:
68  Path<EventModel> m_path;
69 
70  Id<EventModel> m_originalEvent;
71  std::vector<Id<EventModel>> m_newEvents;
72 };
73 
75 {
76  SCORE_COMMAND_DECL(CommandFactoryName(), SplitStateMacro, "Split state from node")
77 };
78 }
79 }
Definition: SplitEvent.hpp:26
Definition: SplitEvent.hpp:75
Definition: SplitEvent.hpp:56
Definition: EventModel.hpp:36
The core hierarchical and temporal process of score.
Definition: ScenarioModel.hpp:37
The id_base_t class.
Definition: Identifier.hpp:57
Allows for grouping of multiple commands in a single one.
Definition: AggregateCommand.hpp:15
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