////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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  aecxmeteringsaalgorithm.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "aecxmeteringsaalgorithm.h"
#include "parametersetmanager.h"

AECXMETERINGSAALGORITHM_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SetValue/GetValue Functions
/// Gets or sets the requested value
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SAAlgorithmType::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, "ID") == 0)
    {
        ParameterUtils::DoubleToString((double)ID, __value, __size, 0);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "description") == 0)
    {
        PARAMETER_STRCPY(__value, __size, description);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "extensionParameters") == 0)
    {
        if (__index < extensionParametersCount)
        {
            ParameterUtils::DoubleToString((double)extensionParameters[__index], __value, __size);
            __result = true;
        }
        else
        {
            SIZE_T __valuePos = 0;
            for (UINT32 i = 0; i < extensionParametersCount; i++)
            {
                if (i > 0)
                {
                    PARAMETER_STRCAT(__value, __size, ",");
                    __valuePos = PARAMETER_STRLEN(__value);
                }
                ParameterUtils::DoubleToString((double)extensionParameters[i], &__value[__valuePos], (INT32)(__size - __valuePos));
            }
            __result = true;
        }
    }
    else if (PARAMETER_STRCMP(__name, "extensionTriggerSystem") == 0)
    {
        if (__index < extensionTriggerSystemCount)
        {
            __result = extensionTriggerSystem[__index].GetValue(&__path[__pos], __value, __size);
        }
    }

    return __result;
}

bool SAAlgorithmType::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, "ID") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            ID = (UINT32)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "description") == 0)
    {
        // Cannot modify strings, risk of memory leaks or corruption
    }
    else if (PARAMETER_STRCMP(__name, "extensionParameters") == 0)
    {
        if (__index < extensionParametersCount)
        {
            const double dblValue = ParameterUtils::StringToDouble(__value, __result);
            if (__result)
            {
                extensionParameters[__index] = (float)dblValue; 
            }
        }
        else
        {
            SIZE_T __valueLen = PARAMETER_STRLEN(__value);
            UINT32 __pos = 0;

            __index = 0;
            while (__pos < __valueLen && __index < extensionParametersCount)
            {
                CHAR __valueStr[MAX_SIZE];

                __pos += ParameterUtils::GetSubString(&__value[__pos], ',', __valueStr, MAX_SIZE);
                __pos++;

                const double dblValue = ParameterUtils::StringToDouble(__valueStr, __result);
                if (__result)
                {
                    extensionParameters[__index] = (float)dblValue; 
                }
                __index++;
            }
            __result = true;
        }
    }
    else if (PARAMETER_STRCMP(__name, "extensionTriggerSystem") == 0)
    {
        if (__index < extensionTriggerSystemCount)
        {
            __result = extensionTriggerSystem[__index].SetValue(&__path[__pos], __value);
        }
    }

    return __result;
}

bool SAAlgorithmType::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);

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

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

    // extensionParameters
    if (__name[0] == '\0')
    {
        __result = true;
        __info.Add(ParameterParserInfo("extensionParameters", ParameterParserDataType::Float, true, false, extensionParametersCount));
    }

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

    return __result;
}

bool AECXMeteringSAAlgorithmType::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, "module_version") == 0)
    {
        __result = module_version.GetValue(&__path[__pos], __value, __size);
    }
    else if (PARAMETER_STRCMP(__name, "parameter_version") == 0)
    {
        __result = parameter_version.GetValue(&__path[__pos], __value, __size);
    }
    else if (PARAMETER_STRCMP(__name, "SAAlgorithm") == 0)
    {
        if (__index < SAAlgorithmCount)
        {
            __result = SAAlgorithm[__index].GetValue(&__path[__pos], __value, __size);
        }
    }

    return __result;
}

bool AECXMeteringSAAlgorithmType::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, "module_version") == 0)
    {
        __result = module_version.SetValue(&__path[__pos], __value);
    }
    else if (PARAMETER_STRCMP(__name, "parameter_version") == 0)
    {
        __result = parameter_version.SetValue(&__path[__pos], __value);
    }
    else if (PARAMETER_STRCMP(__name, "SAAlgorithm") == 0)
    {
        if (__index < SAAlgorithmCount)
        {
            __result = SAAlgorithm[__index].SetValue(&__path[__pos], __value);
        }
    }

    return __result;
}

bool AECXMeteringSAAlgorithmType::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);

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

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

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

    return __result;
}

