AddOnlyProcessToInterval.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 <ossia/detail/json.hpp>
10 
11 #include <QPointF>
12 
13 #include <score_plugin_scenario_export.h>
14 struct DataStreamInput;
15 struct DataStreamOutput;
16 namespace Process
17 {
18 class ProcessModelFactory;
19 class LayerFactory;
20 class ProcessModel;
21 }
22 
23 namespace Scenario
24 {
25 class IntervalModel;
26 namespace Command
27 {
29 class SCORE_PLUGIN_SCENARIO_EXPORT AddOnlyProcessToInterval final : public score::Command
30 {
31  SCORE_COMMAND_DECL(CommandFactoryName(), AddOnlyProcessToInterval, "Add a process")
32 public:
35  const QString& dat, QPointF pos);
37  const IntervalModel& cst, Id<Process::ProcessModel> idToUse,
38  UuidKey<Process::ProcessModel> process, const QString& dat, QPointF pos);
39 
40  void undo(const score::DocumentContext& ctx) const override;
41  void redo(const score::DocumentContext& ctx) const override;
42 
43  void undo(IntervalModel&) const;
45 
46  const Path<IntervalModel>& intervalPath() const { return m_path; }
47 
48  const Id<Process::ProcessModel>& processId() const { return m_createdProcessId; }
49 
50  const UuidKey<Process::ProcessModel>& processKey() const { return m_processName; }
51 
52 protected:
53  void serializeImpl(DataStreamInput& s) const override;
54  void deserializeImpl(DataStreamOutput& s) override;
55 
56 private:
57  Path<IntervalModel> m_path;
58  UuidKey<Process::ProcessModel> m_processName;
59  QString m_data;
60  QPointF m_graphpos;
61 
62  Id<Process::ProcessModel> m_createdProcessId{};
63 };
64 
65 class SCORE_PLUGIN_SCENARIO_EXPORT LoadOnlyLayerInInterval final : public score::Command
66 {
67  SCORE_COMMAND_DECL(CommandFactoryName(), LoadOnlyLayerInInterval, "Load a process")
68 public:
70  const IntervalModel& cst, Id<Process::ProcessModel> idToUse,
71  const rapidjson::Value& obj);
72 
73  void undo(const score::DocumentContext& ctx) const override;
74  void redo(const score::DocumentContext& ctx) const override;
75 
76  void undo(IntervalModel&) const;
78 
79  const Path<IntervalModel>& intervalPath() const { return m_path; }
80 
81  const Id<Process::ProcessModel>& processId() const { return m_createdProcessId; }
82 
83 protected:
84  void serializeImpl(DataStreamInput& s) const override;
85  void deserializeImpl(DataStreamOutput& s) override;
86 
87 private:
88  Path<IntervalModel> m_path;
89  Id<Process::ProcessModel> m_createdProcessId{};
90  rapidjson::Document m_data;
91 };
92 
93 class SCORE_PLUGIN_SCENARIO_EXPORT DuplicateOnlyProcessToInterval final
94  : public score::Command
95 {
96  SCORE_COMMAND_DECL(
97  CommandFactoryName(), DuplicateOnlyProcessToInterval, "Duplicate a process")
98 public:
101  const IntervalModel& cst, Id<Process::ProcessModel> idToUse,
102  const Process::ProcessModel&);
103 
104  void undo(const score::DocumentContext& ctx) const override;
105  void redo(const score::DocumentContext& ctx) const override;
106 
107  void undo(IntervalModel&) const;
109 
110  const Path<IntervalModel>& intervalPath() const { return m_path; }
111 
112  const Id<Process::ProcessModel>& processId() const { return m_createdProcessId; }
113 
114 protected:
115  void serializeImpl(DataStreamInput& s) const override;
116  void deserializeImpl(DataStreamOutput& s) override;
117 
118 private:
119  Path<IntervalModel> m_path;
120  QByteArray m_processData;
121  Id<Process::ProcessModel> m_createdProcessId{};
122 };
123 }
124 }
The Path class is a typesafe wrapper around ObjectPath.
Definition: Path.hpp:52
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Create a new process in a interval.
Definition: AddOnlyProcessToInterval.hpp:30
Definition: AddOnlyProcessToInterval.hpp:95
Definition: AddOnlyProcessToInterval.hpp:66
Definition: IntervalModel.hpp:50
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