floatpump-firmware/Middlewares/floatpump/Inc/Menu.h

55 lines
1.4 KiB
C
Raw Normal View History

//
// Created by robtor on 09.12.22.
//
#ifndef FLOATPUMP_MENU_H
#define FLOATPUMP_MENU_H
2023-01-06 12:51:07 +00:00
#include <utility>
2023-01-04 12:22:45 +00:00
#include <vector>
2023-01-05 15:32:42 +00:00
#include <typeinfo>
2023-01-04 12:22:45 +00:00
#include "Menu_Entry.h"
#include "LCD_I2C_Driver.h"
2023-01-06 12:51:07 +00:00
namespace floatpump::menu {
2023-01-06 12:51:07 +00:00
class Menu {
2023-01-06 12:51:07 +00:00
public:
2023-01-04 12:22:45 +00:00
2023-01-06 12:51:07 +00:00
explicit Menu(std::string name) : m_name(std::move(name)) {}
2023-01-05 16:42:39 +00:00
2023-01-06 12:51:07 +00:00
//Add specific components
void addEntry(const Menu_Entry &entry);
2023-01-04 12:22:45 +00:00
2023-01-06 12:51:07 +00:00
void addSubmenu(Menu *submenu);
2023-01-06 12:51:07 +00:00
//Get this menu as string
[[nodiscard]] std::string printLine() const;
2023-01-06 12:51:07 +00:00
//Get all submenus and entries as string vector
std::vector<std::string> getDisplayList();
2023-01-06 08:27:53 +00:00
2023-01-06 12:51:07 +00:00
//Get number of all entries
[[nodiscard]] unsigned int getAllEntriesNum() const;
2023-01-04 12:22:45 +00:00
2023-01-06 12:51:07 +00:00
//Retrieve specific submenu, returns nullptr on error
Menu *getSubmenu(int index);
2023-01-04 12:22:45 +00:00
2023-01-06 12:51:07 +00:00
//Retrieve specific entry, returns nullptr on error
Menu_Entry *getEntry(int index);
2023-01-06 12:51:07 +00:00
//Returns parent menu pointer or nullptr
Menu *getParent();
2023-01-06 12:51:07 +00:00
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)
};
2023-01-06 12:51:07 +00:00
}
#endif //FLOATPUMP_MENU_H