now trying to build
This commit is contained in:
20
src/App.cpp
20
src/App.cpp
@@ -50,23 +50,23 @@ void App::load(std::string lib) {
|
||||
}
|
||||
|
||||
Module::create_t* create = (Module::create_t*) dlsym(handle, "create");
|
||||
|
||||
if(dlerror()) {
|
||||
std::cout << "error finding create function in file: " << lib << std::endl;
|
||||
}
|
||||
|
||||
Module::destroy_t* destroy = (Module::destroy_t*) dlsym(handle, "destroy");
|
||||
if(dlerror()) {
|
||||
std::cout << "error finding destroy function in file: " << lib << std::endl;
|
||||
}
|
||||
|
||||
Module* m = create(handle);
|
||||
|
||||
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||
|
||||
if((*it)->getName() != "") {
|
||||
|
||||
if((*it)->getName() != m->getName()) {
|
||||
std::cout << "Module \"" << m->getName() << "\" is already loaded!\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m->setSelf(modules.end());
|
||||
modules.push_back(m);
|
||||
}
|
||||
|
||||
void App::unload(std::list<Module*>::iterator it) {
|
||||
@@ -78,15 +78,15 @@ void App::unload(std::list<Module*>::iterator it) {
|
||||
|
||||
void App::handleArgs(const int& argc, char* argv[]) {
|
||||
|
||||
int i = 0;
|
||||
int i = 1;
|
||||
|
||||
if(argc == 0) {
|
||||
if(argc == 1) {
|
||||
printHelp();
|
||||
end();
|
||||
}
|
||||
|
||||
while(i < argc) {
|
||||
if(strcmp(argv[i], "-h") == 0) {
|
||||
if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||
printHelp();
|
||||
end();
|
||||
} else {
|
||||
|
||||
@@ -14,6 +14,8 @@ class Module {
|
||||
virtual void run() = 0;
|
||||
std::string getName() const { return name; }
|
||||
void* getHandle() { return handle; }
|
||||
|
||||
void setSelf(std::list<Module*>::iterator s) { self = s; }
|
||||
|
||||
protected:
|
||||
std::string name;
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
|
||||
//#include <chrono>
|
||||
//#include <thread>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user