IntervalExecution.hpp
1 #pragma once
2 #include <Process/Execution/ProcessComponent.hpp>
3 #include <Process/TimeValue.hpp>
4 
5 #include <Scenario/Document/Components/IntervalComponent.hpp>
6 
7 #include <score/model/ComponentHierarchy.hpp>
8 #include <score/model/Identifier.hpp>
9 
10 #include <ossia-qt/time_value.hpp>
11 
12 #include <QObject>
13 
14 #include <memory>
15 #include <verdigris>
16 
17 namespace Process
18 {
19 class ProcessModel;
20 }
21 namespace score
22 {
23 struct DocumentContext;
24 }
25 namespace ossia
26 {
27 class scenario;
28 class time_interval;
29 }
30 namespace Scenario
31 {
32 class IntervalModel;
33 }
34 
35 namespace Execution
36 {
37 class IntervalComponentBase;
38 class IntervalComponent;
39 }
40 
41 namespace score
42 {
43 #if defined(SCORE_SERIALIZABLE_COMPONENTS)
44 template <>
45 struct is_component_serializable<Execution::IntervalComponentBase>
46 {
47  using type = score::not_serializable_tag;
48 };
49 
50 template <>
51 struct is_component_serializable<Execution::IntervalComponent>
52 {
53  using type = score::not_serializable_tag;
54 };
55 #endif
56 }
57 
58 namespace Execution
59 {
60 struct Context;
61 
63 {
64  ossia::time_value defaultDuration;
65  ossia::time_value minDuration;
66  ossia::time_value maxDuration;
67  double speed;
68 };
69 
70 class SCORE_PLUGIN_SCENARIO_EXPORT IntervalComponentBase
71  : public Scenario::GenericIntervalComponent<const Context>
72 {
73  COMMON_COMPONENT_METADATA("4d644678-1924-49bf-8c82-89841581d23f")
74 public:
79 
80  static const constexpr bool is_unique = true;
82  Scenario::IntervalModel& score_cst, const std::shared_ptr<ossia::scenario>& scenar,
83  const Context& ctx, QObject* parent);
84  IntervalComponentBase() = delete;
87  IntervalComponentBase& operator=(const IntervalComponentBase&) = delete;
88  IntervalComponentBase& operator=(IntervalComponentBase&&) = delete;
89 
91  interval_duration_data makeDurations() const;
92 
93  const std::shared_ptr<ossia::time_interval>& OSSIAInterval() const;
94  Scenario::IntervalModel& scoreInterval() const;
95 
96  const auto& processes() const { return m_processes; }
97 
98  void pause();
99  void resume();
100  void stop();
101 
102  void executionStarted();
103  void executionStopped();
104 
106  make(ProcessComponentFactory& factory, Process::ProcessModel& process);
107  ProcessComponent* make(Process::ProcessModel& process) { return nullptr; }
108  std::function<void()> removing(const Process::ProcessModel& e, ProcessComponent& c);
109 
110  template <typename... Args>
111  void added(Args&&...)
112  {
113  }
114  template <typename Component_T, typename Element, typename Fun>
115  void removed(const Element& elt, const Component_T& comp, Fun f)
116  {
117  if(f)
118  f();
119  }
120 
121  const Context& context() const { return system(); }
122 
123 protected:
124  void on_processAdded(Process::ProcessModel& score_proc);
125  void
126  recomputePropagate(const Process::ProcessModel& process, const Process::Port& port);
127 
128  std::shared_ptr<ossia::time_interval> m_ossia_interval;
129  score::hash_map<Id<Process::ProcessModel>, std::shared_ptr<ProcessComponent>>
130  m_processes;
131 };
132 
133 class SCORE_PLUGIN_SCENARIO_EXPORT IntervalComponent final
134  : public score::PolymorphicComponentHierarchy<IntervalComponentBase, false>
135 {
136  W_OBJECT(IntervalComponent)
137 
138 public:
139  IntervalComponent() = delete;
140  template <typename... Args>
141  IntervalComponent(Args&&... args)
142  : PolymorphicComponentHierarchyManager{
143  score::lazy_init_t{}, std::forward<Args>(args)...}
144  {
145  }
146 
147  IntervalComponent(const IntervalComponent&) = delete;
149  IntervalComponent& operator=(const IntervalComponent&) = delete;
150  IntervalComponent& operator=(IntervalComponent&&) = delete;
152 
153  // only here to help autocompletion
154  const std::shared_ptr<ossia::time_interval>& OSSIAInterval() const
155  {
156  return IntervalComponentBase::OSSIAInterval();
157  }
158 
159  void init();
160  void cleanup(const std::shared_ptr<IntervalComponent>&);
161 
163  void onSetup(
164  std::shared_ptr<IntervalComponent>,
165  std::shared_ptr<ossia::time_interval> ossia_cst, interval_duration_data dur,
166  bool executionRoot = false);
167 
168 public:
169  void slot_callback(bool running, ossia::time_value date);
170  W_SLOT(slot_callback);
171  void graph_slot_callback(bool running, ossia::time_value date);
172  W_SLOT(graph_slot_callback);
173 };
174 }
Definition: IntervalExecution.hpp:72
Definition: IntervalExecution.hpp:135
Definition: Process/Execution/ProcessComponent.hpp:102
Definition: Process/Execution/ProcessComponent.hpp:154
Definition: Process/Execution/ProcessComponent.hpp:48
Definition: Port.hpp:102
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Definition: Scenario/Document/Components/IntervalComponent.hpp:12
Definition: IntervalModel.hpp:50
A component that has a reference to a specific context object.
Definition: lib/score/model/Component.hpp:58
Manages polymorphic hierarchies of components.
Definition: ComponentHierarchy.hpp:165
Components used for the execution of a score.
Definition: ProcessComponent.cpp:12
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
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: IntervalExecution.hpp:63
Definition: lib/score/model/Component.hpp:16