LocalTreeComponent.hpp
1 #pragma once
2 #include <LocalTree/GetProperty.hpp>
3 #include <LocalTree/NameProperty.hpp>
4 #include <LocalTree/Property.hpp>
5 
6 #include <score/model/Component.hpp>
7 
8 namespace LocalTree
9 {
10 template <typename Component_T>
11 class Component : public Component_T
12 {
13 public:
14  template <typename... Args>
15  Component(ossia::net::node_base& n, score::ModelMetadata& m, Args&&... args)
16  : Component_T{std::forward<Args>(args)...}
17  , m_thisNode{n, m, this}
18  {
19  add<score::ModelMetadata::p_comment>(m);
20  add<score::ModelMetadata::p_label>(m);
21  }
22 
23  ossia::net::node_base& node() const { return m_thisNode.node; }
24 
25  auto& context() const { return this->system(); }
26 
27 protected:
28  template <typename Property, typename Object>
29  void add(Object& obj)
30  {
31  m_properties.push_back(add_property<Property>(node(), obj, this));
32  }
33 
34  template <typename Property, typename Object>
35  void add_get(Object& obj)
36  {
37  m_properties.push_back(add_getProperty<Property>(node(), obj, this));
38  }
39 
40  MetadataNamePropertyWrapper m_thisNode;
41  std::vector<std::unique_ptr<BaseProperty>> m_properties;
42 };
43 
45 }
Definition: LocalTreeComponent.hpp:12
Definition: NameProperty.hpp:13
The ModelMetadata class.
Definition: ModelMetadata.hpp:22
Local tree provides a way to extend the tree given through the Engine::Network::LocalDevice.
Definition: BaseCallbackWrapper.hpp:9