Loading...
Searching...
No Matches
StateExecution.hpp
1#pragma once
2#include <Process/Execution/ProcessComponent.hpp>
3#include <Process/ExecutionComponent.hpp>
4#include <Process/Process.hpp>
5
6#include <Scenario/Document/Components/IntervalComponent.hpp>
7#include <Scenario/Document/State/StateModel.hpp>
8
9#include <score/model/ComponentHierarchy.hpp>
10
11#include <ossia/dataflow/nodes/state.hpp>
12
13namespace ossia
14{
15class graph_node;
16class time_event;
17}
18namespace Scenario
19{
20class StateModel;
21}
22
23namespace Execution
24{
25class SCORE_PLUGIN_SCENARIO_EXPORT StateComponentBase : public Execution::Component
26{
27 COMMON_COMPONENT_METADATA("b3905e79-2bd0-48bd-8654-8666455ceedd")
28public:
29 static constexpr bool is_unique = true;
30
36 const Scenario::StateModel& element, std::shared_ptr<ossia::time_event> ev,
37 const Execution::Context& ctx, QObject* parent);
38
40 void onDelete() const;
41 void updateControls();
42
44 make(ProcessComponentFactory& factory, Process::ProcessModel& process);
45 ProcessComponent* make(Process::ProcessModel& process) { return nullptr; }
46 std::function<void()> removing(const Process::ProcessModel& e, ProcessComponent& c);
47
48 template <typename... Args>
49 void added(Args&&...)
50 {
51 }
52 template <typename Component_T, typename Element, typename Fun>
53 void removed(const Element& elt, const Component_T& comp, Fun f)
54 {
55 if(f)
56 f();
57 }
58 template <typename Models>
59 const auto& models() const
60 {
61 static_assert(
62 std::is_same<Models, Process::ProcessModel>::value,
63 "State component must be passed Process::ProcessModel as child.");
64
65 return m_model->stateProcesses;
66 }
67
68 const auto& processes() const { return m_processes; }
69 const auto& state() const
70 {
71 SCORE_ASSERT(m_model);
72 return *m_model;
73 }
74 const std::shared_ptr<ossia::nodes::state_writer>& node() const { return m_node; }
75
76protected:
77 QPointer<const Scenario::StateModel> m_model;
78 std::shared_ptr<ossia::time_event> m_ev;
79 std::shared_ptr<ossia::nodes::state_writer> m_node;
80 score::hash_map<Id<Process::ProcessModel>, std::shared_ptr<ProcessComponent>>
81 m_processes;
82};
83
84class SCORE_PLUGIN_SCENARIO_EXPORT StateComponent final
85 : public score::PolymorphicComponentHierarchy<StateComponentBase, false>
86{
87public:
88 template <typename... Args>
89 StateComponent(Args&&... args)
90 : PolymorphicComponentHierarchyManager{
91 score::lazy_init_t{}, std::forward<Args>(args)...}
92 {
93 init();
94 }
95
96 StateComponent(const StateComponent&) = delete;
98 StateComponent& operator=(const StateComponent&) = delete;
99 StateComponent& operator=(StateComponent&&) = delete;
101
103 void onSetup();
104
105 void init();
106 void cleanup(const std::shared_ptr<StateComponent>&);
107};
108}
Definition Process/Execution/ProcessComponent.hpp:102
Definition Process/Execution/ProcessComponent.hpp:154
Definition Process/Execution/ProcessComponent.hpp:48
Definition StateExecution.hpp:26
Definition StateExecution.hpp:86
The Process class.
Definition score-lib-process/Process/Process.hpp:61
Definition StateModel.hpp:63
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
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Definition ExecutionContext.hpp:76
Definition lib/score/model/Component.hpp:16