score
Home
Classes
Namespaces
Files
Loading...
Searching...
No Matches
HierarchicalModel.hpp
1
#pragma once
2
#include <score/model/Component.hpp>
3
namespace
score
4
{
8
template
<
typename
Model,
typename
T, T Model::*ptr>
9
struct
HierarchicalMember
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>
17
struct
HierarchicModel
;
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>
56
using
HierarchicalComponents
57
=
HierarchicalMember<Model, score::Components, &Model::components>
;
58
}
score
Base toolkit upon which the software is built.
Definition
Application.cpp:90
score::HierarchicModel
Definition
HierarchicalModel.hpp:17
score::HierarchicalMember
Definition
HierarchicalModel.hpp:10