2021-04-22 04:15:23 +02:00
|
|
|
#pragma once
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <mutex>
|
|
|
|
|
|
|
|
struct ModuleComInterface {
|
|
|
|
std::string moduleName;
|
|
|
|
void* ctx;
|
|
|
|
void (*handler)(int code, void* in, void* out, void* ctx);
|
|
|
|
};
|
|
|
|
|
|
|
|
class ModuleComManager {
|
|
|
|
public:
|
|
|
|
bool registerInterface(std::string moduleName, std::string name, void (*handler)(int code, void* in, void* out, void* ctx), void* ctx);
|
|
|
|
bool unregisterInterface(std::string name);
|
|
|
|
bool interfaceExists(std::string name);
|
|
|
|
std::string getModuleName(std::string name);
|
|
|
|
bool callInterface(std::string name, int code, void* in, void* out);
|
|
|
|
|
|
|
|
private:
|
2023-09-29 14:42:45 +02:00
|
|
|
std::recursive_mutex mtx;
|
2021-04-22 04:15:23 +02:00
|
|
|
std::map<std::string, ModuleComInterface> interfaces;
|
|
|
|
};
|