bool AECXMeteringSAAlgorithmType::module_versionStruct::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;

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

    if (PARAMETER_STRCMP(__name, "major_revision") == 0)
    {
        ParameterUtils::DoubleToString((double)major_revision, __value, __size, 0);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "minor_revision") == 0)
    {
        ParameterUtils::DoubleToString((double)minor_revision, __value, __size, 0);
        __result = true;
    }
    else if (PARAMETER_STRCMP(__name, "incr_revision") == 0)
    {
        ParameterUtils::DoubleToString((double)incr_revision, __value, __size, 0);
        __result = true;
    }

    return __result;
}

bool AECXMeteringSAAlgorithmType::module_versionStruct::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;

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

    if (PARAMETER_STRCMP(__name, "major_revision") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            major_revision = (INT32)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "minor_revision") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            minor_revision = (INT32)dblValue; 
        }
    }
    else if (PARAMETER_STRCMP(__name, "incr_revision") == 0)
    {
        const double dblValue = ParameterUtils::StringToDouble(__value, __result);
        if (__result)
        {
            incr_revision = (INT32)dblValue; 
        }
    }

    return __result;
}

bool AECXMeteringSAAlgorithmType::module_versionStruct::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;

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

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

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

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

    return __result;
}

bool AECXMeteringSAAlgorithmType::parameter_versionStruct::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;

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

    if (PARAMETER_STRCMP(__name, "revision") == 0)
    {
        PARAMETER_STRCPY(__value, __size, revision);
        __result = true;
    }

    return __result;
}

bool AECXMeteringSAAlgorithmType::parameter_versionStruct::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;

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

    if (PARAMETER_STRCMP(__name, "revision") == 0)
    {
        // Cannot modify strings, risk of memory leaks or corruption
    }

    return __result;
}

