-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmarbles.h
122 lines (96 loc) · 3.29 KB
/
marbles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef MARBLES_H
#define MARBLES_H
#include <string>
#include <sst/core/subcomponent.h>
namespace SST {
namespace MarblesDemo {
class Marble : public SubComponent {
public:
SST_ELI_REGISTER_SUBCOMPONENT_API(
SST::MarblesDemo::Marble
)
Marble(ComponentId_t id, Params& params) : SubComponent(id), comp_id(id) {}
virtual void print(SST::Output *output) {}
ComponentId_t comp_id;
};
template<typename T>
class LargeMarble : public Marble {
public:
SST_ELI_REGISTER_SUBCOMPONENT_DERIVED_API(
SST::MarblesDemo::LargeMarble<T>,
SST::MarblesDemo::Marble
)
LargeMarble(ComponentId_t id, Params& params) : Marble(id, params) {}
virtual void print(SST::Output *output) override {
std::string template_type;
if (std::is_same<T, float>::value) template_type = "float";
if (std::is_same<T, int>::value) template_type = "int";
output->output("\tLargeMarble(%ld) is templated with type %s\n", comp_id, template_type.c_str());
}
};
template<typename T>
class SmallMarble : public Marble {
public:
SST_ELI_REGISTER_SUBCOMPONENT_DERIVED_API(
SST::MarblesDemo::SmallMarble<T>,
SST::MarblesDemo::Marble
)
SmallMarble(ComponentId_t id, Params& params) : Marble(id, params) {}
virtual void print(SST::Output *output) override {
std::string template_type;
if (std::is_same<T, float>::value) template_type = "float";
if (std::is_same<T, int>::value) template_type = "int";
output->output("\tSmallMarble(%ld) is templated with type %s\n", comp_id, template_type.c_str());
}
};
class SmallIntMarble : public SmallMarble<int> {
public:
SST_ELI_REGISTER_SUBCOMPONENT(
SmallIntMarble,
"MarblesDemo",
"SmallIntMarble",
SST_ELI_ELEMENT_VERSION(1, 0, 0),
"Implements the SmallMarble derivation of a Marble",
SST::MarblesDemo::SmallMarble<int>
)
SmallIntMarble(ComponentId_t id, Params& params) : SmallMarble<int>(id, params) {}
};
class SmallFloatMarble : public SmallMarble<float> {
public:
SST_ELI_REGISTER_SUBCOMPONENT(
SmallFloatMarble,
"MarblesDemo",
"SmallFloatMarble",
SST_ELI_ELEMENT_VERSION(1, 0, 0),
"Implements the SmallMarble derivation of a Marble",
SST::MarblesDemo::SmallMarble<float>
)
SmallFloatMarble(ComponentId_t id, Params& params) : SmallMarble<float>(id, params) {}
};
class LargeIntMarble : public LargeMarble<int> {
public:
SST_ELI_REGISTER_SUBCOMPONENT(
LargeIntMarble,
"MarblesDemo",
"LargeIntMarble",
SST_ELI_ELEMENT_VERSION(1, 0, 0),
"Implements the LargeMarble derivation of a Marble",
SST::MarblesDemo::LargeMarble<int>
)
LargeIntMarble(ComponentId_t id, Params& params) : LargeMarble<int>(id, params) {}
};
class LargeFloatMarble : public LargeMarble<float> {
public:
SST_ELI_REGISTER_SUBCOMPONENT(
LargeFloatMarble,
"MarblesDemo",
"LargeFloatMarble",
SST_ELI_ELEMENT_VERSION(1, 0, 0),
"Implements the LargeMarble derivation of a Marble",
SST::MarblesDemo::LargeMarble<float>
)
LargeFloatMarble(ComponentId_t id, Params& params) : LargeMarble<float>(id, params) {}
};
} // namespace MarblesDemo
} // namespace SST
#endif // MARBLE_H