Files
Bachelorarbeit-Rover/lib/Menu/menuEntry.cpp
T
2022-01-19 09:13:53 +01:00

55 lines
1.0 KiB
C++

/**
* @file menuEntry.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @version 0.1
* @date 2022-01-12
*
* @copyright Copyright (c) 2022
*
*/
#include "menuEntry.h"
MenuEntry::MenuEntry(const char* name, void (*function) (), void (*callback) ()) {
this->name = name;
this->function = function;
this->callback = callback;
}
MenuEntry::MenuEntry(const char* name, void (*function) ()) {
this->name = name;
this->function = function;
this->callback = nullptr;
}
MenuEntry::MenuEntry(const char* name, Menu* menu) {
this->name = name;
this->menu = menu;
this->isMenu = true;
this->callback = nullptr;
}
void MenuEntry::runAction() {
if (isMenu)
this->menu->printMenu();
else
this->function();
if (this->callback)
this->callback();
}
const char* MenuEntry::getName() {
return this->name;
}
bool MenuEntry::getIsMenu() {
return this->isMenu;
}
Menu* MenuEntry::getMenu() {
if (isMenu)
return this->menu;
else
return nullptr;
}