algorithm-visualizer
 All Classes
Layout.h
1 #ifndef LAYOUT_H
2 #define LAYOUT_H
3 
4 #include "Commander.h"
5 
6 class Layout : public Commander {
7 protected:
8  using commander_list = std::vector<Commander>;
9 
10 private:
11  static std::vector<string> keys(const commander_list &children) {
12  std::vector<string> keys;
13  keys.reserve(children.size());
14  for (Commander commander : children) {
15  keys.push_back(commander.key);
16  }
17  return keys;
18  }
19 
20 public:
21  static void setRoot(const Commander &child) {
22  command(nullptr, "setRoot", {child.key});
23  }
24 
25  Layout(const commander_list &children, const string &className = "Layout") : Commander({keys(children)},
26  className) {
27  }
28 
29  void add(const Commander &child, int index) {
30  command("add", {child.key, index});
31  }
32 
33  void add(const Commander &child) {
34  command("add", {child.key});
35  }
36 
37  void remove(const Commander &child) {
38  command("remove", {child.key});
39  }
40 
41  void removeAll() {
42  command("remove", {});
43  }
44 };
45 
46 #endif
Definition: Layout.h:6
Definition: Commander.h:14