Я пересоздал репозиторий из-за большого количества мусора в прошлом
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#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_stop() {return reinterpret_cast<void*>(&StopModule);} \
|
||||
EXPORT void* protect_quit() {return reinterpret_cast<void*>(&QuitModule);} \
|
||||
}\
|
||||
ModuleInstance* Factory(CoreInstance& core) { return static_cast<ModuleInstance*>(new Class(core)); }
|
||||
|
||||
|
||||
class CoreInstance;
|
||||
|
||||
class ModuleInstance {
|
||||
CoreInstance& core_;
|
||||
|
||||
public:
|
||||
Delegate<void> onStop;
|
||||
|
||||
ModuleInstance(CoreInstance& core);
|
||||
virtual ~ModuleInstance() = default;
|
||||
|
||||
CoreInstance& getCore() const { return core_; }
|
||||
|
||||
virtual void start();
|
||||
void stop();
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
// Create module instance
|
||||
EXPORT void InitModule(CoreInstance& core);
|
||||
|
||||
// Start module instance
|
||||
EXPORT void StartModule();
|
||||
|
||||
// Destroy module instance when core unloads there
|
||||
EXPORT void StopModule();
|
||||
|
||||
// Stop module when core calls this
|
||||
EXPORT void QuitModule();
|
||||
}
|
||||
Reference in New Issue
Block a user