Files
Bachelorarbeit-Rover/lib/Menu/menu.cpp
T
2022-01-12 18:58:52 +01:00

42 lines
845 B
C++

/**
* @file menu.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2022-01-12
*
* @copyright Copyright (c) 2022
*
*/
#include "menu.h"
Menu::Menu(MenuEntry* firstEntry) {
entrys.push_back(firstEntry);
this->it = this->entrys.begin();
}
void Menu::nextEntry() {
if (this->it != this->entrys.end())
this->it++;
else
this->it = this->entrys.begin();
this->printMenu();
}
void Menu::prevEntry() {
if (this->it != this->entrys.begin())
this->it--;
else
this->it = this->entrys.end();
this->printMenu();
}
void Menu::enterEntry() {
// TODO: find out why i cannot call run directly from the iterator
MenuEntry* selectedEntry = *(this->it);
selectedEntry->run();
}
void Menu::enterParentMenu() {
this->parentMenu->printMenu();
}