45 lines
986 B
C++
45 lines
986 B
C++
#ifndef MODULE_H
|
|
#define MODULE_H
|
|
|
|
#include "pch.hpp"
|
|
|
|
namespace Archimedes {
|
|
|
|
class App;
|
|
|
|
class Module {
|
|
|
|
friend class App;
|
|
|
|
static std::list<std::string*> modules;
|
|
|
|
public:
|
|
typedef Module* create_t(void*, App*);
|
|
|
|
static std::list<std::string*>& GetModules() { return modules; }
|
|
|
|
Module(void* h, App* a) : handle(h), app(a) { modules.push_back(&name); }
|
|
|
|
virtual ~Module() { modules.remove_if([this](std::string* s) -> bool { return s ? *s == name : false; }); }
|
|
|
|
virtual void run() = 0;
|
|
virtual void onLoad() = 0;
|
|
|
|
std::string getName() const { return name; }
|
|
void* getHandle() { return handle; }
|
|
|
|
void setSelf(std::list<Module*>::iterator s) { self = s; }
|
|
|
|
protected:
|
|
std::string name;
|
|
void* handle;
|
|
std::list<Module*>::iterator self;
|
|
|
|
App* app;
|
|
|
|
std::unordered_map<std::string, std::string> deps;
|
|
};
|
|
}
|
|
|
|
#endif
|