diff options
Moved templated stuff into hpp files and added a blank main.cpp file
6 files changed, 13 insertions, 30 deletions
| -rw-r--r-- | src/ConsoleInterface/Command.cpp | 5 | ||||
| -rw-r--r-- | src/ConsoleInterface/Command.h | 1 | ||||
| -rw-r--r-- | src/ConsoleInterface/Menu.cpp | 2 | ||||
| -rw-r--r-- | src/ConsoleInterface/Menu.h | 2 | ||||
| -rw-r--r-- | src/ConsoleInterface/Toolbox.h | 25 | ||||
| -rw-r--r-- | src/ConsoleInterface/Toolbox.hpp (renamed from src/ConsoleInterface/Toolbox.cpp) | 8 |
diff --git a/src/ConsoleInterface/Command.cpp b/src/ConsoleInterface/Command.cpp index da8915f..d3d058c 100644 --- a/src/ConsoleInterface/Command.cpp +++ b/src/ConsoleInterface/Command.cpp @@ -1,13 +1,16 @@ #include "Command.h" #include <cstring> +Command::Command() : Command("", nullptr) {} + Command::Command(const char* nameInMenu, void (*exec)()) { strcpy(this->nameInMenu, nameInMenu); this->exec = exec; } void Command::run() const { - exec(); + if (exec != nullptr) + exec(); } const char* Command::get_nameInMenu() const { diff --git a/src/ConsoleInterface/Command.h b/src/ConsoleInterface/Command.h index fba011b..d00b277 100644 --- a/src/ConsoleInterface/Command.h +++ b/src/ConsoleInterface/Command.h @@ -6,6 +6,7 @@ class Command { void (*exec)(); public: + Command(); Command(const char* nameInMenu, void (*exec)()); void run() const; diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp index 7bd7c5e..333c47a 100644 --- a/src/ConsoleInterface/Menu.cpp +++ b/src/ConsoleInterface/Menu.cpp @@ -1,5 +1,5 @@ #include "Menu.h" -#include "Toolbox.h" +#include "Toolbox.hpp" Menu::Menu(const Command* commands, unsigned commandCount) { menuOptions = List<Command>(commands, commandCount); diff --git a/src/ConsoleInterface/Menu.h b/src/ConsoleInterface/Menu.h index 0c0c915..f80636d 100644 --- a/src/ConsoleInterface/Menu.h +++ b/src/ConsoleInterface/Menu.h @@ -2,7 +2,7 @@ #define HEADER_CONSOLEINTERFACE_MENU #include "Command.h" -#include "../List/List.h" +#include "../List/List.hpp" class Menu { List<Command> menuOptions; diff --git a/src/ConsoleInterface/Toolbox.h b/src/ConsoleInterface/Toolbox.h deleted file mode 100644 index 8d13537..0000000 --- a/src/ConsoleInterface/Toolbox.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef HEADER_CONSOLEINTERFACE_TOOLBOX -#define HEADER_CONSOLEINTERFACE_TOOLBOX - -template <class T> -void read(T* storage); - -template <class T> -void read(T& storage); - -template <class T> -void print(const T* item); - -template <class T> -void printLine(const T* item); - -template <class T> -void print(const T& item); - -template <class T> -void printLine(const T& item); - -void printOrderedListElem(const char* message); -void resetOrderedList(int starter = 1); - -#endif diff --git a/src/ConsoleInterface/Toolbox.cpp b/src/ConsoleInterface/Toolbox.hpp index c42e0b2..1af42e2 100644 --- a/src/ConsoleInterface/Toolbox.cpp +++ b/src/ConsoleInterface/Toolbox.hpp @@ -1,4 +1,6 @@ -#include "Toolbox.h" +#ifndef HEADER_CONSOLEINTERFACE_TOOLBOX +#define HEADER_CONSOLEINTERFACE_TOOLBOX + #include <iostream> template <class T> @@ -38,6 +40,8 @@ void printOrderedListElem(const char* message) { printLine(message); } -void resetOrderedList(int starter) { +void resetOrderedList(int starter = 1) { orderedListIndex = starter; } + +#endif |
