-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.h
More file actions
37 lines (33 loc) · 979 Bytes
/
Menu.h
File metadata and controls
37 lines (33 loc) · 979 Bytes
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
#ifndef MENU_H
#define MENU_H
#include "MenuComponent.h"
#include <iostream>
#include <string>
#include <string_view>
#include <list>
class Menu : public MenuComponent {
public:
Menu(std::string_view n, std::string_view d) : name(n), description(d) { }
void add(menu_component_t menuComponent) override {
menuComponents.push_back(menuComponent); }
void remove(menu_component_t menuComponent) override {
menuComponents.remove(menuComponent); }
std::string getName() const override { return name; }
std::string getDescription() const override { return description; }
void print() const override;
private:
std::list<menu_component_t> menuComponents;
std::string name;
std::string description;
};
inline
void
Menu::print() const
{
std::cout << '\n' << getName();
std::cout << ", " << getDescription() << '\n';
std::cout << "----------------------\n";
for (const auto &menuComponent : menuComponents)
menuComponent->print() ;
}
#endif /* MENU_H */