////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// All rights reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: Parameter Parser V7.4.1 (8cca6579792b9fcef3bc725ff070c5ec453c7c85)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  globalelements.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "globalelements.h"
#include "parametersetmanager.h"

GLOBALELEMENTS_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SetValue/GetValue Functions
/// Gets or sets the requested value
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool trigger_pt_type_aec::GetValue(
    const CHAR* const __path,
    CHAR* const       __value,
    UINT32 const      __size)
{
    constexpr SIZE_T MAX_SIZE = 129;
    CHAR   __name[MAX_SIZE] = "";
    UINT32 __index          = MAX_UINT;
    bool   __result         = false;

    (void)ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "lux_idx_start") == 0)
    {
        ParameterUtils::DoubleToString((double)lux_idx_start, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_end") == 0)
    {
        ParameterUtils::DoubleToString((double)lux_idx_end, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "gain_start") == 0)
    {
        ParameterUtils::DoubleToString((double)gain_start, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "gain_end") == 0)
    {
        ParameterUtils::DoubleToString((double)gain_end, __value, __size);
        __result = true;
    }

    return __result;
}

bool trigger_pt_type_aec::SetValue(
    const CHAR* const __path,
    const CHAR* const __value)
{
    constexpr SIZE_T MAX_SIZE = 129;
    CHAR   __name[MAX_SIZE] = "";
    UINT32 __index          = MAX_UINT;
    bool   __result         = false;

    (void)ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "lux_idx_start") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            lux_idx_start = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_end") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            lux_idx_end = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "gain_start") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            gain_start = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "gain_end") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            gain_end = (float)dblValue; 
        }
    }

    return __result;
}

bool trigger_pt_type_aec::GetInfo(
    const CHAR* const           __path,
    PList<ParameterParserInfo>& __info)
{
    constexpr SIZE_T MAX_SIZE = 129;
    CHAR   __name[MAX_SIZE] = "";
    UINT32 __index          = MAX_UINT;
    bool   __result         = false;

    (void)ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    // lux_idx_start
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("lux_idx_start", ParameterParserDataType::Float, (double)lux_idx_start));
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_start") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)lux_idx_start));
    }

    // lux_idx_end
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("lux_idx_end", ParameterParserDataType::Float, (double)lux_idx_end));
    }
    else if (PARAMETER_STRCMP(__name, "lux_idx_end") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)lux_idx_end));
    }

    // gain_start
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("gain_start", ParameterParserDataType::Float, (double)gain_start));
    }
    else if (PARAMETER_STRCMP(__name, "gain_start") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)gain_start));
    }

    // gain_end
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("gain_end", ParameterParserDataType::Float, (double)gain_end));
    }
    else if (PARAMETER_STRCMP(__name, "gain_end") == 0)
    {
        __result = true;
        __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Float, (double)gain_end));
    }

    return __result;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load trigger_pt_type_aec
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void trigger_pt_type_aec::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(lux_idx_start);
    PARAMETER_INITIALIZE(lux_idx_end);
    PARAMETER_INITIALIZE(gain_start);
    PARAMETER_INITIALIZE(gain_end);

    ParameterFileSymbolTableEntry* const entry = parentParams.Entry;
    ParameterLoadParameters localParams(parentParams);
    localParams.Element   = nullptr;
    localParams.UseParent = false;
    localParams.Index     = 0;

    if (parentParams.Element != nullptr)
    {
        bool _posChanged = false;
        localParams.Element = entry->AdjustPositionAndGetElement(parentParams, true, _posChanged);
    }

    // If parentParams.Element != null && localParams.Element == null, then this element is not defined in the binary file.
    // If parentParams.Element == null then this binary file does not contain a definition table or
    // the full backwards compatibility feature is disabled (for memory or performance reasons)
    if (parentParams.Element == nullptr || parentParams.Element->Verified || localParams.Element != nullptr)
    {
        localParams.Position      = entry->Position;
        localParams.LoadDataLimit = entry->ReadLoadDataLimit(parentParams.LoadDataLimit);

        localParams.NameHash = 0x9400c837a72e7366;
        entry->ReadSimpleTypeFixedArray(&lux_idx_start, 1, localParams);
        localParams.NameHash = 0x8feebe8493968b4e;
        entry->ReadSimpleTypeFixedArray(&lux_idx_end, 1, localParams);
        localParams.NameHash = 0xc1caf9102a8c4bcd;
        entry->ReadSimpleTypeFixedArray(&gain_start, 1, localParams);
        localParams.NameHash = 0xdf4179732028dad3;
        entry->ReadSimpleTypeFixedArray(&gain_end, 1, localParams);

        entry->UpdatePosition(localParams.LoadDataLimit);
    }
    else
    {
        PARAMETER_LOG_ERROR(entry->Table->SetManager, "%s: 0x%llx entry not found in the binary file, all values will be 0\n",
            __FUNCTION__, parentParams.NameHash);
    }
}

void trigger_pt_type_aec::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        trigger_pt_type_aec* arrayPtr = (trigger_pt_type_aec*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

void* trigger_pt_type_aec::AllocArray(
    UINT32 __count)
{
    trigger_pt_type_aec* result = nullptr;
    if (__count > 0)
    {
        result = PARAMETER_NEW trigger_pt_type_aec[__count];
    }
    return result;
}
GLOBALELEMENTS_NAMESPACE_END
