CreateState.hpp
1 #pragma once
2 #include <Scenario/Commands/ScenarioCommandFactory.hpp>
3 
4 #include <score/command/Command.hpp>
5 #include <score/model/Identifier.hpp>
6 #include <score/model/path/Path.hpp>
7 #include <score/tools/std/Optional.hpp>
8 
9 #include <QString>
10 
11 struct DataStreamInput;
12 struct DataStreamOutput;
13 
14 namespace Scenario
15 {
16 class ProcessModel;
17 class EventModel;
18 class StateModel;
19 namespace Command
20 {
21 class SCORE_PLUGIN_SCENARIO_EXPORT CreateState final : public score::Command
22 {
23  SCORE_COMMAND_DECL(CommandFactoryName(), CreateState, "Create a state")
24 public:
26  const Scenario::ProcessModel& scenario, Id<EventModel> event, double stateY);
28  const Scenario::ProcessModel& scenario, Id<StateModel> newId, Id<EventModel> event,
29  double stateY);
30 
31  const Path<Scenario::ProcessModel>& scenarioPath() const { return m_path; }
32 
33  const double& endStateY() const { return m_stateY; }
34 
35  const Id<StateModel>& createdState() const { return m_newState; }
36 
37  void undo(const score::DocumentContext& ctx) const override;
38  void redo(const score::DocumentContext& ctx) const override;
39 
40 protected:
41  void serializeImpl(DataStreamInput&) const override;
42  void deserializeImpl(DataStreamOutput&) override;
43 
44 private:
46  QString m_createdName;
47  Id<StateModel> m_newState;
48  Id<EventModel> m_event;
49  double m_stateY{};
50 };
51 }
52 }
Definition: CreateState.hpp:22
The core hierarchical and temporal process of score.
Definition: ScenarioModel.hpp:37
The id_base_t class.
Definition: Identifier.hpp:57
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