better mana c api entry point definition

This commit is contained in:
Florian Lüke 2024-12-27 17:34:02 +01:00
parent bbd52cbde0
commit c82671490a
6 changed files with 31 additions and 6 deletions

View file

@ -37,6 +37,7 @@ if (ROOT_FOUND)
include(${ROOT_USE_FILE}) include(${ROOT_USE_FILE})
add_library(mana-plugin-root-histogram SHARED mana_plugin_root_histogram.cc) add_library(mana-plugin-root-histogram SHARED mana_plugin_root_histogram.cc)
target_link_libraries(mana-plugin-root-histogram PRIVATE mana mesytec-mnode rxi-logc ${ROOT_LIBRARIES}) target_link_libraries(mana-plugin-root-histogram PRIVATE mana mesytec-mnode rxi-logc ${ROOT_LIBRARIES})
target_compile_options(mana-plugin-root-histogram PRIVATE -DLOG_USE_COLOR)
endif() endif()
if (pybind11_FOUND) if (pybind11_FOUND)

View file

@ -65,9 +65,9 @@ extern "C"
mana_process_system_event_t *process_system_event; mana_process_system_event_t *process_system_event;
} mana_sink_plugin_t; } mana_sink_plugin_t;
// plugins need to define this function with the name 'mana_get_sink_plugin' // use this to define the entry point into the plugin
#define MANA_DEFINE_GET_PLUGIN(name) mana_sink_plugin_t name() // from c++: extern "C" MANA_C_SINK_PLUGIN() { ... return plugin; }
typedef MANA_DEFINE_GET_PLUGIN(mana_get_sink_plugin_t); #define MANA_C_SINK_PLUGIN mana_sink_plugin_t mana_get_sink_plugin
#ifdef __cplusplus #ifdef __cplusplus
} }

24
src/internal/mana_nng.h Normal file
View file

@ -0,0 +1,24 @@
#ifndef CF5E5AFF_F218_4A25_95DF_8097D7C5685B
#define CF5E5AFF_F218_4A25_95DF_8097D7C5685B
#include "mana_analysis.h"
#include <mesytec-mnode/mnode_nng.h>
namespace mesytec::mnode::mana
{
class NngServer: public IManaSink
{
public:
explicit NngServer(nng_socket socket)
: socket_(socket)
{
}
private:
nng_socket socket_;
};
} // namespace mesytec::mnode::mana
#endif /* CF5E5AFF_F218_4A25_95DF_8097D7C5685B */

View file

@ -44,7 +44,7 @@ MANA_DEFINE_PLUGIN_SYSTEM_EVENT(process_system_event)
log_debug("system_event: ctx=%p, size=%zu", context, size); log_debug("system_event: ctx=%p, size=%zu", context, size);
} }
MANA_DEFINE_GET_PLUGIN(mana_get_sink_plugin) MANA_C_SINK_PLUGIN()
{ {
mana_sink_plugin_t plugin; mana_sink_plugin_t plugin;
plugin.init = init; plugin.init = init;

View file

@ -95,7 +95,7 @@ MANA_DEFINE_PLUGIN_SYSTEM_EVENT(process_system_event)
auto ctx = reinterpret_cast<Context *>(context); auto ctx = reinterpret_cast<Context *>(context);
} }
extern "C" MANA_DEFINE_GET_PLUGIN(mana_get_plugin) extern "C" MANA_C_SINK_PLUGIN()
{ {
mana_sink_plugin_t plugin; mana_sink_plugin_t plugin;
plugin.init = init; plugin.init = init;

View file

@ -219,7 +219,7 @@ MANA_DEFINE_PLUGIN_SYSTEM_EVENT(process_system_event)
log_trace("system_event: ctx=%p, size=%zu", context, size); log_trace("system_event: ctx=%p, size=%zu", context, size);
} }
extern "C" MANA_DEFINE_GET_PLUGIN(mana_get_sink_plugin) extern "C" MANA_C_SINK_PLUGIN()
{ {
mana_sink_plugin_t plugin; mana_sink_plugin_t plugin;
plugin.init = init; plugin.init = init;