add App& member to Module class

This commit is contained in:
2025-03-14 16:13:26 -05:00
parent e7286caa20
commit 2b1293d414
4 changed files with 13 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
#include "print.h"
Print::Print(void* h) {
handle = h;
Print::Print(void* h, App& a) : Module(h, a) {
name = "Print";
}
@@ -12,6 +11,6 @@ Print::~Print() {
void Print::run() {
std::cout << "Print lib loaded and run!\n";
//App::Get().unload(self);
App::Get().end();
app.end();
std::cout << "App::Get() called\n";
}

View File

@@ -3,14 +3,14 @@
class Print : public Module {
public:
Print(void*);
Print(void*, App&);
~Print();
void run();
};
extern "C" {
Module* create(void* handle) {
return new Print(handle);
Module* create(void* handle, App& app) {
return new Print(handle, app);
}
}

View File

@@ -63,7 +63,7 @@ void App::load(std::string lib) {
std::cout << "error finding create function in file: " << lib << std::endl;
}
Module* m = create(h);
Module* m = create(h, App::Get());
for(auto it = modules.begin(); it != modules.end(); it++) {

View File

@@ -3,13 +3,15 @@
#include "pch.hpp"
class App;
class Module {
public:
typedef Module* create_t(void*);
typedef Module* create_t(void*, App&);
typedef void* destroy_t(Module*);
Module(void* h, App& a) : handle(h), app(a) {};
virtual ~Module() {}
virtual void run() = 0;
std::string getName() const { return name; }
@@ -21,6 +23,9 @@ class Module {
std::string name;
void* handle;
std::list<Module*>::iterator self;
App& app;
};
#endif