plugins/score-plugin-engine/Execution/DocumentPlugin.hpp
1 #pragma once
2 #include "BaseScenarioComponent.hpp"
3 
4 #include <Process/Dataflow/Port.hpp>
5 #include <Process/ExecutionAction.hpp>
6 #include <Process/ExecutionContext.hpp>
7 #include <Process/ExecutionSetup.hpp>
8 
9 #include <score/plugins/documentdelegate/plugin/DocumentPlugin.hpp>
10 #include <score/tools/Metadata.hpp>
11 
12 #include <ossia/dataflow/bench_map.hpp>
13 #include <ossia/dataflow/dataflow_fwd.hpp>
14 #include <ossia/network/generic/generic_device.hpp>
15 #include <ossia/network/local/local.hpp>
16 
17 #include <memory>
18 #include <verdigris>
19 
20 inline QDataStream& operator<<(QDataStream& i, const ossia::bench_map& sel)
21 {
22  SCORE_ABORT;
23  return i;
24 }
25 inline QDataStream& operator>>(QDataStream& i, ossia::bench_map& sel)
26 {
27  SCORE_ABORT;
28  return i;
29 }
30 
31 namespace ossia
32 {
33 class audio_protocol;
34 struct bench_map;
35 }
36 namespace Device
37 {
38 class DeviceInterface;
39 }
40 namespace score
41 {
42 class DocumentModel;
43 }
44 namespace Scenario
45 {
46 class BaseScenario;
47 class IntervalModel;
48 }
49 namespace Dataflow
50 {
51 class AudioDevice;
52 }
53 namespace Execution
54 {
55 struct Queues
56 {
57 };
59 class SCORE_PLUGIN_ENGINE_EXPORT DocumentPlugin final : public score::DocumentPlugin
60 {
61  W_OBJECT(DocumentPlugin)
62 public:
63  struct ContextData
64  {
65  explicit ContextData(const score::DocumentContext& ctx);
66 
67  ExecutionCommandQueue m_execQueue{1024};
68  EditionCommandQueue m_editionQueue{1024};
69  GCCommandQueue m_gcQueue{1024};
70  std::atomic_bool m_created{};
71 
72  std::shared_ptr<ossia::graph_interface> execGraph;
73  std::shared_ptr<ossia::execution_state> execState;
74  std::shared_ptr<ossia::bench_map> bench;
75  SetupContext setupContext;
76 
77  Context context;
78  };
79 
80  DocumentPlugin(const score::DocumentContext& ctx, QObject* parent);
81 
82  ~DocumentPlugin() override;
83  void reload(bool forcePlay, Scenario::IntervalModel& doc);
84  void clear();
85 
86  void on_documentClosing() override;
87  const std::shared_ptr<BaseScenarioElement>& baseScenario() const noexcept;
88 
89  void playStartState();
90  void playStopState();
91 
92  bool isPlaying() const;
93 
94  const std::shared_ptr<ContextData>& contextData() const noexcept { return m_ctxData; }
95  const Context& context() const noexcept { return m_ctxData->context; }
96  const ExecutionController& executionController() const noexcept;
97  std::shared_ptr<ossia::audio_protocol> audioProto();
98 
99  void runAllCommands() const;
100 
101  void registerAction(ExecutionAction& act);
102  const std::vector<ExecutionAction*>& actions() const noexcept { return m_actions; }
103 
104  const Execution::Settings::Model& settings;
105 
106  QPointer<Dataflow::AudioDevice> audio_device{};
107  QPointer<Device::DeviceInterface> local_device{};
108 
109 public:
110  void finished() E_SIGNAL(SCORE_PLUGIN_ENGINE_EXPORT, finished)
111 
112  void slot_bench(ossia::bench_map, int64_t ns);
113 
114 private:
115  void on_deviceAdded(Device::DeviceInterface* device);
116  void on_finished();
117  void timerEvent(QTimerEvent* event) override;
118  void registerDevice(ossia::net::device_base*);
119  void unregisterDevice(ossia::net::device_base*);
120  void makeGraph();
121  void initExecState();
122  void recreateBase();
123 
124  std::shared_ptr<ContextData> m_ctxData;
125  std::shared_ptr<BaseScenarioElement> m_base;
126  std::vector<ExecutionAction*> m_actions;
127 
128  int m_tid{};
129 };
130 }
Definition: plugins/score-plugin-engine/Execution/DocumentPlugin.hpp:60
Definition: ExecutionController.hpp:31
Definition: ExecutorModel.hpp:64
Definition: IntervalModel.hpp:50
Extend a document with custom data and systems.
Definition: DocumentPluginBase.hpp:24
Manipulation of Devices from Qt.
Definition: AddressSettings.cpp:14
Components used for the execution of a score.
Definition: ProcessComponent.cpp:12
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ExecutionContext.hpp:76
Definition: plugins/score-plugin-engine/Execution/DocumentPlugin.hpp:64
Definition: plugins/score-plugin-engine/Execution/DocumentPlugin.hpp:56
Definition: ExecutionSetup.hpp:38
Definition: DocumentContext.hpp:18