add argc, argv to mana plugin init
This commit is contained in:
parent
81023bbde2
commit
f5fc1d49e7
4 changed files with 17 additions and 5 deletions
|
@ -286,7 +286,7 @@ struct ManaCountingSink: public IManaSink
|
|||
totalBytes = 0;
|
||||
}
|
||||
|
||||
void init() override {}
|
||||
void init(int, const char **) override {}
|
||||
void shutdown() override {}
|
||||
void begin_run(const char *descriptor_json) override
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C"
|
|||
size_t size_bytes;
|
||||
} mana_offset_array_t;
|
||||
|
||||
#define MANA_DEFINE_PLUGIN_INIT(name) void *name()
|
||||
#define MANA_DEFINE_PLUGIN_INIT(name) void *name(int plugin_argc, const char **plugin_argv)
|
||||
|
||||
#define MANA_DEFINE_PLUGIN_SHUTDOWN(name) void name(void *context)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "mana_c_api.h"
|
||||
#include <cassert>
|
||||
#include <mesytec-mnode/mnode_cpp_types.h>
|
||||
#include <mesytec-mnode/mnode_string.hpp>
|
||||
#include <mesytec-mvlc/cpp_compat.h>
|
||||
#include <mesytec-mvlc/util/data_filter.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
@ -131,7 +132,7 @@ class IManaSink
|
|||
public:
|
||||
virtual ~IManaSink() = default;
|
||||
|
||||
virtual void init() = 0;
|
||||
virtual void init(int plugin_argc, const char **plugin_argv) = 0;
|
||||
virtual void shutdown() = 0;
|
||||
virtual void begin_run(const char *descriptor_json) = 0;
|
||||
virtual void end_run(const char *descriptor_json) = 0;
|
||||
|
@ -140,6 +141,14 @@ class IManaSink
|
|||
|
||||
virtual void process_system_event(const uint32_t *data, size_t size) = 0;
|
||||
|
||||
template <typename StringHolder> void init(StringHolder args)
|
||||
{
|
||||
std::vector<const char *> cargs(args.size());
|
||||
std::transform(args.begin(), args.end(), cargs.begin(),
|
||||
[](const std::string &s) { return s.c_str(); });
|
||||
init(cargs.size(), cargs.data());
|
||||
}
|
||||
|
||||
protected:
|
||||
IManaSink() = default;
|
||||
|
||||
|
@ -159,7 +168,10 @@ struct ManaCSink: public IManaSink
|
|||
{
|
||||
}
|
||||
|
||||
void init() override { context_ = plugin_.init(); }
|
||||
void init(int plugin_argc, const char **plugin_argv) override
|
||||
{
|
||||
context_ = plugin_.init(plugin_argc, plugin_argv);
|
||||
}
|
||||
void shutdown() override { plugin_.shutdown(context_); }
|
||||
void begin_run(const char *descriptor_json) override
|
||||
{
|
||||
|
|
|
@ -481,7 +481,7 @@ int main(int argc, char *argv[])
|
|||
// make the analysis instance available to the parser callbacks
|
||||
parserContext->parser.userContext = &mana;
|
||||
|
||||
mana.sink->init();
|
||||
mana.sink->init(0, nullptr);
|
||||
mana.sink->begin_run(mana.runDescriptor.dump().c_str());
|
||||
|
||||
strategy->run(*listfileContext, *parserContext);
|
||||
|
|
Loading…
Reference in a new issue