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

#include "camxpdafconfig.h"
#include "parametersetmanager.h"

CAMX_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PDAFConfigurationDataClass::PDAFConfigurationDataClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, nullptr)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(PDCommonInfo);
    PARAMETER_INITIALIZE(PDModeInfoCount);
    PARAMETER_INITIALIZE(PDModeInfo);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PDAFConfigurationDataClass::PDAFConfigurationDataClass(
    const CHAR*       name,
    ModuleData* const moduleData)
    : ParameterModule(name, MAJOR, MINOR, PATCH, moduleData)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(PDCommonInfo);
    PARAMETER_INITIALIZE(PDModeInfo);
}

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


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(PDAFName);
    PARAMETER_INITIALIZE(PDOrientation);
    PARAMETER_INITIALIZE(PDDefocusConfidenceThreshold);
    PARAMETER_INITIALIZE(PDBlackLevelExists);
    PARAMETER_INITIALIZE(PDBlackLevel);

    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 = 0xea104b68501856c7;
        entry->ReadStringFixedArray(&PDAFName, 1, localParams, __COUNTER__);
        localParams.NameHash = 0xf06d0c619dcd8113;
        entry->ReadEnumFixedArray(&PDOrientation, 1, localParams);
        localParams.NameHash = 0xdacf79883c00a64e;
        entry->ReadSimpleTypeFixedArray(&PDDefocusConfidenceThreshold, 1, localParams);
        localParams.NameHash = 0x854c9cfb83bb8b05;
        entry->ReadOptionalSimpleType(PDBlackLevel, PDBlackLevelExists, PDBlackLevelID, 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 PDAFInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFInformation* arrayPtr = (PDAFInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFPixelCoordinates
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFPixelCoordinates::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(PDXCoordinate);
    PARAMETER_INITIALIZE(PDYCoordinate);
    PARAMETER_INITIALIZE(PDPixelShieldInformation);
    PARAMETER_INITIALIZE(PDExposureTypeExists);
    PARAMETER_INITIALIZE(PDExposureType);

    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 = 0xa388d679e24ebe5c;
        entry->ReadSimpleTypeFixedArray(&PDXCoordinate, 1, localParams);
        localParams.NameHash = 0xc24a61dae8fdd5e6;
        entry->ReadSimpleTypeFixedArray(&PDYCoordinate, 1, localParams);
        localParams.NameHash = 0xcbbc1e114f219e02;
        entry->ReadEnumFixedArray(&PDPixelShieldInformation, 1, localParams);
        localParams.NameHash = 0xec52b4d30b242649;
        entry->ReadOptionalEnum(PDExposureType, PDExposureTypeExists, PDExposureTypeID, 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 PDAFPixelCoordinates::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFPixelCoordinates* arrayPtr = (PDAFPixelCoordinates*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFBlockPattern
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFBlockPattern::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(PDPixelCount);
    PARAMETER_INITIALIZE(PDPixelCoordinatesCount);
    PARAMETER_INITIALIZE(PDPixelCoordinates);
    PARAMETER_INITIALIZE(PDBlockDimensions);
    PARAMETER_INITIALIZE(PDOffsetHorizontal);
    PARAMETER_INITIALIZE(PDOffsetVertical);

    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 = 0xa4dfb119640f2ee3;
        entry->ReadSimpleTypeFixedArray(&PDPixelCount, 1, localParams);
        localParams.NameHash = 0xc5a4b52748a782db;
        entry->ReadStructureArray(PDPixelCoordinates, PDPixelCoordinatesCount, PDPixelCoordinatesID, 1, localParams, __COUNTER__);
        localParams.UseParent       = false;
        localParams.UseParentOffset = true;
        localParams.NameHash        = 0xa00d3bf72e852e5f;
        PDBlockDimensions.Load(localParams);
        localParams.NameHash = 0x874b0dff8533127c;
        entry->ReadSimpleTypeFixedArray(&PDOffsetHorizontal, 1, localParams);
        localParams.NameHash = 0xaeee700caae13547;
        entry->ReadSimpleTypeFixedArray(&PDOffsetVertical, 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 PDAFBlockPattern::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFBlockPattern* arrayPtr = (PDAFBlockPattern*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFSensorNativePatternInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFSensorNativePatternInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(PDBlockCountHorizontal);
    PARAMETER_INITIALIZE(PDBlockCountVertical);
    PARAMETER_INITIALIZE(PDBlockPatternExists);
    PARAMETER_INITIALIZE(PDBlockPattern);
    PARAMETER_INITIALIZE(PDCropRegion);
    PARAMETER_INITIALIZE(PDDownscaleFactorHorizontal);
    PARAMETER_INITIALIZE(PDDownscaleFactorVertical);
    PARAMETER_INITIALIZE(PDNativeBufferFormat);

    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 = 0xed52dd2425e9a45a;
        entry->ReadSimpleTypeFixedArray(&PDBlockCountHorizontal, 1, localParams);
        localParams.NameHash = 0xd6cfc2316e2e332c;
        entry->ReadSimpleTypeFixedArray(&PDBlockCountVertical, 1, localParams);
        localParams.NameHash = 0xf504f1c945fc5bde;
        entry->ReadOptionalStructure(PDBlockPattern, PDBlockPatternExists, PDBlockPatternID, localParams);
        localParams.UseParent       = false;
        localParams.UseParentOffset = true;
        localParams.NameHash        = 0xdc9709e8cdc3abf8;
        PDCropRegion.Load(localParams);
        localParams.NameHash = 0xfe841b00d4ac5cdf;
        entry->ReadSimpleTypeFixedArray(&PDDownscaleFactorHorizontal, 1, localParams);
        localParams.NameHash = 0x965102a546e5d88c;
        entry->ReadSimpleTypeFixedArray(&PDDownscaleFactorVertical, 1, localParams);
        localParams.NameHash = 0xfb7921c7c62414cb;
        entry->ReadEnumFixedArray(&PDNativeBufferFormat, 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 PDAFSensorNativePatternInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFSensorNativePatternInformation* arrayPtr = (PDAFSensorNativePatternInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFBlockPatternInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFBlockPatternInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(PDStride);
    PARAMETER_INITIALIZE(PDBufferFormat);
    PARAMETER_INITIALIZE(PDBlockPatternExists);
    PARAMETER_INITIALIZE(PDBlockPattern);

    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 = 0xc62c16e69806b6ae;
        entry->ReadSimpleTypeFixedArray(&PDStride, 1, localParams);
        localParams.NameHash = 0xce1db743c5f0efcc;
        entry->ReadEnumFixedArray(&PDBufferFormat, 1, localParams);
        localParams.NameHash = 0xf504f1c945fc5bde;
        entry->ReadOptionalStructure(PDBlockPattern, PDBlockPatternExists, PDBlockPatternID, 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 PDAFBlockPatternInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFBlockPatternInformation* arrayPtr = (PDAFBlockPatternInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFModeInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFModeInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(PDSensorNativePatternInfoExists);
    PARAMETER_INITIALIZE(PDSensorNativePatternInfo);
    PARAMETER_INITIALIZE(PDBufferBlockPatternInfoExists);
    PARAMETER_INITIALIZE(PDBufferBlockPatternInfo);
    PARAMETER_INITIALIZE(PDType);
    PARAMETER_INITIALIZE(PDSensorModeExists);
    PARAMETER_INITIALIZE(PDSensorMode);
    PARAMETER_INITIALIZE(PDModeKeyExists);
    PARAMETER_INITIALIZE(PDModeKey);
    PARAMETER_INITIALIZE(PDAFLibraryName);
    PARAMETER_INITIALIZE(PDSensorPDStatsFormatExists);
    PARAMETER_INITIALIZE(PDSensorPDStatsFormat);
    PARAMETER_INITIALIZE(PDSensorOutputFormatExists);
    PARAMETER_INITIALIZE(PDSensorOutputFormat);
    PARAMETER_INITIALIZE(lcrPDOffsetCorrectionExists);
    PARAMETER_INITIALIZE(lcrPDOffsetCorrection);
    PARAMETER_INITIALIZE(PDPixelOrderTypeExists);
    PARAMETER_INITIALIZE(PDPixelOrderType);
    PARAMETER_INITIALIZE(PDoffsetmapIDExists);
    PARAMETER_INITIALIZE(PDoffsetmapID);
    PARAMETER_INITIALIZE(PDOffsetCorrectionExists);
    PARAMETER_INITIALIZE(PDOffsetCorrection);

    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 = 0xaff08cac7c98b44b;
        entry->ReadOptionalStructure(PDSensorNativePatternInfo, PDSensorNativePatternInfoExists, PDSensorNativePatternInfoID, localParams);
        localParams.NameHash = 0xc128a058ef741f82;
        entry->ReadOptionalStructure(PDBufferBlockPatternInfo, PDBufferBlockPatternInfoExists, PDBufferBlockPatternInfoID, localParams);
        localParams.NameHash = 0xbfdd6170c3b5b8c4;
        entry->ReadEnumFixedArray(&PDType, 1, localParams);
        localParams.NameHash = 0xc0dafbdac23c8d16;
        entry->ReadOptionalSimpleType(PDSensorMode, PDSensorModeExists, PDSensorModeID, localParams);
        localParams.NameHash = 0xa6596b395ed8cece;
        entry->ReadOptionalSimpleType(PDModeKey, PDModeKeyExists, PDModeKeyID, localParams);
        localParams.NameHash = 0xc3f49413d69525eb;
        entry->ReadStringFixedArray(&PDAFLibraryName, 1, localParams, __COUNTER__);
        localParams.NameHash = 0x80a9da988d9bc31b;
        entry->ReadOptionalEnum(PDSensorPDStatsFormat, PDSensorPDStatsFormatExists, PDSensorPDStatsFormatID, localParams);
        localParams.NameHash = 0xdad4fda41173fea5;
        entry->ReadOptionalEnum(PDSensorOutputFormat, PDSensorOutputFormatExists, PDSensorOutputFormatID, localParams);
        localParams.NameHash = 0xe4d0cafae63fc634;
        entry->ReadOptionalSimpleType(lcrPDOffsetCorrection, lcrPDOffsetCorrectionExists, lcrPDOffsetCorrectionID, localParams);
        localParams.NameHash = 0x841f74a3feec719e;
        entry->ReadOptionalEnum(PDPixelOrderType, PDPixelOrderTypeExists, PDPixelOrderTypeID, localParams);
        localParams.NameHash = 0x9f84f3f275143fde;
        entry->ReadOptionalSimpleType(PDoffsetmapID, PDoffsetmapIDExists, PDoffsetmapIDID, localParams);
        localParams.NameHash = 0x97c20a015565ae99;
        entry->ReadOptionalSimpleType(PDOffsetCorrection, PDOffsetCorrectionExists, PDOffsetCorrectionID, 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 PDAFModeInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFModeInformation* arrayPtr = (PDAFModeInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load PDAFConfigurationData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFConfigurationData::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(PDCommonInfo);
    PARAMETER_INITIALIZE(PDModeInfoCount);
    PARAMETER_INITIALIZE(PDModeInfo);

    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.UseParent       = false;
        localParams.UseParentOffset = true;
        localParams.NameHash        = 0xe11cd9f365a2599f;
        module_version.Load(localParams);
        localParams.NameHash        = 0x9d744ca7f70dc66d;
        PDCommonInfo.Load(localParams);
        localParams.NameHash = 0x865541c292c27f6f;
        entry->ReadStructureArray(PDModeInfo, PDModeInfoCount, PDModeInfoID, 1, localParams, __COUNTER__);

        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 PDAFConfigurationData::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        PDAFConfigurationData* arrayPtr = (PDAFConfigurationData*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFConfigurationData::module_versionStruct::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(major_revision);
    PARAMETER_INITIALIZE(minor_revision);
    PARAMETER_INITIALIZE(incr_revision);

    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 = 0xcd66249477636693;
        entry->ReadSimpleTypeFixedArray(&major_revision, 1, localParams);
        localParams.NameHash = 0xc5497493137a9c25;
        entry->ReadSimpleTypeFixedArray(&minor_revision, 1, localParams);
        localParams.NameHash = 0xb27b8a668efb2a56;
        entry->ReadSimpleTypeFixedArray(&incr_revision, 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 PDAFConfigurationData::module_versionStruct::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        module_versionStruct* arrayPtr = (module_versionStruct*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PDAFInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFInformation::Unload(ParameterFileSymbolTable* const __table)
{
    ParameterFileSymbolTable::ReleaseObject(__table, PDAFName);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PDAFBlockPattern
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFBlockPattern::Unload(ParameterFileSymbolTable* const __table)
{
    ParameterFileSymbolTable::ReleaseObject(__table, PDPixelCoordinates);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PDAFSensorNativePatternInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFSensorNativePatternInformation::Unload(ParameterFileSymbolTable* const __table)
{
    PDBlockPattern.Unload(__table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PDAFBlockPatternInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFBlockPatternInformation::Unload(ParameterFileSymbolTable* const __table)
{
    PDBlockPattern.Unload(__table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PDAFModeInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFModeInformation::Unload(ParameterFileSymbolTable* const __table)
{
    PDSensorNativePatternInfo.Unload(__table);
    PDBufferBlockPatternInfo.Unload(__table);
    ParameterFileSymbolTable::ReleaseObject(__table, PDAFLibraryName);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload PDAFConfigurationData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFConfigurationData::Unload(ParameterFileSymbolTable* const __table)
{
    PDCommonInfo.Unload(__table);
    for (UINT32 i = 0; PDModeInfo != nullptr && i < PDModeInfoCount; i++)
    {
        PDModeInfo[i].Unload(__table);
    }
    ParameterFileSymbolTable::ReleaseObject(__table, PDModeInfo);
}

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetModuleName: Returns ParameterModule::Name variable
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* PDAFConfigurationData::GetModuleName()
{
    return ((PDAFConfigurationDataClass*)this)->Name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetModuleName: Returns ParameterModule::NameHash variable
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
UINT64 PDAFConfigurationData::GetModuleNameHash()
{
    return ((PDAFConfigurationDataClass*)this)->NameHash;
}

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

    if (IsModuleMatch(moduleData) && 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 = (PDAFConfigurationDataClass*)module;
        }
        else
        {
            cls = PARAMETER_NEW PDAFConfigurationDataClass(Name, moduleData);
            cls->SymbolTableID = id;
            defModule->AddModule((ParameterModule*)cls);
        }
    }
    else if (Version.Value != moduleData->Version.Value)
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create PDAFConfigurationDataClass, binary version (%lld) does not match source version (%lld)\n",
            moduleData->Version.Value, Version.Value);
    }
    else
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create PDAFConfigurationDataClass, binary name hash (0x%016llx) does not match source name hash (0x%016llx)\n",
            moduleData->NameHash, NameHash);
    }

    return (ParameterModule*)cls;
}

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

#ifdef PARAMETER_USE_MUTEX
    ParameterMutexLocker lock(Mutex); // Unique LOCK
#endif

    if (!Loaded)
    {
        PDAFConfigurationDataClass* const cls = this;

        ParameterFileSymbolTableEntry  entryObj;
        ParameterFileSymbolTableEntry* const entry = &entryObj;
        result = table->Find(entryObj, SymbolTableID);

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


        ParameterDefinitionElement* _element = nullptr;
        if (table->ModuleDefinitions != nullptr && !table->ModuleDefinitions->empty())
        {
            _element = table->BuildModuleElement(NameHash);
        }

        ParameterLoadParameters parentParams(entry, NameHash, true, true, _element, entry->Position, 0, ParameterFileSymbolTableEntry::LOAD_LIMIT_MAX);
        cls->Load(parentParams);
        PARAMETER_DELETE _element;
        Modified++;
        Loaded = true;
    }

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

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload module data
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void PDAFConfigurationDataClass::UnloadModule()
{
#ifdef PARAMETER_USE_MUTEX
    ParameterMutexLocker lock(Mutex); // Unique LOCK
#endif

    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 PDAFConfigurationDataClass::Release()
{
    ParameterModule::Release();
}

CAMX_NAMESPACE_END
