<commit_before>/*
 * Copyright 2016 <<NAME>> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */


#pragma once


#include <iostream>
#include <vector>
#include <string>
#include <type_traits>
#include "rclcpp/rclcpp.hpp"

#define ASTRINGZ(x) STRINGZ(x)
#define STRINGZ(x)  #x
#define REFLECT(a)  addElement(ASTRINGZ(a) , a);
#define UNUSED(x) (void)(x)


using namespace std;

class Element{
public:
    string key;
    string type;
    
    virtual void print(){}
    virtual rclcpp::parameter::ParameterVariant  getParameterVariant()=0;
    virtual rclcpp::parameter::ParameterVariant  getParameterVariant(std::string prefix)= 0;
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key, std::string & _type)=0;
    
};
template <class T>
class SpecificElement : public Element{
    
    static_assert(std::is_same<T, double>::value || std::is_same<T, int64_t>::value || std::is_same<T, bool>::value || std::is_same<T, std::string>::value || std::is_same<T, std::vector<uint8_t>>::value,
                  "The Reflection api only accepts the following types: double, int64_t, boo, string, std::vector<uint8_t>");
public: 
    T &data;
    SpecificElement(string _key,T &_data):data(_data){
        key=_key;
        if(std::is_same<T, double>::value)
            type = "double";
        else if(std::is_same<T, int64_t>::value)
            type = "int64_t";
        else if(std::is_same<T, bool>::value)
            type = "bool";
        else if(std::is_same<T, std::vector<uint8_t>>::value)
            type = "vector<uint8_t>";
    }
    virtual void print(){
        cout<<"<"<<key<<"> ="<<data<<endl;
    }
    virtual void setValue(T val)
    {
        data =val;
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant()
    {
        return rclcpp::parameter::ParameterVariant(key, data);
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant(std::string prefix)
    {
        return rclcpp::parameter::ParameterVariant(prefix+"."+key, data);
    }
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key,std::string &_type)
    {
        _key = key;
        _type = type;

        length = sizeof(T);

        return &data;
    }
};

template <>
class SpecificElement<std::string> : public Element{
public:
    std::string &data;
    SpecificElement(string _key,std::string &_data):data(_data){
        key=_key;
        type = "string";
    }
    virtual void print(){
        cout<<"<"<<key<<"> ="<<data<<endl;
    }
    virtual void setValue(std::string val)
    {
        data =val;
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant()
    {
        return rclcpp::parameter::ParameterVariant(key, data);
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant(std::string prefix)
    {
        return rclcpp::parameter::ParameterVariant(prefix+"."+key, data);
    }
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key,std::string &_type)
    {
        _key = key;
        _type = type;

        length = ((std::string)data).length();
        return ((std::string)data).c_str();

    }
};

template <>
class SpecificElement<std::vector<uint8_t>> : public Element{
public:
    std::vector<uint8_t> &data;
    SpecificElement(string _key,std::vector<uint8_t> &_data):data(_data){
        key=_key;
        type = "std::vector<uint8_t>";
    }
    virtual void print(){
       // cout<<"<"<<key<<"> ="<<data<<endl;
    }
    virtual void setValue(std::vector<uint8_t> val)
    {
        data =val;
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant()
    {
        return rclcpp::parameter::ParameterVariant(key, data);
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant(std::string prefix)
    {
        return rclcpp::parameter::ParameterVariant(prefix+"."+key, data);
    }
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key,std::string &_type)
    {
        _key = key;
        _type = type;

        length = data.size();<commit_msg>Fixed not compatible error<commit_after>/*
 * Copyright 2016 <<NAME>> <<EMAIL>>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */


#pragma once


#include <iostream>
#include <vector>
#include <string>
#include <type_traits>
#include "rclcpp/rclcpp.hpp"

#define ASTRINGZ(x) STRINGZ(x)
#define STRINGZ(x)  #x
#define REFLECT(a)  addElement(ASTRINGZ(a) , a);
#define UNUSED(x) (void)(x)


using namespace std;

class Element{
public:
    string key;
    string type;
    
    virtual void print(){}
    virtual rclcpp::parameter::ParameterVariant  getParameterVariant()=0;
    virtual rclcpp::parameter::ParameterVariant  getParameterVariant(std::string prefix)= 0;
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key, std::string & _type)=0;
    
};
template <class T>
class SpecificElement : public Element{
    
    static_assert(std::is_same<T, double>::value || std::is_same<T, int64_t>::value || std::is_same<T, bool>::value || std::is_same<T, std::string>::value || std::is_same<T, std::vector<uint8_t>>::value,
                  "The Reflection api only accepts the following types: double, int64_t, boo, string, std::vector<uint8_t>");
public: 
    T &data;
    SpecificElement(string _key,T &_data):data(_data){
        key=_key;
        if(std::is_same<T, double>::value)
            type = "double";
        else if(std::is_same<T, int64_t>::value)
            type = "int64_t";
        else if(std::is_same<T, bool>::value)
            type = "bool";
        else if(std::is_same<T, std::vector<uint8_t>>::value)
            type = "vector<uint8_t>";
    }
    virtual void print(){
        cout<<"<"<<key<<"> ="<<data<<endl;
    }
    virtual void setValue(T val)
    {
        data =val;
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant()
    {
        return rclcpp::parameter::ParameterVariant(key, data);
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant(std::string prefix)
    {
        return rclcpp::parameter::ParameterVariant(prefix+"."+key, data);
    }
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key,std::string &_type)
    {
        _key = key;
        _type = type;

        length = sizeof(T);

        return &data;
    }
};

template <>
class SpecificElement<std::string> : public Element{
public:
    std::string &data;
    SpecificElement(string _key,std::string &_data):data(_data){
        key=_key;
        type = "string";
    }
    virtual void print(){
        cout<<"<"<<key<<"> ="<<data<<endl;
    }
    virtual void setValue(std::string val)
    {
        data =val;
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant()
    {
        return rclcpp::parameter::ParameterVariant(key, data);
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant(std::string prefix)
    {
        return rclcpp::parameter::ParameterVariant(prefix+"."+key, data);
    }
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key,std::string &_type)
    {
        _key = key;
        _type = type;

        length = ((std::string)data).length();
        return ((std::string)data).c_str();

    }
};

template <>
class SpecificElement<std::vector<uint8_t>> : public Element{
public:
    std::vector<uint8_t> &data;
    SpecificElement(string _key,std::vector<uint8_t> &_data):data(_data){
        key=_key;
        type = "std::vector<uint8_t>";
    }
    virtual void print(){
        // cout<<"<"<<key<<"> ="<<data<<endl;
    }
    virtual void setValue(std::vector<uint8_t> val)
    {
        data =val;
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant()
    {
        return rclcpp::parameter::ParameterVariant(key, data);
    }
    virtual rclcpp::parameter::ParameterVariant getParameterVariant(std::string prefix)
    {
        return rclcpp::parameter::ParameterVariant(prefix+"."+key, data);
    }
    virtual const void * getVoidPtr(uint8_t & length, std::string & _key,std::string &_type)
    {
        _key = key;
        _type = type;

        length = data.size();
{'fraction_non_alphanumeric': 0.1411431064572426, 'fraction_numerical': 0.006980802792321117, 'mean_word_length': 3.3475580844001898, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '336217', 'n_tokens_mistral': 2890, 'n_tokens_neox': 2853, 'n_words': 682}