<commit_before>//
//  ofxOscSubscribeParameter.h
//  ofxPubSubOscDev
//
//  Created by ISHII 2bit on 2016/05/29.
//
//

#pragma once

#ifndef ofxOscSubscribeParameter_h
#define ofxOscSubscribeParameter_h

#include "ofxOscMessage.h"
#include "ofxOscMessageEx.h"
#include "ofxOscSubscriberLoadImplementation.h"

namespace ofx {
    namespace PubSubOsc {
        namespace Subscribe {
            struct AbstractParameter {
                virtual void read(const ofxOscMessageEx &message, std::size_t offset = 0) = 0;
                virtual std::size_t size() const = 0;
                void setEnable(bool bEnabled) { this->bEnabled = bEnabled; }
                bool isEnabled() const { return bEnabled; }
            protected:
                bool bEnabled{true};
            };
            
            using ParameterRef = std::shared_ptr<AbstractParameter>;
            
            template <typename T>
            struct Parameter : AbstractParameter, type_traits<T> {
                Parameter(T &t) : t(t) {}
                virtual void read(const ofxOscMessageEx &message, std::size_t offset = 0) override
                    { PubSubOsc::load(message, t, offset); }
                virtual std::size_t size() const override { return type_traits<T>::size; };
                
            private:
                
                T &t;
            };
            
            template <typename ... Ts>
            struct TupleParameter : AbstractParameter, type_traits<std::tuple<Ts ...>> {
                TupleParameter(std::vector<ParameterRef> &&t) : t(std::move(t)) {}
                virtual void read(const ofxOscMessageEx &message, std::size_t offset = 0) override
                    { load(message, t, offset); }
                virtual std::size_t size() const override { return type_traits<std::tuple<Ts ...>>::size; };
                
            private:
                
                std::vector<ParameterRef> t;
            };
            
            namespace detail {
                template <typename ... Ts, std::size_t ... Indices>
                void read_to_tuple(index_sequence<Indices ...> &&,
                                   ofxOscMessageEx &m,
                                   std::tuple<Ts ...> &t,
                                   std::size_t offset) {
                    std::size_t o{0};
                    std::vector<std::size_t>{(PubSubOsc::load(m, std::get<Indices>(t), offset + o), o += type_traits<Ts>::size) ...};
                }
                
                template <typename ... Ts>
                void read_to_tuple(ofxOscMessageEx &m, std::tuple<Ts ...> &t, std::size_t offset) {
                    read_to_tuple(index_sequence_for<Ts ...>(), m, t, offset);
                }
            };<commit_msg>omg!! fixed!!!<commit_after>//
//  ofxOscSubscribeParameter.h
//  ofxPubSubOscDev
//
//  Created by ISHII 2bit on 2016/05/29.
//
//

#pragma once

#ifndef ofxOscSubscribeParameter_h
#define ofxOscSubscribeParameter_h

#include "ofxOscMessage.h"
#include "ofxOscMessageEx.h"
#include "ofxOscSubscriberLoadImplementation.h"

namespace ofx {
    namespace PubSubOsc {
        namespace Subscribe {
            struct AbstractParameter {
                virtual void read(const ofxOscMessageEx &message, std::size_t offset = 0) = 0;
                virtual std::size_t size() const = 0;
                void setEnable(bool bEnabled) { this->bEnabled = bEnabled; }
                bool isEnabled() const { return bEnabled; }
            protected:
                bool bEnabled{true};
            };
            
            using ParameterRef = std::shared_ptr<AbstractParameter>;
            
            template <typename T>
            struct Parameter : AbstractParameter, type_traits<T> {
                Parameter(T &t) : t(t) {}
                virtual void read(const ofxOscMessageEx &message, std::size_t offset = 0) override
                    { PubSubOsc::load(message, t, offset); }
                virtual std::size_t size() const override { return type_traits<T>::size; };
                
            private:
                
                T &t;
            };
            
            template <typename ... Ts>
            struct TupleParameter : AbstractParameter, type_traits<std::tuple<Ts ...>> {
                TupleParameter(std::vector<ParameterRef> &&t) : t(std::move(t)) {}
                virtual void read(const ofxOscMessageEx &message, std::size_t offset = 0) override
                    { load(message, t, offset); }
                virtual std::size_t size() const override { return type_traits<std::tuple<Ts ...>>::size; };
                
            private:
                
                std::vector<ParameterRef> t;
            };
            
            namespace detail {
                template <typename ... Ts, std::size_t ... Indices>
                void read_to_tuple(index_sequence<Indices ...> &&,
                                   const ofxOscMessageEx &m,
                                   std::tuple<Ts ...> &t,
                                   std::size_t offset) {
                    std::size_t o{0};
                    std::vector<std::size_t>{(PubSubOsc::load(m, std::get<Indices>(t), offset + o), o += type_traits<Ts>::size) ...};
                }
                
                template <typename ... Ts>
                void read_to_tuple(const ofxOscMessageEx &m, std::tuple<Ts ...> &t, std::size_t offset) {
                    read_to_tuple(index_sequence_for<Ts ...>(), m, t, offset);
                }
            };
{'fraction_non_alphanumeric': 0.11417816813048934, 'fraction_numerical': 0.005377307761247535, 'mean_word_length': 1.515779981965735, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3219883', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1484, 'n_words': 325}