plugins/score-plugin-vst/Vst/commands.hpp
1 #pragma once
2 #include <Dataflow/Commands/CableHelpers.hpp>
3 #include <Media/Commands/MediaCommandFactory.hpp>
4 
5 #include <score/command/Command.hpp>
6 
7 namespace Process
8 {
9 class Port;
10 class Cable;
11 class Inlet;
12 }
13 namespace vst
14 {
15 class Model;
16 class ControlInlet;
17 const CommandGroupKey& CommandFactoryName();
18 
19 class SetControl final : public score::Command
20 {
21  SCORE_COMMAND_DECL(CommandFactoryName(), SetControl, "Set a control")
22 
23 public:
24  SetControl(const ControlInlet& obj, float newval);
25  virtual ~SetControl();
26 
27  void undo(const score::DocumentContext& ctx) const final override;
28  void redo(const score::DocumentContext& ctx) const final override;
29  void update(const ControlInlet& obj, float newval);
30 
31 protected:
32  void serializeImpl(DataStreamInput& stream) const final override;
33  void deserializeImpl(DataStreamOutput& stream) final override;
34 
35 private:
36  Path<ControlInlet> m_path;
37  float m_old, m_new;
38 };
39 
40 class CreateControl final : public score::Command
41 {
42  SCORE_COMMAND_DECL(CommandFactoryName(), CreateControl, "Create a control")
43 
44 public:
45  CreateControl(const Model& obj, int fxNum, float value);
46  virtual ~CreateControl();
47  void undo(const score::DocumentContext& ctx) const final override;
48  void redo(const score::DocumentContext& ctx) const final override;
49 
50 protected:
51  void serializeImpl(DataStreamInput& stream) const final override;
52  void deserializeImpl(DataStreamOutput& stream) final override;
53 
54 private:
55  Path<Model> m_path;
56  int m_fxNum{};
57  float m_val{};
58 };
59 
60 class RemoveControl final : public score::Command
61 {
62  SCORE_COMMAND_DECL(CommandFactoryName(), RemoveControl, "Remove a control")
63 
64 public:
65  RemoveControl(const Model& obj, Id<Process::Port> id);
66  virtual ~RemoveControl();
67  void undo(const score::DocumentContext& ctx) const final override;
68  void redo(const score::DocumentContext& ctx) const final override;
69 
70 protected:
71  void serializeImpl(DataStreamInput& stream) const final override;
72  void deserializeImpl(DataStreamOutput& stream) final override;
73 
74 private:
75  Path<Model> m_path;
76  Id<Process::Port> m_id;
77  QByteArray m_control;
78  Dataflow::SerializedCables m_cables;
79 };
80 }
Definition: QmlObjects.hpp:114
The Path class is a typesafe wrapper around ObjectPath.
Definition: Path.hpp:52
The id_base_t class.
Definition: Identifier.hpp:57
The Command class.
Definition: Command.hpp:34
Definition: Vst/Control.hpp:15
Definition: plugins/score-plugin-vst/Vst/commands.hpp:41
Definition: plugins/score-plugin-vst/Vst/commands.hpp:61
Definition: plugins/score-plugin-vst/Vst/commands.hpp:20
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Definition: DataStreamHelpers.hpp:99
Definition: DataStreamHelpers.hpp:103
Definition: DocumentContext.hpp:18