44 lines
861 B
C++
44 lines
861 B
C++
#ifndef MODULE_H
|
|
#define MODULE_H
|
|
|
|
#include "pch.hpp"
|
|
|
|
namespace Archimedes {
|
|
|
|
class App;
|
|
|
|
class Module {
|
|
|
|
friend class App;
|
|
|
|
public:
|
|
|
|
typedef Module* create_t(void*, App*);
|
|
|
|
Module(void* h, App* a) : handle(h), app(a) {}
|
|
|
|
virtual ~Module() {}
|
|
|
|
virtual void run() = 0;
|
|
virtual void onLoad() = 0;
|
|
|
|
std::string getName() const { return name; }
|
|
void* getHandle() { return handle; }
|
|
|
|
std::any getData(std::string s) { return data[s.c_str()]; };
|
|
|
|
protected:
|
|
std::string name;
|
|
void* handle;
|
|
|
|
App* app;
|
|
|
|
std::unordered_map<std::string, std::variant<std::string, Module*>> deps;
|
|
std::unordered_map<std::string, Module*> depsInstances;
|
|
|
|
std::unordered_map<std::string, std::any> data;
|
|
};
|
|
}
|
|
|
|
#endif
|