Initial commit

This commit is contained in:
2023-02-10 09:32:39 +01:00
commit 84bbb1297b
13 changed files with 1008 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
/**
* @file menuAction.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief Implentation of the class MenuAction
* @version 0.1
* @date 2022-01-12
*
* @copyright Copyright (c) 2022
*
*/
#include "menuAction.h"
MenuAction::MenuAction(const char* name, void (*function) (), void (*callback) ()) {
this->name = name;
this->function = function;
this->callback = callback;
}
MenuAction::MenuAction(const char* name, MenuControl* menu) {
this->name = name;
this->menu = menu;
this->isMenu = true;
}
MenuAction::MenuAction(const char* name, MenuActionWrapper* action) {
this->name = name;
this->action = action;
}
MenuAction::~MenuAction() {
if (this->menu)
delete this->menu;
if (this->action)
delete this->action;
}
void MenuAction::runAction() {
if (isMenu)
this->menu->printMenu();
else {
if (this->function)
this->function();
else if (this->action)
this->action->action();
else
std::cout << "Error in MenuAction::runAction" << std::endl;
}
if (this->callback)
this->callback();
}
const char* MenuAction::getName() {
return this->name;
}
bool MenuAction::getIsMenu() {
return this->isMenu;
}
MenuControl* MenuAction::getMenu() {
if (isMenu)
return this->menu;
else
return nullptr;
}