bool AECXMeteringSAAlgorithmType::parameter_versionStruct::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;

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

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

    return __result;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AECXMeteringSAAlgorithmTypeClass::AECXMeteringSAAlgorithmTypeClass(
    const CHAR* const name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, nullptr)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(SAAlgorithmCount);
    PARAMETER_INITIALIZE(SAAlgorithm);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AECXMeteringSAAlgorithmTypeClass::AECXMeteringSAAlgorithmTypeClass(
    const CHAR* const name,
    ModuleData* const moduleData)
    : ParameterModule(name, MAJOR, MINOR, PATCH, moduleData)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(SAAlgorithm);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AECXMeteringSAAlgorithmTypeClass::~AECXMeteringSAAlgorithmTypeClass()
{
    if (Loaded)
    {
        UnloadModule();
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* AECXMeteringSAAlgorithmTypeClass::GetName(
    const CHAR* const type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ModuleData::GetType(temp, "aecxmeteringsaalgorithm")) == 0)
    {
        name = "aecxmeteringsaalgorithm";
    }
    return name;
}

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

    PARAMETER_INITIALIZE(ID);
    PARAMETER_INITIALIZE(description);
    PARAMETER_INITIALIZE(extensionParameters);
    PARAMETER_INITIALIZE(extensionTriggerSystem);

    SYMBOL_TABLE_ENTRY_READ(entry, result, ID, alignment)

    // Reading String description from symbol table
    {
        UINT32 count = 0;
        SYMBOL_TABLE_ENTRY_READ(entry, result, count, alignment)
        ParameterFileSymbolTableEntry stringPointerEntryCls;
        ParameterFileSymbolTableEntry* const stringPointerEntry = &stringPointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(stringPointerEntryCls, entry, alignment);
        }
        SYMBOL_TABLE_ENTRY_READ_STRING(stringPointerEntry, result, description, count, alignment)
    }

    // Reading Array extensionParameters from symbol table
    // Do not check result value here because the count value needs to be initialized in this block
    {
        extensionParametersCount = 0;
        SYMBOL_TABLE_ENTRY_READ(entry, result, extensionParametersCount, 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)
        {
            extensionParametersID = pointerEntry->ID;
            DupObjInfo* extensionParametersDupInfo = pointerEntry->GetDupObject(extensionParametersCount, file, line);
            if (extensionParametersDupInfo != nullptr && extensionParametersDupInfo->Object != nullptr)
            {
                extensionParameters = (float*)extensionParametersDupInfo->Object;
                if (extensionParameters == nullptr)
                {
                    if (extensionParametersDupInfo->File != nullptr)
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "extensionParameters duplicate found but object is nullptr: %s:%d, RefCount: %d\n",
                            extensionParametersDupInfo->File, extensionParametersDupInfo->Line, extensionParametersDupInfo->RefCount);
                    }
                    else
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "extensionParameters duplicate found but Object is nullptr: <nullptr file ptr>:%d, RefCount: %d\n",
                            extensionParametersDupInfo->Line, extensionParametersDupInfo->RefCount);
                    }
                }
            }

            if (extensionParameters == nullptr)
            {
                if (result && extensionParametersCount > 0)
                {
                    extensionParameters = pointerEntry->ReadArray<float>(extensionParametersCount, alignment);
                    result = extensionParameters != nullptr;
                }
                if (!result || extensionParameters == nullptr)
                {
                    if (extensionParametersCount > 0)
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "Failed to allocate extensionParameters\n");
                    }
                    extensionParametersCount = 0;
                }
            }
        }
        if (extensionParameters == nullptr)
        {
            extensionParametersCount = 0;
        }
    }

    // Reading Array extensionTriggerSystem from symbol table
    // Do not check result value here because the count value needs to be initialized in this block
    {
        extensionTriggerSystemCount = 0;
        SYMBOL_TABLE_ENTRY_READ(entry, result, extensionTriggerSystemCount, 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)
        {
            extensionTriggerSystemID = pointerEntry->ID;
            DupObjInfo* extensionTriggerSystemDupInfo = pointerEntry->GetDupObject(extensionTriggerSystemCount, file, line);
            if (extensionTriggerSystemDupInfo != nullptr && extensionTriggerSystemDupInfo->Object != nullptr)
            {
                extensionTriggerSystem = (aecxglobalelements::TwoLevelDataBankTriggerSystemType*)extensionTriggerSystemDupInfo->Object;
                if (extensionTriggerSystem == nullptr)
                {
                    if (extensionTriggerSystemDupInfo->File != nullptr)
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "extensionTriggerSystem duplicate found but object is nullptr: %s:%d, RefCount: %d\n",
                            extensionTriggerSystemDupInfo->File, extensionTriggerSystemDupInfo->Line, extensionTriggerSystemDupInfo->RefCount);
                    }
                    else
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "extensionTriggerSystem duplicate found but Object is nullptr: <nullptr file ptr>:%d, RefCount: %d\n",
                            extensionTriggerSystemDupInfo->Line, extensionTriggerSystemDupInfo->RefCount);
                    }
                }
            }

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

    return result;
}

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

    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(SAAlgorithm);

    result = module_version.Load(entry, alignment);
    if (result)
    {
        result = parameter_version.Load(entry, alignment);
    }

    // Reading Array SAAlgorithm from symbol table
    // Do not check result value here because the count value needs to be initialized in this block
    {
        SAAlgorithmCount = 0;
        SYMBOL_TABLE_ENTRY_READ(entry, result, SAAlgorithmCount, 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)
        {
            SAAlgorithmID = pointerEntry->ID;
            DupObjInfo* SAAlgorithmDupInfo = pointerEntry->GetDupObject(SAAlgorithmCount, file, line);
            if (SAAlgorithmDupInfo != nullptr && SAAlgorithmDupInfo->Object != nullptr)
            {
                SAAlgorithm = (SAAlgorithmType*)SAAlgorithmDupInfo->Object;
                if (SAAlgorithm == nullptr)
                {
                    if (SAAlgorithmDupInfo->File != nullptr)
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "SAAlgorithm duplicate found but object is nullptr: %s:%d, RefCount: %d\n",
                            SAAlgorithmDupInfo->File, SAAlgorithmDupInfo->Line, SAAlgorithmDupInfo->RefCount);
                    }
                    else
                    {
                        PARAMETER_LOG_ERROR(entry->SetManager, "SAAlgorithm duplicate found but Object is nullptr: <nullptr file ptr>:%d, RefCount: %d\n",
                            SAAlgorithmDupInfo->Line, SAAlgorithmDupInfo->RefCount);
                    }
                }
            }

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

    return result;
}

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

    PARAMETER_INITIALIZE(major_revision);
    PARAMETER_INITIALIZE(minor_revision);
    PARAMETER_INITIALIZE(incr_revision);

    SYMBOL_TABLE_ENTRY_READ(entry, result, major_revision, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, minor_revision, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, incr_revision, alignment)

    return result;
}

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

    PARAMETER_INITIALIZE(revision);


    // Reading String revision from symbol table
    {
        UINT32 count = 0;
        SYMBOL_TABLE_ENTRY_READ(entry, result, count, alignment)
        ParameterFileSymbolTableEntry stringPointerEntryCls;
        ParameterFileSymbolTableEntry* const stringPointerEntry = &stringPointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(stringPointerEntryCls, entry, alignment);
        }
        SYMBOL_TABLE_ENTRY_READ_STRING(stringPointerEntry, result, revision, count, alignment)
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload SAAlgorithmType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SAAlgorithmType::Unload(ParameterFileSymbolTable* const __table)
{
    if (__table != nullptr && __table->ReleaseDupObject(description))
    {
        PARAMETER_DELETE[] description;
    }
    description = nullptr;
    if (__table != nullptr && __table->ReleaseDupObject(extensionParameters))
    {
        PARAMETER_DELETE[] extensionParameters;
    }
    extensionParameters = nullptr;
    for (UINT32 i = 0; i < extensionTriggerSystemCount; i++)
    {
        extensionTriggerSystem[i].Unload(__table);
    }
    if (__table != nullptr && __table->ReleaseDupObject(extensionTriggerSystem))
    {
        PARAMETER_DELETE[] extensionTriggerSystem;
    }
    extensionTriggerSystem = nullptr;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload AECXMeteringSAAlgorithmType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECXMeteringSAAlgorithmType::Unload(ParameterFileSymbolTable* const __table)
{
    parameter_version.Unload(__table);
    for (UINT32 i = 0; i < SAAlgorithmCount; i++)
    {
        SAAlgorithm[i].Unload(__table);
    }
    if (__table != nullptr && __table->ReleaseDupObject(SAAlgorithm))
    {
        PARAMETER_DELETE[] SAAlgorithm;
    }
    SAAlgorithm = nullptr;
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Release the ParameterModule object
/// Requires that this object was created via a ParameterSetManager::GetModule call
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECXMeteringSAAlgorithmType::Release()
{
    ((AECXMeteringSAAlgorithmTypeClass*)this)->Release();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Returns the ParameterModule::Modified value
/// The Modified value is incremented when the module's data or pointer values change
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
UINT32 AECXMeteringSAAlgorithmType::GetModified()
{
    return ((AECXMeteringSAAlgorithmTypeClass*)this)->Modified;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Create module, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* AECXMeteringSAAlgorithmTypeClass::Create(
    ModuleData*    moduleData,
    DefaultModule* const defModule) const
{
    AECXMeteringSAAlgorithmTypeClass* cls = nullptr;

    if (PARAMETER_STRCMP(Type, moduleData->Type) == 0 && Version.Value == moduleData->Version.Value)
    {
        const UINT32 id = moduleData->DuplicateID > 0 ? moduleData->DuplicateID : moduleData->ID;

        ParameterModule* const module = defModule->Find(id);
        if (module != nullptr)
        {
            cls = (AECXMeteringSAAlgorithmTypeClass*)module;
        }
        else
        {
            cls = PARAMETER_NEW AECXMeteringSAAlgorithmTypeClass(GetName(moduleData->Type), moduleData);
            cls->SymbolTableID = id;
            defModule->AddModule((ParameterModule*)cls);
        }
    }
    else if (Version.Value != moduleData->Version.Value)
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create AECXMeteringSAAlgorithmTypeClass, binary version (%lld) does not match source version (%lld)\n",
            moduleData->Version.Value, Version.Value);
    }
    else
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create AECXMeteringSAAlgorithmTypeClass, binary name (%s) does not match source name (%s)\n",
            moduleData->Type, Type);
    }

    return (ParameterModule*)cls;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module data, return true is successful
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool AECXMeteringSAAlgorithmTypeClass::LoadModule(
    ParameterFileSymbolTable* const table)
{
    bool result = true;

    if (!Loaded)
    {
        BYTE const alignment = table->Alignment;
        AECXMeteringSAAlgorithmTypeClass* const cls = this;

        ParameterFileSymbolTableEntry  entryObj;
        ParameterFileSymbolTableEntry* const entry = &entryObj;
        // With EzTune enabled, the unused upper byte of SymbolTableID value can change, so clear it
        result = table->Find(entryObj, SymbolTableID & 0x00ffffff);

        if (!result)
        {
            PARAMETER_LOG_ERROR(entry->SetManager, "AECXMeteringSAAlgorithmTypeClass::LoadModule Failed to find module ID (%d) in Symbol Table\n", SymbolTableID);
        }

        if (result)
        {
            result = cls->Load(entry, alignment);
        }
        Modified++;
        Loaded = true;
    }

    if (!result)
    {
        /// Module failed to fully load, unload it
        UnloadModule();
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload module data
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECXMeteringSAAlgorithmTypeClass::UnloadModule()
{
    if (Loaded)
    {
        if (Data != nullptr && Data->SymbolTable != nullptr)
        {
            Unload(Data->SymbolTable);
        }
        else
        {
            PARAMETER_LOG_ERROR(Data != nullptr ? Data->SetManager : nullptr, "UnloadModule %s called with nullptr "
                "Data->SymbolTable object\n", Name);
            Unload(nullptr);
        }
        Loaded = false;
    }
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// /// Release the ParameterModule object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void AECXMeteringSAAlgorithmTypeClass::Release()
{
    ParameterModule::Release();
}

AECXMETERINGSAALGORITHM_NAMESPACE_END
