<commit_before>﻿#include "PluginService.h"
#include "Stream.h"
#include "SenseKitContext.h"
#include "PluginServiceDelegate.h"
#include <SenseKit/Plugins/PluginServiceProxyBase.h>
#include <SenseKit/sensekit_types.h>
#include "StreamRegisteredEventArgs.h"
#include "StreamUnregisteringEventArgs.h"
#include "CreatePluginProxy.h"
#include "ParameterBin.h"
#include "Logging.h"
#include <cstdio>
#include <memory>

namespace sensekit
{
    PluginServiceProxyBase* PluginService::create_proxy()
    {
        return create_plugin_proxy(this);
    }

    void PluginService::notify_host_event(sensekit_event_id id, const void* data, size_t dataSize)
    {
        m_hostEventSignal.raise(id, data, dataSize);
    }

    sensekit_status_t PluginService::create_stream_set(const char* streamUri, sensekit_streamset_t& streamSet)
    {
        StreamSet& set = m_context.get_setCatalog().get_or_add(streamUri, true);
        streamSet = set.get_handle();

        SINFO("PluginService", "creating streamset: %s %x", streamUri, streamSet);

        return SENSEKIT_STATUS_SUCCESS;
    }

    sensekit_status_t PluginService::destroy_stream_set(sensekit_streamset_t& streamSet)
    {
        StreamSet* actualSet = StreamSet::get_ptr(streamSet);

        SINFO("PluginService", "destroying streamset: %s %x", actualSet->get_uri().c_str(), streamSet);
        m_context.get_setCatalog().destroy_set(actualSet);

        streamSet = nullptr;

        return SENSEKIT_STATUS_SUCCESS;
    }

    sensekit_status_t PluginService::register_stream_registered_callback(stream_registered_callback_t callback,
                                                                    void* clientTag,
                                                                    CallbackId& callbackId)
    {
        auto thunk = [clientTag, callback](StreamRegisteredEventArgs args)
            {
                callback(clientTag,
                         args.streamSet->get_handle(),
                         args.stream->get_handle(),
                         args.description);
            };

        m_context.get_setCatalog().register_for_stream_registered_event(thunk);

        return SENSEKIT_STATUS_SUCCESS;
    }

    sensekit_status_t PluginService::register_stream_unregistering_callback(stream_unregistering_callback_t callback,
                                                                       void* clientTag,
                                                                       CallbackId& callbackId)
    {
        auto thunk = [clientTag, callback](StreamUnregisteringEventArgs args)
            {
                callback(clientTag,
                         args.streamSet->get_handle(),
                         args.stream->get_handle(),
                         args.description);
            };

        m_context.get_setCatalog().register_for_stream_unregistering_event(thunk);

        return SENSEKIT_STATUS_SUCCESS;
    }<commit_msg>Fixes unreturned callback ids in PluginService<commit_after>﻿#include "PluginService.h"
#include "Stream.h"
#include "SenseKitContext.h"
#include "PluginServiceDelegate.h"
#include <SenseKit/Plugins/PluginServiceProxyBase.h>
#include <SenseKit/sensekit_types.h>
#include "StreamRegisteredEventArgs.h"
#include "StreamUnregisteringEventArgs.h"
#include "CreatePluginProxy.h"
#include "ParameterBin.h"
#include "Logging.h"
#include <cstdio>
#include <memory>

namespace sensekit
{
    PluginServiceProxyBase* PluginService::create_proxy()
    {
        return create_plugin_proxy(this);
    }

    void PluginService::notify_host_event(sensekit_event_id id, const void* data, size_t dataSize)
    {
        m_hostEventSignal.raise(id, data, dataSize);
    }

    sensekit_status_t PluginService::create_stream_set(const char* streamUri, sensekit_streamset_t& streamSet)
    {
        StreamSet& set = m_context.get_setCatalog().get_or_add(streamUri, true);
        streamSet = set.get_handle();

        SINFO("PluginService", "creating streamset: %s %x", streamUri, streamSet);

        return SENSEKIT_STATUS_SUCCESS;
    }

    sensekit_status_t PluginService::destroy_stream_set(sensekit_streamset_t& streamSet)
    {
        StreamSet* actualSet = StreamSet::get_ptr(streamSet);

        SINFO("PluginService", "destroying streamset: %s %x", actualSet->get_uri().c_str(), streamSet);
        m_context.get_setCatalog().destroy_set(actualSet);

        streamSet = nullptr;

        return SENSEKIT_STATUS_SUCCESS;
    }

    sensekit_status_t PluginService::register_stream_registered_callback(stream_registered_callback_t callback,
                                                                    void* clientTag,
                                                                    CallbackId& callbackId)
    {
        auto thunk = [clientTag, callback](StreamRegisteredEventArgs args)
            {
                callback(clientTag,
                         args.streamSet->get_handle(),
                         args.stream->get_handle(),
                         args.description);
            };

        callbackId = m_context.get_setCatalog().register_for_stream_registered_event(thunk);

        return SENSEKIT_STATUS_SUCCESS;
    }

    sensekit_status_t PluginService::register_stream_unregistering_callback(stream_unregistering_callback_t callback,
                                                                       void* clientTag,
                                                                       CallbackId& callbackId)
    {
        auto thunk = [clientTag, callback](StreamUnregisteringEventArgs args)
            {
                callback(clientTag,
                         args.streamSet->get_handle(),
                         args.stream->get_handle(),
                         args.description);
            };

        callbackId = m_context.get_setCatalog().register_for_stream_unregistering_event(thunk);

        return SENSEKIT_STATUS_SUCCESS;
    }
{'fraction_non_alphanumeric': 0.08562278779706725, 'fraction_numerical': 0.0, 'mean_word_length': 2.24617067833698, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1660838', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1550, 'n_words': 247}