#include "internal/mana_api.hpp"
#include "internal/rxi/log.hpp"

using namespace mesytec::mnode;
using namespace mesytec::mnode::mana;

class Sink: public IManaSink
{
  public:
    Sink()
    {
        log_set_level(LOG_INFO);
        log_info("init: this=%p", this);
    }

    void begin_run(const char *descriptor_json) override
    {
        (void)descriptor_json;
        log_info("begin_run: this=%p", this);
    }

    void end_run(const char *descriptor_json) override
    {
        (void)descriptor_json;
        log_info("end_run: this=%p", this);
    }

    void process_event(uint16_t eventIndex, mana_offset_array_t *arrays, size_t arrayCount,
                       size_t totalBytes) override
    {
        log_trace("event: this=%p, eventIndex=%d, arrayCount=%zu, totalBytes=%zu", this, eventIndex,
                  arrayCount, totalBytes);
    }

    void process_system_event(const uint32_t *data, size_t size) override
    {
        log_debug("system_event: this=%p, size=%zu", this, size);
    }
};

class Plugin: public IManaPlugin
{
  public:
    std::unique_ptr<IManaSink> makeSink() override { return std::make_unique<Sink>(); }
};

MANA_CPP_PLUGIN() { return new Plugin; }
