diff --git a/src/App.cpp b/src/App.cpp index 8d9a5f1..35a255b 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -71,10 +71,10 @@ void App::load(std::string lib) { } modules.push_back(m); - m->setSelf(modules.rbegin()); + m->setSelf(modules.rbegin().base()); } -void App::unload(std::list::iterator it) { +void App::unload(decltype(Module::self) it) { void* handle = (*it)->getHandle(); delete *it; dlclose(handle); diff --git a/src/App.h b/src/App.h index b8d75f9..cd5d378 100644 --- a/src/App.h +++ b/src/App.h @@ -24,7 +24,7 @@ class App { void load(std::string); - void unload(std::list::iterator); + void unload(decltype(Module::self)); void handleArgs(const int&, char*[]); diff --git a/src/Module.h b/src/Module.h index 5a9615f..491daea 100644 --- a/src/Module.h +++ b/src/Module.h @@ -7,6 +7,8 @@ class App; class Module { + friend class App; + public: typedef Module* create_t(void*, App&); typedef void* destroy_t(Module*); @@ -17,12 +19,12 @@ class Module { std::string getName() const { return name; } void* getHandle() { return handle; } - void setSelf(std::list::reverse_iterator s) { self = s; } + void setSelf(std::list::iterator s) { self = s; } protected: std::string name; void* handle; - std::list::reverse_iterator self; + std::list::iterator self; App& app;