CreateInterval.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 #include <score_plugin_scenario_export.h>
12 struct DataStreamInput;
13 struct DataStreamOutput;
14 namespace Process
15 {
16 class Cable;
17 }
18 namespace Scenario
19 {
20 class StateModel;
21 class IntervalModel;
22 class ProcessModel;
23 
24 namespace Command
25 {
32 class SCORE_PLUGIN_SCENARIO_EXPORT CreateInterval final : public score::Command
33 {
34  SCORE_COMMAND_DECL(CommandFactoryName(), CreateInterval, "Create an interval")
35 public:
37  const Scenario::ProcessModel& scenarioPath, Id<StateModel> startState,
38  Id<StateModel> endState, bool graphal = false);
39  CreateInterval& operator=(CreateInterval&&) = default;
40 
41  const Path<Scenario::ProcessModel>& scenarioPath() const { return m_path; }
42 
43  void undo(const score::DocumentContext& ctx) const override;
44  void redo(const score::DocumentContext& ctx) const override;
45 
46  const Id<IntervalModel>& createdInterval() const { return m_createdIntervalId; }
47 
48  const Id<StateModel>& startState() const { return m_startStateId; }
49 
50 protected:
51  void serializeImpl(DataStreamInput&) const override;
52  void deserializeImpl(DataStreamOutput&) override;
53 
54 private:
56  QString m_createdName;
57 
58  Id<IntervalModel> m_createdIntervalId{};
59 
60  Id<StateModel> m_startStateId{};
61  Id<StateModel> m_endStateId{};
62  double m_startStatePos{-1};
63  double m_endStatePos{-1};
64  bool m_graphal{};
65 };
66 }
67 }
The CreateEventAfterEventCommand class.
Definition: CreateInterval.hpp:33
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
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
Definition: DocumentContext.hpp:18