WIP: Removed unnecessary pointers and changed to reference type

This commit is contained in:
Robin Dietzel 2023-01-06 14:36:43 +01:00
parent cf70dcd5e5
commit 5c6c69ae10
4 changed files with 14 additions and 14 deletions

View File

@ -7,6 +7,6 @@
// Auto generated header file containing the last git revision
#define GIT_HASH "be1b884"
#define GIT_HASH "6fd24bf"
#endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H

View File

@ -95,15 +95,15 @@ int main(void) {
Menu mainmenu("Hauptmenue");
Menu_Entry_Type_Checkable entry1bool(true);
entry1bool.linkConfig(globalConfig.testbool.getLink());
Menu_Entry entry(&entry1bool, "test");
Menu_Entry entry(entry1bool, "test");
Menu_Entry_Type_Percent entry1perc(15);
Menu_Entry entry2(&entry1perc, "Prozent");
Menu_Entry entry2(entry1perc, "Prozent");
Menu_Entry_Type_Time entry1time(23,44,12);
Menu_Entry entry3(&entry1time, "Uhrzeit");
Menu_Entry entry3(entry1time, "Uhrzeit");
mainmenu.addEntry(entry);
mainmenu.addEntry(entry2);
@ -111,12 +111,12 @@ int main(void) {
Menu submenu("Submenu1");
Menu_Entry_Type_Checkable entrysub(true);
Menu_Entry sube(&entrysub, "yay dies sub!");
Menu_Entry sube(entrysub, "yay dies sub!");
Menu_Entry_Type_ReadOnly<uint16_t> entryread(42);
uint16_t wurst = 0;
entryread.linkConfig(&wurst);
Menu_Entry sube2(&entryread, "Read Only test ");
Menu_Entry sube2(entryread, "Read Only test ");
submenu.addEntry(sube);
submenu.addEntry(sube2);

View File

@ -12,7 +12,7 @@ namespace floatpump::menu {
class Menu_Entry {
public:
Menu_Entry(Menu_Entry_Type_Delegate *type, std::string name) : m_type(type), m_name(name) {};
Menu_Entry(Menu_Entry_Type_Delegate &type, std::string name) : m_type(type), m_name(name) {};
@ -30,7 +30,7 @@ namespace floatpump::menu {
private:
std::string m_name;
menu::Menu_Entry_Type_Delegate *m_type; //Saves type of this menu entry
menu::Menu_Entry_Type_Delegate &m_type; //Saves type of this menu entry
};
}

View File

@ -9,26 +9,26 @@ namespace floatpump {
std::string Menu_Entry::printLine() {
//We have 19 characters width for displaying the entry -> fill with spaces
int spaces = 19 - (m_name.length() + m_type->toString().length());
int spaces = 19 - (m_name.length() + m_type.toString().length());
std::string spacer;
spacer.append(spaces, ' ');
return m_name + spacer + m_type->toString();
return m_name + spacer + m_type.toString();
}
void Menu_Entry::action_press() {
m_type->u_press();
m_type.u_press();
}
void Menu_Entry::action_increase() {
m_type->u_increase(1);
m_type.u_increase(1);
}
void Menu_Entry::action_decrease() {
m_type->u_decrease(1);
m_type.u_decrease(1);
}
bool Menu_Entry::isEntered() {
return m_type->isEntered();
return m_type.isEntered();
}
} // floatpump
} // menu