ExecutionController.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 
4 #include <score/plugins/application/GUIApplicationPlugin.hpp>
5 
6 #include <score_plugin_engine_export.h>
7 
8 #include <functional>
9 #include <memory>
10 namespace Scenario
11 {
12 class IntervalModel;
13 class ScenarioDocumentModel;
14 class ScenarioDocumentPresenter;
15 class ScenarioApplicationPlugin;
16 class TransportActions;
17 }
18 namespace Transport
19 {
20 class TransportInterface;
21 }
22 namespace Execution
23 {
24 using TransportInterface = Transport::TransportInterface;
25 struct Context;
26 class Clock;
27 class BaseScenarioElement;
28 using exec_setup_fun
29  = std::function<void(const Execution::Context&, Execution::BaseScenarioElement&)>;
30 class SCORE_PLUGIN_ENGINE_EXPORT ExecutionController : public QObject
31 {
32 public:
35 
36  TransportInterface& transport() const noexcept;
37  void init_transport();
38 
39  TimeVal execution_time() const;
40 
41  void on_record(::TimeVal t);
42  void on_transport(TimeVal t);
43 
44  // User requests playback to the transport interface from the local tree
45  void request_play_from_localtree(bool);
46  void request_play_global_from_localtree(bool);
47  void request_transport_from_localtree(TimeVal);
48  void request_stop_from_localtree();
49  void request_reinitialize_from_localtree();
50 
51  // User requests playback to the transport interface from the GUI
52  void request_play_from_here(TimeVal t);
53  void request_play_global(bool);
54  void request_play_local(bool);
55  void request_play_interval(
56  Scenario::IntervalModel&, exec_setup_fun setup = {},
57  ::TimeVal t = ::TimeVal::zero());
58  void request_stop_interval(Scenario::IntervalModel&);
59  void request_stop();
60 
61 private:
62  // If the transport interface answers: these functions will "press" the Play, etc...
63  // buttons programmatically to put them in the right state, and start the playback
64  void trigger_play();
65  void trigger_pause();
66  void trigger_stop();
67  void trigger_reinitialize();
68 
69  void on_play_global(bool b);
70  void on_play_local(bool b);
71 
72  void play_interval(
73  Scenario::IntervalModel&, exec_setup_fun setup = {},
74  ::TimeVal t = ::TimeVal::zero());
75 
76  void stop_interval(Scenario::IntervalModel&);
77  void ensure_audio_engine();
78 
79  void on_play_local(bool, ::TimeVal t);
80  void on_pause();
81  void on_stop();
82 
86  void on_reinitialize();
87 
88  void stop_clock();
89  void send_end_state();
90  void reset_after_stop();
91  void reset_edition();
92 
93 private:
94  Scenario::ScenarioDocumentModel* currentScenarioModel();
95  Scenario::ScenarioDocumentPresenter* currentScenarioPresenter();
96  score::Document* currentDocument() const;
97  std::unique_ptr<Execution::Clock> makeClock(const Execution::Context&);
98 
99  const score::GUIApplicationContext& context;
101  Scenario::TransportActions& m_actions;
102  std::unique_ptr<Execution::Clock> m_clock;
103  Transport::TransportInterface* m_transport{};
104 
105  struct IntervalToPlay
106  {
107  Scenario::IntervalModel& interval;
108  exec_setup_fun setup;
109  ::TimeVal t;
110  };
111  std::vector<IntervalToPlay> m_intervalsToPlay;
112 
113  bool m_playing{false};
114  bool m_paused{false};
115  bool m_requestLocalPlay{};
116 };
117 }
Definition: BaseScenarioComponent.hpp:83
Definition: ExecutionController.hpp:31
Definition: IntervalModel.hpp:50
Definition: ScenarioApplicationPlugin.hpp:42
Definition: ScenarioDocumentModel.hpp:29
The ScenarioDocumentPresenter class.
Definition: ScenarioDocumentPresenter.hpp:58
Definition: TransportActions.hpp:18
Definition: TransportInterface.hpp:20
The Document class is the central part of the software.
Definition: Document.hpp:51
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
Definition: ExecutionContext.hpp:75
Definition: TimeValue.hpp:21
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15