48 lines
991 B
C++
48 lines
991 B
C++
#pragma once
|
|
|
|
#include "Delegate/Delegate.h"
|
|
|
|
#ifdef _WIN32
|
|
#define EXPORT __declspec(dllexport)
|
|
#elif __linux__
|
|
#define EXPORT
|
|
#else
|
|
#error message("Unknow platform")
|
|
#endif
|
|
/*
|
|
* This macro protects
|
|
* module callbacks from GB
|
|
*/
|
|
#define PROTECTION_FROM_GB(Class) \
|
|
extern "C" {\
|
|
EXPORT void* protect_init() {return reinterpret_cast<void*>(&InitModule);} \
|
|
EXPORT void* protect_start() {return reinterpret_cast<void*>(&StartModule);} \
|
|
EXPORT void* protect_quit() {return reinterpret_cast<void*>(&QuitModule);} \
|
|
}\
|
|
ModuleInstance* Factory() { return static_cast<ModuleInstance*>(new Class()); }
|
|
|
|
struct CoreCallBacks;
|
|
|
|
class ModuleInstance {
|
|
public:
|
|
Delegate<void> onStop;
|
|
|
|
virtual ~ModuleInstance() = default;
|
|
|
|
virtual void start();
|
|
void stop();
|
|
|
|
void QuitGame();
|
|
};
|
|
|
|
extern "C" {
|
|
// Create module instance
|
|
EXPORT void InitModule(CoreCallBacks* callbacks);
|
|
|
|
// Start module instance
|
|
EXPORT void StartModule();
|
|
|
|
// Stop module when core calls this
|
|
EXPORT void QuitModule();
|
|
}
|