<commit_before>#ifndef SINGLEBINSTREAM_H
#define SINGLEBINSTREAM_H

#include "Stream.h"

namespace sensekit { namespace plugins {

        template<typename TFrameType, typename TBlockType>
        class SingleBinStream : public Stream
        {
        public:

            SingleBinStream(PluginServiceProxy& pluginService,
                            Sensor& streamSet,
                            StreamDescription description,
                            size_t bufferSize)
                : Stream(pluginService,
                         streamSet,
                         description)
                {
                    create_bin(sizeof(TFrameType) + bufferSize, m_binHandle, m_frame);
                }

            using frame_type = TFrameType;
            using block_type = TBlockType;

            bool has_connections()
                {
                    if (m_binHandle == nullptr)
                        return false;

                    return bin_has_connections(m_binHandle);
                }

            frame_type* begin_write(size_t frameIndex)
                {
                    if (m_locked)
                        return reinterpret_cast<TFrameType*>(m_frame->data);

                    m_locked = true;
                    m_frame->frameIndex = frameIndex;
                    return reinterpret_cast<TFrameType*>(m_frame->data);
                }

            void end_write()
                {
                    if (!m_locked)
                        return;

                    cycle_bin(m_binHandle, m_frame);
                    m_locked = false;
                }

            virtual void on_connection_added(sensekit_streamconnection_t connection) override
                {
                    link_connection_to_bin(connection, m_binHandle);
                }

            virtual void on_connection_removed(sensekit_bin_t bin,
                                               sensekit_streamconnection_t connection) override
                {
                    link_connection_to_bin(connection, nullptr);
                }

        private:
            bool m_locked{false};
            sensekit_bin_t m_binHandle{nullptr};
            sensekit_frame_t* m_frame{nullptr};
        };
    }}

#endif /* SINGLEBINSTREAM_H */<commit_msg>SingleBinStream whitespace<commit_after>#ifndef SINGLEBINSTREAM_H
#define SINGLEBINSTREAM_H

#include "Stream.h"

namespace sensekit { namespace plugins {

    template<typename TFrameType, typename TBlockType>
    class SingleBinStream : public Stream
    {
    public:

        SingleBinStream(PluginServiceProxy& pluginService,
                        Sensor& streamSet,
                        StreamDescription description,
                        size_t bufferSize)
            : Stream(pluginService,
                        streamSet,
                        description)
            {
                create_bin(sizeof(TFrameType) + bufferSize, m_binHandle, m_frame);
            }

        using frame_type = TFrameType;
        using block_type = TBlockType;

        bool has_connections()
            {
                if (m_binHandle == nullptr)
                    return false;

                return bin_has_connections(m_binHandle);
            }

        frame_type* begin_write(size_t frameIndex)
            {
                if (m_locked)
                    return reinterpret_cast<TFrameType*>(m_frame->data);

                m_locked = true;
                m_frame->frameIndex = frameIndex;
                return reinterpret_cast<TFrameType*>(m_frame->data);
            }

        void end_write()
            {
                if (!m_locked)
                    return;

                cycle_bin(m_binHandle, m_frame);
                m_locked = false;
            }

        virtual void on_connection_added(sensekit_streamconnection_t connection) override
            {
                link_connection_to_bin(connection, m_binHandle);
            }

        virtual void on_connection_removed(sensekit_bin_t bin,
                                            sensekit_streamconnection_t connection) override
            {
                link_connection_to_bin(connection, nullptr);
            }

    private:
        bool m_locked{false};
        sensekit_bin_t m_binHandle{nullptr};
        sensekit_frame_t* m_frame{nullptr};
    };
}}

#endif /* SINGLEBINSTREAM_H */
{'fraction_non_alphanumeric': 0.06144742831133364, 'fraction_numerical': 0.0, 'mean_word_length': 1.3641742872512104, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5819793', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1040, 'n_words': 193}