-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.h
27 lines (25 loc) · 876 Bytes
/
Menu.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
#pragma once
#include <map>
#include <vector>
#include <memory>
#include <string>
#include "Option.h"
#include "Config.h"
#include "Notifier.h"
class Menu
{
public:
Menu(std::shared_ptr<Communicator> communicator, const Config& appConfig, std::shared_ptr<Notifier> programExitedNotifier);
void selectAndExecuteOption();
virtual void printOptions() = 0;
protected:
std::vector<std::shared_ptr<Option>> indexedOptions;
std::map<std::string, std::shared_ptr<Option>> namedOptions;
private:
void onFormatChanged(std::shared_ptr<std::string> newFormat);
void addNamedOptionsAsIndexed();
std::shared_ptr<Option> selectMatchingOption(const std::string& handledInput);
std::shared_ptr<Option> selectNamedOption(const std::string& handledInput);
std::shared_ptr<Communicator> communicator;
std::map<std::string, std::map<std::string, std::shared_ptr<Option>>> options;
};