55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
//
|
|
// Created by robtor on 09.12.22.
|
|
//
|
|
|
|
#ifndef FLOATPUMP_MENU_H
|
|
#define FLOATPUMP_MENU_H
|
|
|
|
#include <utility>
|
|
#include <vector>
|
|
#include <typeinfo>
|
|
#include "Menu_Entry.h"
|
|
#include "LCD_I2C_Driver.h"
|
|
|
|
namespace floatpump::menu {
|
|
|
|
class Menu {
|
|
|
|
public:
|
|
|
|
explicit Menu(std::string name) : m_name(std::move(name)) {}
|
|
|
|
//Add specific components
|
|
void addEntry(const Menu_Entry &entry);
|
|
|
|
void addSubmenu(Menu *submenu);
|
|
|
|
//Get this menu as string
|
|
[[nodiscard]] std::string printLine() const;
|
|
|
|
//Get all submenus and entries as string vector
|
|
std::vector<std::string> getDisplayList();
|
|
|
|
//Get number of all entries
|
|
[[nodiscard]] unsigned int getAllEntriesNum() const;
|
|
|
|
//Retrieve specific submenu, returns nullptr on error
|
|
Menu *getSubmenu(int index);
|
|
|
|
//Retrieve specific entry, returns nullptr on error
|
|
Menu_Entry *getEntry(int index);
|
|
|
|
//Returns parent menu pointer or nullptr
|
|
Menu *getParent();
|
|
|
|
private:
|
|
std::vector<Menu_Entry> m_entries; //normal menu entries
|
|
std::vector<Menu *> m_submenus; //all submenu entries
|
|
Menu *m_parent = nullptr; //the parent menu, if it is a submenu
|
|
std::string m_name = "Menu"; //the name of this menu (displayed if it is an submenu)
|
|
};
|
|
|
|
}
|
|
|
|
#endif //FLOATPUMP_MENU_H
|