added more App functions
This commit is contained in:
29
src/App.cpp
29
src/App.cpp
@@ -2,7 +2,7 @@
|
||||
|
||||
App* App::instance = nullptr;
|
||||
|
||||
App::App() {
|
||||
App::App(const int& argc, char* argv[]) {
|
||||
|
||||
if(instance != nullptr) {
|
||||
std::cout << "App already exists\nThere can only be one!\n";
|
||||
@@ -13,6 +13,8 @@ App::App() {
|
||||
|
||||
instance = this;
|
||||
|
||||
handleArgs(argc, argv);
|
||||
|
||||
}
|
||||
|
||||
App::~App() {
|
||||
@@ -29,3 +31,28 @@ void App::run() {
|
||||
}
|
||||
}
|
||||
|
||||
void App::load(std::string lib) {
|
||||
|
||||
}
|
||||
|
||||
void App::handleArgs(const int& argc, char* argv[]) {
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(i < argc) {
|
||||
if(strcmp(argv[i], "-h") == 0) {
|
||||
printHelp();
|
||||
end();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
while(i < argc) {
|
||||
|
||||
load(argv[i]);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,19 @@ class App {
|
||||
std::vector<Module*> modules;
|
||||
|
||||
public:
|
||||
App();
|
||||
App(const int&, char*[]);
|
||||
~App();
|
||||
|
||||
static App& Get() { return *instance; }
|
||||
|
||||
void run();
|
||||
|
||||
void load(std::string);
|
||||
|
||||
void handleArgs(const int&, char*[]);
|
||||
|
||||
void printHelp();
|
||||
|
||||
void end() { done = true; };
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
#include "App.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
App app;
|
||||
App app(argc, argv);
|
||||
app.run();
|
||||
}
|
||||
|
||||
@@ -5,4 +5,6 @@
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user