add App& member to Module class
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
|
||||||
Print::Print(void* h) {
|
Print::Print(void* h, App& a) : Module(h, a) {
|
||||||
handle = h;
|
|
||||||
name = "Print";
|
name = "Print";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,6 +11,6 @@ Print::~Print() {
|
|||||||
void Print::run() {
|
void Print::run() {
|
||||||
std::cout << "Print lib loaded and run!\n";
|
std::cout << "Print lib loaded and run!\n";
|
||||||
//App::Get().unload(self);
|
//App::Get().unload(self);
|
||||||
App::Get().end();
|
app.end();
|
||||||
std::cout << "App::Get() called\n";
|
std::cout << "App::Get() called\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
class Print : public Module {
|
class Print : public Module {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Print(void*);
|
Print(void*, App&);
|
||||||
~Print();
|
~Print();
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
Module* create(void* handle) {
|
Module* create(void* handle, App& app) {
|
||||||
return new Print(handle);
|
return new Print(handle, app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void App::load(std::string lib) {
|
|||||||
std::cout << "error finding create function in file: " << lib << std::endl;
|
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++) {
|
for(auto it = modules.begin(); it != modules.end(); it++) {
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
#include "pch.hpp"
|
#include "pch.hpp"
|
||||||
|
|
||||||
|
class App;
|
||||||
|
|
||||||
class Module {
|
class Module {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Module* create_t(void*);
|
typedef Module* create_t(void*, App&);
|
||||||
typedef void* destroy_t(Module*);
|
typedef void* destroy_t(Module*);
|
||||||
|
|
||||||
|
Module(void* h, App& a) : handle(h), app(a) {};
|
||||||
virtual ~Module() {}
|
virtual ~Module() {}
|
||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
std::string getName() const { return name; }
|
std::string getName() const { return name; }
|
||||||
@@ -21,6 +23,9 @@ class Module {
|
|||||||
std::string name;
|
std::string name;
|
||||||
void* handle;
|
void* handle;
|
||||||
std::list<Module*>::iterator self;
|
std::list<Module*>::iterator self;
|
||||||
|
|
||||||
|
App& app;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user