update to new versioned plugin api
This commit is contained in:
parent
a488a255ff
commit
998794a6dd
2
external/CMakeLists.txt
vendored
2
external/CMakeLists.txt
vendored
@ -13,7 +13,7 @@ endif()
|
||||
if (NOT TARGET imgui)
|
||||
FetchContent_Declare(imgui
|
||||
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
||||
GIT_TAG d4ddc46e7
|
||||
GIT_TAG d6cb3c9 # v1.90.1
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
|
@ -2,21 +2,19 @@
|
||||
|
||||
#include <solanaceae/crdtnotes/crdtnotes.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
//#include <solanaceae/util/config_model.hpp>
|
||||
|
||||
#include <memory>
|
||||
#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<CRDTNotes> g_crdtn = nullptr;
|
||||
static std::unique_ptr<CRDTNotesSync> g_crdtns = nullptr;
|
||||
|
||||
constexpr const char* plugin_name = "CRDTNotes";
|
||||
|
||||
extern "C" {
|
||||
|
||||
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
|
||||
return "CRDTNotes";
|
||||
return plugin_name;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
|
||||
@ -24,29 +22,14 @@ 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 CRDTN START()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " START()\n";
|
||||
|
||||
if (solana_api == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//ConfigModelI* conf = nullptr;
|
||||
Contact3Registry* cr = nullptr;
|
||||
|
||||
{ // make sure required types are loaded
|
||||
//conf = RESOLVE_INSTANCE(ConfigModelI);
|
||||
cr = RESOLVE_INSTANCE(Contact3Registry);
|
||||
|
||||
//if (conf == nullptr) {
|
||||
//std::cerr << "PLUGIN CRDTN missing ConfigModelI\n";
|
||||
//return 2;
|
||||
//}
|
||||
|
||||
if (cr == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing Contact3Registry\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
try {
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
@ -54,14 +37,18 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
g_crdtns = std::make_unique<CRDTNotesSync>(*g_crdtn, *cr);
|
||||
|
||||
// register types
|
||||
PROVIDE_INSTANCE(CRDTNotesSync, "CRDTNotes", g_crdtns.get());
|
||||
PROVIDE_INSTANCE(CRDTNotesEventI, "CRDTNotes", g_crdtns.get());
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesSync, plugin_name, g_crdtns.get());
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesEventI, plugin_name, g_crdtns.get());
|
||||
} catch (const ResolveException& e) {
|
||||
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
|
||||
std::cout << "PLUGIN CRDTN STOP()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
|
||||
|
||||
g_crdtn.reset();
|
||||
g_crdtns.reset();
|
||||
|
@ -1,22 +1,20 @@
|
||||
#include <solanaceae/plugin/solana_plugin_v1.h>
|
||||
|
||||
#include <solanaceae/crdtnotes_imgui/crdtnotes_imgui.hpp>
|
||||
//#include <solanaceae/util/config_model.hpp>
|
||||
#include <imgui.h>
|
||||
|
||||
#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<CRDTNotesImGui> g_crdtn_imgui = nullptr;
|
||||
|
||||
constexpr const char* plugin_name = "CRDTNotesImGui";
|
||||
|
||||
extern "C" {
|
||||
|
||||
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
|
||||
return "CRDTNIMGUIotesImGui";
|
||||
return plugin_name;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
|
||||
@ -24,43 +22,16 @@ 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 CRDTNIMGUI START()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " START()\n";
|
||||
|
||||
if (solana_api == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//ConfigModelI* conf = nullptr;
|
||||
CRDTNotesSync* crdtns = nullptr;
|
||||
Contact3Registry* cr = nullptr;
|
||||
ImGuiContext* imguic = nullptr;
|
||||
|
||||
{ // make sure required types are loaded
|
||||
//conf = RESOLVE_INSTANCE(ConfigModelI);
|
||||
crdtns = RESOLVE_INSTANCE(CRDTNotesSync);
|
||||
cr = RESOLVE_INSTANCE(Contact3Registry);
|
||||
imguic = RESOLVE_INSTANCE(ImGuiContext);
|
||||
|
||||
//if (conf == nullptr) {
|
||||
//std::cerr << "PLUGIN CRDTNIMGUI missing ConfigModelI\n";
|
||||
//return 2;
|
||||
//}
|
||||
|
||||
if (crdtns == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNIMGUI missing CRDTNotesSync\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (cr == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNIMGUI missing Contact3Registry\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (imguic == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNIMGUI missing ImGuiContext\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
try {
|
||||
auto* crdtns = PLUG_RESOLVE_INSTANCE(CRDTNotesSync);
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
auto* imguic = PLUG_RESOLVE_INSTANCE_VERSIONED(ImGuiContext, ImGui::GetVersion());
|
||||
|
||||
ImGui::SetCurrentContext(imguic);
|
||||
|
||||
@ -69,13 +40,17 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
g_crdtn_imgui = std::make_unique<CRDTNotesImGui>(*crdtns, *cr);
|
||||
|
||||
// register types
|
||||
PROVIDE_INSTANCE(CRDTNotesImGui, "CRDTNotesImGui", g_crdtn_imgui.get());
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesImGui, plugin_name, g_crdtn_imgui.get());
|
||||
} catch (const ResolveException& e) {
|
||||
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
|
||||
std::cout << "PLUGIN CRDTNIMGUI STOP()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
|
||||
|
||||
g_crdtn_imgui.reset();
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <solanaceae/crdtnotes/crdtnotes.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
#include <solanaceae/crdtnotes_toxsync/crdtnotes_toxsync.hpp>
|
||||
//#include <solanaceae/util/config_model.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||
@ -12,15 +11,14 @@
|
||||
#include <memory>
|
||||
#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<CRDTNotesToxSync> g_crdtn_ts = nullptr;
|
||||
|
||||
constexpr const char* plugin_name = "CRDTNotesToxSync";
|
||||
|
||||
extern "C" {
|
||||
|
||||
SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) {
|
||||
return "CRDTNotesToxSync";
|
||||
return plugin_name;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) {
|
||||
@ -28,70 +26,35 @@ 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 CRDTNTS START()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " START()\n";
|
||||
|
||||
if (solana_api == nullptr) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//ConfigModelI* conf = nullptr;
|
||||
CRDTNotesEventI* notes_sync = nullptr;
|
||||
Contact3Registry* cr = nullptr;
|
||||
ToxI* t = nullptr;
|
||||
ToxEventProviderI* tep = nullptr;
|
||||
ToxContactModel2* tcm = nullptr;
|
||||
|
||||
{ // make sure required types are loaded
|
||||
//conf = RESOLVE_INSTANCE(ConfigModelI);
|
||||
notes_sync = RESOLVE_INSTANCE(CRDTNotesEventI);
|
||||
cr = RESOLVE_INSTANCE(Contact3Registry);
|
||||
t = RESOLVE_INSTANCE(ToxI);
|
||||
tep = RESOLVE_INSTANCE(ToxEventProviderI);
|
||||
tcm = RESOLVE_INSTANCE(ToxContactModel2);
|
||||
|
||||
//if (conf == nullptr) {
|
||||
//std::cerr << "PLUGIN CRDTN missing ConfigModelI\n";
|
||||
//return 2;
|
||||
//}
|
||||
|
||||
if (notes_sync == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing CRDTNotesEventI\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (cr == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing Contact3Registry\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (t == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing ToxI\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tep == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing ToxEventProviderI\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tcm == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing ToxContactModel2\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
try {
|
||||
auto* notes_sync = PLUG_RESOLVE_INSTANCE(CRDTNotesEventI);
|
||||
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||
auto* t = PLUG_RESOLVE_INSTANCE(ToxI);
|
||||
auto* tep = PLUG_RESOLVE_INSTANCE(ToxEventProviderI);
|
||||
auto* tcm = PLUG_RESOLVE_INSTANCE(ToxContactModel2);
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_crdtn_ts = std::make_unique<CRDTNotesToxSync>(*notes_sync, *cr, *t, *tep, *tcm);
|
||||
|
||||
// register types
|
||||
PROVIDE_INSTANCE(CRDTNotesToxSync, "CRDTNotesToxSync", g_crdtn_ts.get());
|
||||
PLUG_PROVIDE_INSTANCE(CRDTNotesToxSync, plugin_name, g_crdtn_ts.get());
|
||||
} catch (const ResolveException& e) {
|
||||
std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
|
||||
std::cout << "PLUGIN CRDTNTS STOP()\n";
|
||||
std::cout << "PLUGIN " << plugin_name << " STOP()\n";
|
||||
|
||||
g_crdtn_ts.reset();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user