2023-05-23 02:06:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define SOLANA_PLUGIN_HOST
|
|
|
|
#include <solanaceae/plugin/solana_plugin_v1.h>
|
|
|
|
|
|
|
|
#include <solanaceae/plugin/plugin.hpp>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// TODO: save plug name to instance
|
2024-01-18 00:26:18 +01:00
|
|
|
// id -> version -> ptr
|
|
|
|
extern std::map<std::string, std::map<std::string, void*>> g_instance_map;
|
2023-05-23 02:06:58 +02:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
2024-01-18 00:26:18 +01:00
|
|
|
void* g_resolveInstance__internal(const char* id, const char* version);
|
2023-05-23 02:06:58 +02:00
|
|
|
|
2024-01-18 00:26:18 +01:00
|
|
|
void g_provideInstance__internal(const char* id, const char* version, const char* plugin_name, void* instance);
|
2023-05-23 02:06:58 +02:00
|
|
|
|
|
|
|
} // extern C
|
|
|
|
|
2024-01-18 18:23:24 +01:00
|
|
|
#include "./version_helper.inl"
|
2024-01-18 00:26:18 +01:00
|
|
|
|
2023-05-23 02:06:58 +02:00
|
|
|
// templated helper, use or make sure vtable is right
|
2024-01-18 00:26:18 +01:00
|
|
|
template<typename T>
|
|
|
|
void g_provideInstance(const char* id, const char* version, const char* plugin_name, T* instance) {
|
|
|
|
g_provideInstance__internal(id, version, plugin_name, instance);
|
|
|
|
}
|
|
|
|
|
2023-05-23 02:06:58 +02:00
|
|
|
template<typename T>
|
|
|
|
void g_provideInstance(const char* id, const char* plugin_name, T* instance) {
|
2024-01-18 00:26:18 +01:00
|
|
|
g_provideInstance__internal(id, internal::g_type_version<T>::version, plugin_name, instance);
|
2023-05-23 02:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// only on host!
|
|
|
|
struct PluginManager {
|
|
|
|
SolanaAPI _sapi {
|
|
|
|
&g_resolveInstance__internal,
|
|
|
|
&g_provideInstance__internal,
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<Plugin> _plugins;
|
|
|
|
|
|
|
|
~PluginManager(void);
|
|
|
|
|
|
|
|
bool add(const std::string& plug_path);
|
|
|
|
|
2024-01-07 14:37:33 +01:00
|
|
|
// returns the minimum time until next call is wanted in seconds
|
|
|
|
float tick(float delta);
|
|
|
|
float render(float delta);
|
2023-05-23 02:06:58 +02:00
|
|
|
};
|
|
|
|
|