-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathLayout.h
46 lines (36 loc) · 1.09 KB
/
Layout.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
#ifndef LAYOUT_H
#define LAYOUT_H
#include "Commander.h"
class Layout : public Commander {
protected:
using commander_list = std::vector<Commander>;
private:
static std::vector<string> keys(const commander_list &children) {
std::vector<string> keys;
keys.reserve(children.size());
for (Commander commander : children) {
keys.push_back(commander.key);
}
return keys;
}
public:
static void setRoot(const Commander &child) {
command(nullptr, "setRoot", {child.key});
}
Layout(const commander_list &children, const string &className = "Layout") : Commander({keys(children)},
className) {
}
void add(const Commander &child, int index) {
command("add", {child.key, index});
}
void add(const Commander &child) {
command("add", {child.key});
}
void remove(const Commander &child) {
command("remove", {child.key});
}
void removeAll() {
command("remove", {});
}
};
#endif