Loading...
Searching...
No Matches
Process/ScenarioExecution.hpp
1#pragma once
2#include <Process/Execution/ProcessComponent.hpp>
3
4#include <Scenario/Document/Components/ScenarioComponent.hpp>
5#include <Scenario/Document/Event/EventExecution.hpp>
6#include <Scenario/Document/Graph.hpp>
7#include <Scenario/Document/Interval/IntervalExecution.hpp>
8#include <Scenario/Document/Interval/IntervalModel.hpp>
9#include <Scenario/Document/State/StateExecution.hpp>
10#include <Scenario/Document/TimeSync/TimeSyncExecution.hpp>
11#include <Scenario/Tools/dataStructures.hpp>
12
13#include <score/model/IdentifiedObjectMap.hpp>
14#include <score/model/Identifier.hpp>
15#include <score/tools/std/Optional.hpp>
16
17#include <ossia/editor/scenario/time_event.hpp>
18
19#include <memory>
20#include <verdigris>
21
22Q_DECLARE_METATYPE(std::shared_ptr<Execution::EventComponent>)
23W_REGISTER_ARGTYPE(std::shared_ptr<Execution::EventComponent>)
24Q_DECLARE_METATYPE(ossia::time_event::status)
25W_REGISTER_ARGTYPE(ossia::time_event::status)
26namespace Device
27{
28class DeviceList;
29}
30namespace Process
31{
32class ProcessModel;
33}
34class QObject;
35namespace ossia
36{
37class time_process;
38struct time_value;
39} // namespace OSSIA
40
41namespace Execution
42{
43class EventComponent;
44class StateComponent;
45class TimeSyncComponent;
46}
47
48namespace Scenario
49{
50class ProcessModel;
51class EventModel;
52class StateModel;
53class TimeSyncModel;
54class CSPCoherencyCheckerInterface;
55} // namespace Scenario
56
57namespace ossia
58{
59class scenario;
60}
61
62namespace Execution
63{
64class IntervalComponent;
65class SCORE_PLUGIN_SCENARIO_EXPORT ScenarioComponentBase
66 : public ProcessComponent_T<Scenario::ProcessModel, ossia::scenario>
67{
68 W_OBJECT(ScenarioComponentBase)
69 COMPONENT_METADATA("4e4b1c1a-1a2a-4ae6-a1a1-38d0900e74e8")
70
71public:
73 Scenario::ProcessModel& proc, const Context& ctx, QObject* parent);
74 ~ScenarioComponentBase() override;
75
76 const auto& states() const { return m_ossia_states; }
77 const score::hash_map<Id<Scenario::IntervalModel>, std::shared_ptr<IntervalComponent>>&
78 intervals() const
79 {
80 return m_ossia_intervals;
81 }
82 const auto& events() const { return m_ossia_timeevents; }
83 const auto& timeSyncs() const { return m_ossia_timesyncs; }
84
85 void playInterval(const Scenario::IntervalModel& itv);
86 void stopInterval(const Scenario::IntervalModel& itv);
87
88 void stop() override;
89
90 template <typename Component_T, typename Element>
91 Component_T* make(Element& elt);
92
93 template <typename Component_T, typename Element, typename Fun>
94 void removed(const Element& elt, const Component_T& comp, Fun f)
95 {
96 if(f)
97 f();
98 }
99
100 std::function<void()> removing(const Scenario::IntervalModel& e, IntervalComponent& c);
101
102 std::function<void()> removing(const Scenario::TimeSyncModel& e, TimeSyncComponent& c);
103
104 std::function<void()> removing(const Scenario::EventModel& e, EventComponent& c);
105
106 std::function<void()> removing(const Scenario::StateModel& e, StateComponent& c);
107
108public:
109 void
110 sig_eventCallback(std::shared_ptr<EventComponent> arg_1, ossia::time_event::status st)
111 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, sig_eventCallback, arg_1, st)
112
113protected:
114 void startIntervalExecution(const Id<Scenario::IntervalModel>&);
115 void stopIntervalExecution(const Id<Scenario::IntervalModel>&);
116 void disableIntervalExecution(const Id<Scenario::IntervalModel>& id);
117
118 void
119 eventCallback(std::shared_ptr<EventComponent> ev, ossia::time_event::status newStatus);
120
121 score::hash_map<Id<Scenario::IntervalModel>, std::shared_ptr<IntervalComponent>>
122 m_ossia_intervals;
123 score::hash_map<Id<Scenario::StateModel>, std::shared_ptr<StateComponent>>
124 m_ossia_states;
125 score::hash_map<Id<Scenario::TimeSyncModel>, std::shared_ptr<TimeSyncComponent>>
126 m_ossia_timesyncs;
127 score::hash_map<Id<Scenario::EventModel>, std::shared_ptr<EventComponent>>
128 m_ossia_timeevents;
129
130 score::hash_map<Id<Scenario::IntervalModel>, Scenario::IntervalModel*>
131 m_executingIntervals;
132
133 const Context& m_ctx;
134
136 QVector<Id<Scenario::TimeSyncModel>> m_pastTn{};
137 Scenario::ElementsProperties m_properties{};
138
140};
141
145
146struct SCORE_PLUGIN_SCENARIO_EXPORT ScenarioComponent final
148{
149 ScenarioComponent(Scenario::ProcessModel& proc, const Context& ctx, QObject* parent);
150
151 void lazy_init() override;
152
153 void cleanup() override;
154};
155
157}
Definition EventExecution.hpp:18
Definition IntervalExecution.hpp:135
Definition Process/Execution/ProcessComponent.hpp:119
Definition Process/ScenarioExecution.hpp:67
Definition StateExecution.hpp:86
Definition TimeSyncExecution.hpp:20
Definition Scenario/Document/Components/ScenarioComponent.hpp:198
Definition CSPCoherencyCheckerInterface.hpp:9
Definition EventModel.hpp:36
Definition IntervalModel.hpp:50
The core hierarchical and temporal process of score.
Definition ScenarioModel.hpp:37
Definition StateModel.hpp:63
Definition TimeSyncModel.hpp:34
The id_base_t class.
Definition Identifier.hpp:57
Manipulation of Devices from Qt.
Definition AddressSettings.cpp:14
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
Definition ExecutionContext.hpp:76
Definition Process/Execution/ProcessComponent.hpp:89
Definition Process/ScenarioExecution.hpp:148
Definition dataStructures.hpp:65
Definition score-plugin-scenario/Scenario/Document/Graph.hpp:63