<commit_before>

#include "Properties.h"
#include "tis_logging.h"
#include "tis_utils.h" // tis_xioctl

#include <algorithm> // find_if
#include <cstring>

using namespace tis_imaging;




PropertyString::PropertyString (std::shared_ptr<PropertyImpl> _impl,
                                const camera_property& _property,
                                const VALUE_TYPE& t)
    : Property(_property, t)
{
    impl = _impl;
}


PropertyString::~PropertyString ()
{}


std::string PropertyString::getDefault () const
{
    return prop.value.s.default_value;
}


bool PropertyString::setValue (const std::string& _value)
{
    if (isReadOnly())
    {
        return false;
    }

    if (_value.size() > sizeof(this->prop.value.s.value))
        return false;

    memcpy(this->prop.value.s.value, _value.c_str(), _value.size());

    notifyImpl();

    return true;
}


std::string PropertyString::getValue () const
{
    return prop.value.s.value;
}






PropertyStringMap::PropertyStringMap (std::shared_ptr<PropertyImpl> _impl,
                                      const camera_property& _property,
                                      const std::map<std::string, int>& _values,
                                      const VALUE_TYPE& t)
    : Property(_property, _values, t)
{
    impl = _impl;
}


PropertyStringMap::~PropertyStringMap ()
{}


std::vector<std::string> PropertyStringMap::getValues () const
{
    std::vector<std::string> vec;

    for (auto m : string_map)
    {
        vec.push_back(std::get<0>(m));
    }

    return vec;
}


std::string PropertyStringMap::getDefault () const
{
    return "";
}


bool PropertyStringMap::setValue (const std::string& _value)
{
    if (isReadOnly())
    {
        return false;
    }

    auto element = string_map.find(_value);

    if (element == string_map.end())
    {
        return false;
    }

    notifyImpl();

    return false;
}


std::string PropertyStringMap::getValue () const
{
    return prop.value.s.value;
}


std::map<std::string, int> PropertyStringMap::getMapping () const
{
    return string_map;
}





PropertySwitch::PropertySwitch (std::shared_ptr<PropertyImpl> _impl,
                                const camera_property& _property,
                                const VALUE_TYPE& t)
    : Property(_property, t)
{
    impl = _impl ;
}


PropertySwitch::~PropertySwitch ()
{}


bool PropertySwitch::getDefault () const
{
    return prop.value.i.default_value;
}


bool PropertySwitch::setValue (const bool&)
{
    if (isReadOnly())
    {
        return false;
    }

    notifyImpl();

    return true;
}


bool PropertySwitch::getValue () const
{
    return prop.value.i.value;
}






PropertyInteger::PropertyInteger (std::shared_ptr<PropertyImpl> _impl,
                                  const camera_property& _property,
                                  const VALUE_TYPE& t)
    : Property (_property, t)
{
    impl = _impl;
}


PropertyInteger::~PropertyInteger ()
{}


int64_t PropertyInteger::getDefault () const
{<commit_msg>Assured PropertySwitch wirks with correct camera_property.value<commit_after>

#include "Properties.h"
#include "tis_logging.h"
#include "tis_utils.h" // tis_xioctl

#include <algorithm> // find_if
#include <cstring>

using namespace tis_imaging;




PropertyString::PropertyString (std::shared_ptr<PropertyImpl> _impl,
                                const camera_property& _property,
                                const VALUE_TYPE& t)
    : Property(_property, t)
{
    impl = _impl;
}


PropertyString::~PropertyString ()
{}


std::string PropertyString::getDefault () const
{
    return prop.value.s.default_value;
}


bool PropertyString::setValue (const std::string& _value)
{
    if (isReadOnly())
    {
        return false;
    }

    if (_value.size() > sizeof(this->prop.value.s.value))
        return false;

    memcpy(this->prop.value.s.value, _value.c_str(), _value.size());

    notifyImpl();

    return true;
}


std::string PropertyString::getValue () const
{
    return prop.value.s.value;
}






PropertyStringMap::PropertyStringMap (std::shared_ptr<PropertyImpl> _impl,
                                      const camera_property& _property,
                                      const std::map<std::string, int>& _values,
                                      const VALUE_TYPE& t)
    : Property(_property, _values, t)
{
    impl = _impl;
}


PropertyStringMap::~PropertyStringMap ()
{}


std::vector<std::string> PropertyStringMap::getValues () const
{
    std::vector<std::string> vec;

    for (auto m : string_map)
    {
        vec.push_back(std::get<0>(m));
    }

    return vec;
}


std::string PropertyStringMap::getDefault () const
{
    return "";
}


bool PropertyStringMap::setValue (const std::string& _value)
{
    if (isReadOnly())
    {
        return false;
    }

    auto element = string_map.find(_value);

    if (element == string_map.end())
    {
        return false;
    }

    notifyImpl();

    return false;
}


std::string PropertyStringMap::getValue () const
{
    return prop.value.s.value;
}


std::map<std::string, int> PropertyStringMap::getMapping () const
{
    return string_map;
}





PropertySwitch::PropertySwitch (std::shared_ptr<PropertyImpl> _impl,
                                const camera_property& _property,
                                const VALUE_TYPE& t)
    : Property(_property, t)
{
    impl = _impl ;
}


PropertySwitch::~PropertySwitch ()
{}


bool PropertySwitch::getDefault () const
{
    return prop.value.b.default_value;
}


bool PropertySwitch::setValue (const bool&)
{
    if (isReadOnly())
    {
        return false;
    }

    notifyImpl();

    return true;
}


bool PropertySwitch::getValue () const
{
    return prop.value.b.value;
}






PropertyInteger::PropertyInteger (std::shared_ptr<PropertyImpl> _impl,
                                  const camera_property& _property,
                                  const VALUE_TYPE& t)
    : Property (_property, t)
{
    impl = _impl;
}


PropertyInteger::~PropertyInteger ()
{}


int64_t PropertyInteger::getDefault () const
{
{'fraction_non_alphanumeric': 0.12070094988535866, 'fraction_numerical': 0.000982640026203734, 'mean_word_length': 2.4639818491208167, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '763929', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1804, 'n_words': 363}