Loading...
Searching...
No Matches
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 <QTimer>
18
19#include <memory>
20#include <verdigris>
21inline QDataStream& operator<<(QDataStream& i, const ossia::bench_map& sel)
22{
23 SCORE_ABORT;
24 return i;
25}
26inline QDataStream& operator>>(QDataStream& i, ossia::bench_map& sel)
27{
28 SCORE_ABORT;
29 return i;
30}
31
32namespace ossia
33{
34class audio_protocol;
35struct bench_map;
36}
37namespace Device
38{
39class DeviceInterface;
40}
41namespace score
42{
43class DocumentModel;
44}
45namespace Scenario
46{
47class BaseScenario;
48class IntervalModel;
49}
50namespace Dataflow
51{
52class AudioDevice;
53}
54namespace Execution
55{
56struct Queues
57{
58};
60class SCORE_PLUGIN_ENGINE_EXPORT DocumentPlugin final : public score::DocumentPlugin
61{
62 W_OBJECT(DocumentPlugin)
63public:
65 {
66 explicit ContextData(const score::DocumentContext& ctx);
67
68 ExecutionCommandQueue m_execQueue{1024};
69 EditionCommandQueue m_editionQueue{1024};
70 GCCommandQueue m_gcQueue{1024};
71 std::atomic_bool m_created{};
72
73 std::shared_ptr<ossia::graph_interface> execGraph;
74 std::shared_ptr<ossia::execution_state> execState;
75 std::shared_ptr<ossia::bench_map> bench;
76 SetupContext setupContext;
77
78 Context context;
79 };
80
81 DocumentPlugin(const score::DocumentContext& ctx, QObject* parent);
82
83 ~DocumentPlugin() override;
84 void reload(bool forcePlay, Scenario::IntervalModel& doc);
85 void clear();
86
87 void on_documentClosing() override;
88 const std::shared_ptr<BaseScenarioElement>& baseScenario() const noexcept;
89
90 void playStartState();
91 void playStopState();
92
93 bool isPlaying() const;
94
95 const std::shared_ptr<ContextData>& contextData() const noexcept { return m_ctxData; }
96 const Context& context() const noexcept { return m_ctxData->context; }
97 const ExecutionController& executionController() const noexcept;
98 std::shared_ptr<ossia::audio_protocol> audioProto();
99
100 void runAllCommands() const;
101
102 void registerAction(ExecutionAction& act);
103 const std::vector<ExecutionAction*>& actions() const noexcept { return m_actions; }
104
105 const Execution::Settings::Model& settings;
106
107 QPointer<Dataflow::AudioDevice> audio_device{};
108 QPointer<Device::DeviceInterface> local_device{};
109
110public:
111 void finished() E_SIGNAL(SCORE_PLUGIN_ENGINE_EXPORT, finished)
112
113 void slot_bench(ossia::bench_map, int64_t ns);
114
115private:
116 void on_deviceAdded(Device::DeviceInterface* device);
117 void on_finished();
118 void timerEvent(QTimerEvent* event) override;
119 void registerDevice(ossia::net::device_base*);
120 void unregisterDevice(ossia::net::device_base*);
121 void makeGraph();
122 void initExecState();
123 void recreateBase();
124
125 std::shared_ptr<ContextData> m_ctxData;
126 std::shared_ptr<BaseScenarioElement> m_base;
127 std::vector<ExecutionAction*> m_actions;
128
129 int m_tid{};
130};
131}
Definition plugins/score-plugin-engine/Execution/DocumentPlugin.hpp:61
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:13
Base toolkit upon which the software is built.
Definition Application.cpp:90
STL namespace.
Definition ExecutionContext.hpp:76
Definition plugins/score-plugin-engine/Execution/DocumentPlugin.hpp:65
Definition plugins/score-plugin-engine/Execution/DocumentPlugin.hpp:57
Definition ExecutionSetup.hpp:38
Definition DocumentContext.hpp:18