HierarchicalModel.hpp
1 #pragma once
2 #include <score/model/Component.hpp>
3 namespace score
4 {
8 template <typename Model, typename T, T Model::*ptr>
10 {
11  using model_type = Model;
12  using child_type = T;
13  static const constexpr auto member = ptr;
14 };
15 
16 template <typename Model, typename... Args>
18 
19 template <typename Model, typename Arg, typename... Args>
20 struct HierarchicModel<Model, Arg, Args...> : public HierarchicModel<Model, Args...>
21 {
22 public:
23  using HierarchicModel<Model, Args...>::HierarchicModel;
24 
25  virtual ~HierarchicModel()
26  {
27  auto& member = this->*Arg::ptr;
28  for(auto elt : member->map().get())
29  {
30  delete elt;
31  }
32  member->map().clear();
33  }
34 };
35 
36 template <typename Model, typename Arg>
37 struct HierarchicModel<Model, Arg> : public Model
38 {
39 public:
40  using Model::Model;
41 
42  virtual ~HierarchicModel()
43  {
44  auto& member = this->*Arg::ptr;
45  for(auto elt : member->map().get())
46  {
47  delete elt;
48  }
49  member->map().clear();
50  }
51 };
52 
53 // Special case for the common components case :
54 
55 template <typename Model>
58 }
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: HierarchicalModel.hpp:17
Definition: HierarchicalModel.hpp:10