////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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 V5.5.1 (2411131018)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

#include "statsroipriority.h"
#include "parametersetmanager.h"

STATSROIPRIORITY_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SetValue/GetValue Functions
/// Gets or sets the requested value
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool modFaceRoiTriggerDataType::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;

    const UINT32 __pos = ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "triggerPt") == 0)
    {
        __result = triggerPt.GetValue(&__path[__pos], __value, __size);
    }
    else if (PARAMETER_STRCMP(__name, "triggerData") == 0)
    {
        if (__index < triggerDataCount)
        {
            __result = triggerData[__index].GetValue(&__path[__pos], __value, __size);
        }
    }

    return __result;
}

bool modFaceRoiTriggerDataType::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;

    const UINT32 __pos = ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "triggerPt") == 0)
    {
        __result = triggerPt.SetValue(&__path[__pos], __value);
    }
    else if (PARAMETER_STRCMP(__name, "triggerData") == 0)
    {
        if (__index < triggerDataCount)
        {
            __result = triggerData[__index].SetValue(&__path[__pos], __value);
        }
    }

    return __result;
}

bool modFaceRoiTriggerDataType::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;

    const UINT32 __pos = ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    // triggerPt
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("triggerPt", ParameterParserDataType::Structure));
    }
    else if (PARAMETER_STRCMP(__name, "triggerPt") == 0)
    {
        __result = triggerPt.GetInfo(&__path[__pos], __info);
    }

    // triggerData
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("triggerData", ParameterParserDataType::Structure, true, false, triggerDataCount));
    }
    else if (PARAMETER_STRCMP(__name, "triggerData") == 0)
    {
        if (__index < triggerDataCount)
        {
            __result = triggerData[__index].GetInfo(&__path[__pos], __info);
        }
        else
        {
            __result = true;
            __info.Add(ParameterParserInfo(nullptr, ParameterParserDataType::Structure, true, false, triggerDataCount));
        }
    }

    return __result;
}

bool chromatixStatsROIPriorityType::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;

    const UINT32 __pos = ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "dominantScoreEnhancement") == 0)
    {
        ParameterUtils::DoubleToString((double)dominantScoreEnhancement, __value, __size);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "FaceROISizeWeight") == 0)
    {
        __result = FaceROISizeWeight.GetValue(&__path[__pos], __value, __size);
    }
    else if (PARAMETER_STRCMP(__name, "FaceROILocationWeight") == 0)
    {
        __result = FaceROILocationWeight.GetValue(&__path[__pos], __value, __size);
    }

    return __result;
}

bool chromatixStatsROIPriorityType::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;

    const UINT32 __pos = ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

    if (PARAMETER_STRCMP(__name, "dominantScoreEnhancement") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            dominantScoreEnhancement = (float)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "FaceROISizeWeight") == 0)
    {
        __result = FaceROISizeWeight.SetValue(&__path[__pos], __value);
    }
    else if (PARAMETER_STRCMP(__name, "FaceROILocationWeight") == 0)
    {
        __result = FaceROILocationWeight.SetValue(&__path[__pos], __value);
    }

    return __result;
}

bool chromatixStatsROIPriorityType::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;

    const UINT32 __pos = ParameterUtils::GetVariable(__path, __name, __index, MAX_SIZE);

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

    // FaceROISizeWeight
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("FaceROISizeWeight", ParameterParserDataType::Structure));
    }
    else if (PARAMETER_STRCMP(__name, "FaceROISizeWeight") == 0)
    {
        __result = FaceROISizeWeight.GetInfo(&__path[__pos], __info);
    }

    // FaceROILocationWeight
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("FaceROILocationWeight", ParameterParserDataType::Structure));
    }
    else if (PARAMETER_STRCMP(__name, "FaceROILocationWeight") == 0)
    {
        __result = FaceROILocationWeight.GetInfo(&__path[__pos], __info);
    }

    return __result;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load modFaceRoiTriggerDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool modFaceRoiTriggerDataType::Load(
    ParameterFileSymbolTableEntry* const entry,
    BYTE const alignment)
{
    bool result = true;

    PARAMETER_INITIALIZE(triggerPt);
    PARAMETER_INITIALIZE(triggerData);

    result = triggerPt.Load(entry, alignment);

    // Reading Array triggerData from symbol table
    // Do not check result value here because the count value needs to be initialized in this block
    {
        triggerDataCount = 0;
        SYMBOL_TABLE_ENTRY_READ(entry, result, triggerDataCount, alignment)
        constexpr const CHAR* const file {__FILE__};
        constexpr INT32 line {LINE_CONST};
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }

        if (result)
        {
            triggerDataID = pointerEntry->ID;
            DupObjInfo* triggerDataDupInfo = pointerEntry->GetDupObject(triggerDataCount, file, line);
            if (triggerDataDupInfo != nullptr && triggerDataDupInfo->Object != nullptr)
            {
                triggerData = (statsglobalelements::glbTriggerDataFloatType*)triggerDataDupInfo->Object;
                if (triggerData == nullptr)
                {
                    if (triggerDataDupInfo->File != nullptr)
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "triggerData duplicate found but object is nullptr: %s:%d, RefCount: %d\n",
                            triggerDataDupInfo->File, triggerDataDupInfo->Line, triggerDataDupInfo->RefCount);
                    }
                    else
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "triggerData duplicate found but Object is nullptr: <nullptr file ptr>:%d, RefCount: %d\n",
                            triggerDataDupInfo->Line, triggerDataDupInfo->RefCount);
                    }
                }
            }

            if (triggerData == nullptr)
            {
                if (result && triggerDataCount > 0)
                {
                    triggerData = PARAMETER_NEW statsglobalelements::glbTriggerDataFloatType[triggerDataCount];
                    (void)pointerEntry->SetDupObject(triggerData, triggerDataCount, file, line);
                }
                if (!result || triggerData == nullptr)
                {
                    if (triggerDataCount > 0)
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "Failed to allocate triggerData\n");
                    }
                    triggerDataCount = 0;
                }
                for (UINT32 i = 0; result && i < triggerDataCount; i++)
                {
                    result = triggerData[i].Load(pointerEntry, alignment);
                }
            }
        }
        if (triggerData == nullptr)
        {
            triggerDataCount = 0;
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixStatsROIPriorityType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool chromatixStatsROIPriorityType::Load(
    ParameterFileSymbolTableEntry* const entry,
    BYTE const alignment)
{
    bool result = true;

    PARAMETER_INITIALIZE(dominantScoreEnhancement);
    PARAMETER_INITIALIZE(FaceROISizeWeight);
    PARAMETER_INITIALIZE(FaceROILocationWeight);

    SYMBOL_TABLE_ENTRY_READ(entry, result, dominantScoreEnhancement, alignment)
    if (result)
    {
        result = FaceROISizeWeight.Load(entry, alignment);
    }
    if (result)
    {
        result = FaceROILocationWeight.Load(entry, alignment);
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload modFaceRoiTriggerDataType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void modFaceRoiTriggerDataType::Unload(ParameterFileSymbolTable* const __table)
{
    if (__table != nullptr && __table->ReleaseDupObject(triggerData))
    {
        PARAMETER_DELETE[] triggerData;
    }
    triggerData = nullptr;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixStatsROIPriorityType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixStatsROIPriorityType::Unload(ParameterFileSymbolTable* const __table)
{
    FaceROISizeWeight.Unload(__table);
    FaceROILocationWeight.Unload(__table);
}
STATSROIPRIORITY_NAMESPACE_END
