work on testMenu
This commit is contained in:
36
src/App.cpp
36
src/App.cpp
@@ -25,14 +25,44 @@ App::~App() {
|
||||
void App::run() {
|
||||
std::cout << "\nTesting...\n";
|
||||
|
||||
done = modules.empty();
|
||||
|
||||
// Main loop
|
||||
while (!done) {
|
||||
end();
|
||||
|
||||
for(auto it = modules.begin(); it != modules.end(); it++)
|
||||
(*it)->run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void App::load(std::string lib) {
|
||||
|
||||
void* handle = dlopen(lib.c_str(), RTLD_LAZY);
|
||||
|
||||
if(!handle) {
|
||||
std::cout << "could not open lib!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
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() != "") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::handleArgs(const int& argc, char* argv[]) {
|
||||
@@ -56,3 +86,7 @@ void App::handleArgs(const int& argc, char* argv[]) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void App::printHelp() {
|
||||
std::cout << "archimedes [ -h | --help ] /path/to/some/library.so\n";
|
||||
}
|
||||
|
||||
@@ -6,12 +6,17 @@
|
||||
class Module {
|
||||
|
||||
public:
|
||||
typedef Module* create_t();
|
||||
typedef Module* create_t(void*);
|
||||
typedef void destroy_t(Module*);
|
||||
|
||||
|
||||
virtual ~Module() {}
|
||||
virtual void run() = 0;
|
||||
std::string getName() const { return name; }
|
||||
|
||||
protected:
|
||||
std::string name;
|
||||
void* handle;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user