plugins/score-plugin-vst3/Vst3/commands.hpp
1 #pragma once
2 #include <Dataflow/Commands/CableHelpers.hpp>
3 
4 #include <score/command/Command.hpp>
5 
6 #include <pluginterfaces/vst/ivsteditcontroller.h>
7 
8 namespace Process
9 {
10 class Port;
11 class Cable;
12 class Inlet;
13 }
14 namespace vst3
15 {
16 const CommandGroupKey& CommandFactoryName();
17 class Model;
18 class ControlInlet;
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, Steinberg::Vst::ParamID fxNum);
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  Steinberg::Vst::ParamID m_fxNum{};
57  static_assert(sizeof(Steinberg::Vst::ParamID) == sizeof(uint32_t));
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: /Vst3/Control.hpp:15
Definition: plugins/score-plugin-vst3/Vst3/commands.hpp:41
Definition: score-plugin-vst3/Vst3/EffectModel.hpp:41
Definition: plugins/score-plugin-vst3/Vst3/commands.hpp:61
Definition: plugins/score-plugin-vst3/Vst3/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