2 #include <Process/Execution/ProcessComponent.hpp>
4 #include <Nodal/Process.hpp>
6 #include <score/model/ComponentHierarchy.hpp>
8 #include <ossia/dataflow/node_process.hpp>
9 #include <ossia/detail/hash_map.hpp>
15 COMPONENT_METADATA(
"e85e0114-2a7e-4569-8a1d-f00c9fd22960")
28 std::shared_ptr<Execution::ProcessComponent> comp;
31 ossia::hash_map<Id<Process::ProcessModel>,
RegisteredNode> m_nodes;
42 template <
typename Component_T,
typename Element,
typename Fun>
43 void removed(
const Element& elt,
const Component_T& comp, Fun f)
49 template <
typename Models>
53 std::is_same<Models, Process::ProcessModel>::value,
54 "Node component must be passed Process::ProcessModel as child.");
56 return process().nodes;
66 ,
public Nano::Observer
86 template <
typename... Args>
97 auto& child_models = process().nodes;
98 for(
auto& child_model : child_models)
103 child_models.mutable_added.template connect<&hierarchy_t::add>(
this);
105 child_models.removing.template connect<&hierarchy_t::remove>(
this);
108 const auto& children()
const {
return m_children; }
113 if(
auto factory = m_componentFactory.factory(model))
117 auto comp = this->make(*factory, model);
120 model.components().add(comp);
121 m_children.emplace_back(ChildPair{&model, comp});
127 auto comp = ParentComponent_T::make(model);
130 model.components().add(comp);
131 m_children.emplace_back(ChildPair{&model, comp});
132 ParentComponent_T::added(*comp);
137 void remove(
const ChildModel_T& model)
140 = ossia::find_if(m_children, [&](
auto pair) {
return pair.model == &model; });
142 if(it != m_children.end())
145 m_children.erase(it);
151 for(
const auto& element : m_children)
158 ~HierarchyManager() { clear(); }
161 void do_cleanup(
const ChildPair& pair)
163 auto t = ParentComponent_T::removing(*pair.model, *pair.component);
164 pair.model->components().erase(*pair.component);
165 ParentComponent_T::removed(*pair.model, *pair.component, std::move(t));
168 const ChildComponentFactoryList_T& m_componentFactory;
170 std::vector<ChildPair> m_children;
183 void cleanup()
override;
Definition: Process/Execution/ProcessComponent.hpp:119
Definition: Process/Execution/ProcessComponent.hpp:102
Definition: Process/Execution/ProcessComponent.hpp:154
Definition: Process/Execution/ProcessComponent.hpp:48
Definition: score-plugin-nodal/Nodal/Executor.hpp:67
Definition: score-plugin-nodal/Nodal/Process.hpp:14
Definition: score-plugin-nodal/Nodal/Executor.hpp:14
Definition: score-plugin-nodal/Nodal/Executor.hpp:175
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
A component that has a reference to a specific context object.
Definition: lib/score/model/Component.hpp:58
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ExecutionContext.hpp:76
Definition: Process/Execution/ProcessComponent.hpp:89
Definition: ExecutionTransaction.hpp:18
Definition: score-plugin-nodal/Nodal/Executor.hpp:76
Definition: score-plugin-nodal/Nodal/Executor.hpp:27