Loading...
Searching...
No Matches
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
17namespace Process
18{
19class ProcessModel;
20}
21namespace score
22{
23struct DocumentContext;
24}
25namespace ossia
26{
27class scenario;
28class time_interval;
29}
30namespace Scenario
31{
32class IntervalModel;
33}
34
35namespace Execution
36{
37class IntervalComponentBase;
38class IntervalComponent;
39}
40
41namespace score
42{
43#if defined(SCORE_SERIALIZABLE_COMPONENTS)
44template <>
45struct is_component_serializable<Execution::IntervalComponentBase>
46{
47 using type = score::not_serializable_tag;
48};
49
50template <>
51struct is_component_serializable<Execution::IntervalComponent>
52{
53 using type = score::not_serializable_tag;
54};
55#endif
56}
57
58namespace Execution
59{
60struct Context;
61
63{
64 ossia::time_value defaultDuration;
65 ossia::time_value minDuration;
66 ossia::time_value maxDuration;
67 double speed;
68};
69
70class SCORE_PLUGIN_SCENARIO_EXPORT IntervalComponentBase
71 : public Scenario::GenericIntervalComponent<const Context>
72{
73 COMMON_COMPONENT_METADATA("4d644678-1924-49bf-8c82-89841581d23f")
74public:
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
123protected:
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
133class SCORE_PLUGIN_SCENARIO_EXPORT IntervalComponent final
134 : public score::PolymorphicComponentHierarchy<IntervalComponentBase, false>
135{
136 W_OBJECT(IntervalComponent)
137
138public:
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
168public:
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:13
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