update utils and plugin
This commit is contained in:
parent
bfe7257a5a
commit
65931a7ffa
2
external/solanaceae_util
vendored
2
external/solanaceae_util
vendored
@ -1 +1 @@
|
||||
Subproject commit 92eee153f2c14f97e50f44b10e2a0aeb5f8b190d
|
||||
Subproject commit 17d2baf7365c3499172dc5afd71171cb3a138d99
|
@ -4,6 +4,10 @@ add_library(plugin_clamav SHARED
|
||||
./plugin_clamav_module.cpp
|
||||
)
|
||||
target_compile_features(plugin_clamav PUBLIC cxx_std_17)
|
||||
set_target_properties(plugin_clamav PROPERTIES
|
||||
C_VISIBILITY_PRESET hidden
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
)
|
||||
target_link_libraries(plugin_clamav PUBLIC
|
||||
solanaceae_clamav
|
||||
solanaceae_plugin
|
||||
|
@ -4,17 +4,17 @@
|
||||
#include <solanaceae/util/config_model.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
||||
#define RESOLVE_INSTANCE(x) static_cast<x*>(solana_api->resolveInstance(#x))
|
||||
#define PROVIDE_INSTANCE(x, p, v) solana_api->provideInstance(#x, p, static_cast<x*>(v))
|
||||
|
||||
static std::unique_ptr<ClamAVModule> g_cavm = nullptr;
|
||||
|
||||
constexpr const char* plugin_name = "ClamAVModule";
|
||||
|
||||
extern "C" {
|
||||
|
||||
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
|
||||
return "ClamAVModule";
|
||||
return plugin_name;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
|
||||
@ -22,43 +22,40 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) {
|
||||
std::cout << "PLUGIN CAVM START()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " START()\n";
|
||||
|
||||
if (solana_api == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
ConfigModelI* conf = nullptr;
|
||||
try {
|
||||
auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI);
|
||||
|
||||
{ // make sure required types are loaded
|
||||
conf = RESOLVE_INSTANCE(ConfigModelI);
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_cavm = std::make_unique<ClamAVModule>(*conf);
|
||||
|
||||
if (conf == nullptr) {
|
||||
std::cerr << "PLUGIN CAVM missing ConfigModelI\n";
|
||||
return 2;
|
||||
}
|
||||
// register types
|
||||
PLUG_PROVIDE_INSTANCE(ClamAVModule, plugin_name, g_cavm.get());
|
||||
} catch (const ResolveException& e) {
|
||||
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_cavm = std::make_unique<ClamAVModule>(*conf);
|
||||
|
||||
// register types
|
||||
PROVIDE_INSTANCE(ClamAVModule, "ClamAVModule", g_cavm.get());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
|
||||
std::cout << "PLUGIN CAVM STOP()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
|
||||
|
||||
g_cavm.reset();
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT void solana_plugin_tick(float delta) {
|
||||
SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float delta) {
|
||||
(void)delta;
|
||||
//std::cout << "PLUGIN CAVM TICK()\n";
|
||||
//g_cavm->iterate();
|
||||
return std::numeric_limits<float>::max();
|
||||
}
|
||||
|
||||
} // extern C
|
||||
|
Loading…
Reference in New Issue
Block a user