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

#include "camxflashdriver.h"
#include "parametersetmanager.h"

CAMX_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FlashDriverDataClass::FlashDriverDataClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, nullptr)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(flashName);
    PARAMETER_INITIALIZE(flashDriverType);
    PARAMETER_INITIALIZE(powerUpSequenceExists);
    PARAMETER_INITIALIZE(powerUpSequence);
    PARAMETER_INITIALIZE(powerDownSequenceExists);
    PARAMETER_INITIALIZE(powerDownSequence);
    PARAMETER_INITIALIZE(regAddrInfoFlashExists);
    PARAMETER_INITIALIZE(regAddrInfoFlash);
    PARAMETER_INITIALIZE(i2cInfoExists);
    PARAMETER_INITIALIZE(i2cInfo);
    PARAMETER_INITIALIZE(flashInformationExists);
    PARAMETER_INITIALIZE(flashInformation);
    PARAMETER_INITIALIZE(numberOfFlashs);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FlashDriverDataClass::FlashDriverDataClass(
    const CHAR*       name,
    ModuleData* const moduleData)
    : ParameterModule(name, MAJOR, MINOR, PATCH, moduleData)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(flashName);
    PARAMETER_INITIALIZE(flashDriverType);
    PARAMETER_INITIALIZE(powerUpSequence);
    PARAMETER_INITIALIZE(powerDownSequence);
    PARAMETER_INITIALIZE(regAddrInfoFlash);
    PARAMETER_INITIALIZE(i2cInfo);
    PARAMETER_INITIALIZE(flashInformation);
    PARAMETER_INITIALIZE(numberOfFlashs);
}

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


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load FlashI2CInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashI2CInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(slaveAddress);
    PARAMETER_INITIALIZE(regAddrType);
    PARAMETER_INITIALIZE(regDataType);
    PARAMETER_INITIALIZE(i2cFrequencyMode);
    PARAMETER_INITIALIZE(flashInitSettings);
    PARAMETER_INITIALIZE(flashOffSettings);
    PARAMETER_INITIALIZE(flashLowSettings);
    PARAMETER_INITIALIZE(flashHighSettings);

    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 = 0xe0fe821faa44eb3a;
        entry->ReadSimpleTypeFixedArray(&slaveAddress, 1, localParams);
        localParams.NameHash = 0xdba4345401ea46a7;
        entry->ReadSimpleTypeFixedArray(&regAddrType, 1, localParams);
        localParams.NameHash = 0xf5542d0f67cc3915;
        entry->ReadSimpleTypeFixedArray(&regDataType, 1, localParams);
        localParams.NameHash = 0x9a30e6f805a86ac5;
        entry->ReadEnumFixedArray(&i2cFrequencyMode, 1, localParams);
        localParams.UseParent       = false;
        localParams.UseParentOffset = true;
        localParams.NameHash        = 0xdb1ce8bf520e4a91;
        flashInitSettings.Load(localParams);
        localParams.NameHash        = 0xb11e5695d9367e26;
        flashOffSettings.Load(localParams);
        localParams.NameHash        = 0xec6345a217c96a45;
        flashLowSettings.Load(localParams);
        localParams.NameHash        = 0x938ee37aa295651c;
        flashHighSettings.Load(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 FlashI2CInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        FlashI2CInformation* arrayPtr = (FlashI2CInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load TriggerInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void TriggerInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(maxFlashCurrent);
    PARAMETER_INITIALIZE(maxTorchCurrent);
    PARAMETER_INITIALIZE(maxFlashDuration);

    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 = 0xe2dd6057680c6277;
        entry->ReadSimpleTypeFixedArray(&maxFlashCurrent, 1, localParams);
        localParams.NameHash = 0x883b19201764e9ff;
        entry->ReadSimpleTypeFixedArray(&maxTorchCurrent, 1, localParams);
        localParams.NameHash = 0xd915a46c9476a397;
        entry->ReadSimpleTypeFixedArray(&maxFlashDuration, 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 TriggerInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        TriggerInformation* arrayPtr = (TriggerInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load FlashInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(triggerInfoCount);
    PARAMETER_INITIALIZE(triggerInfo);

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load FlashRegAddrInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashRegAddrInformation::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(brightnessFlashLED1);
    PARAMETER_INITIALIZE(brightnessFlashLED2);
    PARAMETER_INITIALIZE(brightnessTorchLED1);
    PARAMETER_INITIALIZE(brightnessTorchLED2);

    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 = 0xc22cf824b438f9d7;
        entry->ReadSimpleTypeFixedArray(&brightnessFlashLED1, 1, localParams);
        localParams.NameHash = 0x8b004745a97405d9;
        entry->ReadSimpleTypeFixedArray(&brightnessFlashLED2, 1, localParams);
        localParams.NameHash = 0x8156776ed882f023;
        entry->ReadSimpleTypeFixedArray(&brightnessTorchLED1, 1, localParams);
        localParams.NameHash = 0xc87ac80fc5ce0c2d;
        entry->ReadSimpleTypeFixedArray(&brightnessTorchLED2, 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 FlashRegAddrInformation::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        FlashRegAddrInformation* arrayPtr = (FlashRegAddrInformation*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load FlashDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashDriverData::Load(
    ParameterLoadParameters& parentParams)
{
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(flashName);
    PARAMETER_INITIALIZE(flashDriverType);
    PARAMETER_INITIALIZE(powerUpSequenceExists);
    PARAMETER_INITIALIZE(powerUpSequence);
    PARAMETER_INITIALIZE(powerDownSequenceExists);
    PARAMETER_INITIALIZE(powerDownSequence);
    PARAMETER_INITIALIZE(regAddrInfoFlashExists);
    PARAMETER_INITIALIZE(regAddrInfoFlash);
    PARAMETER_INITIALIZE(i2cInfoExists);
    PARAMETER_INITIALIZE(i2cInfo);
    PARAMETER_INITIALIZE(flashInformationExists);
    PARAMETER_INITIALIZE(flashInformation);
    PARAMETER_INITIALIZE(numberOfFlashs);

    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 = 0xc1073b9a5e002a36;
        entry->ReadStringFixedArray(&flashName, 1, localParams, __COUNTER__);
        localParams.NameHash = 0xada4c5a2afcdb9f6;
        entry->ReadEnumFixedArray(&flashDriverType, 1, localParams);
        localParams.NameHash = 0x832c67f0d28e401d;
        entry->ReadOptionalStructure(powerUpSequence, powerUpSequenceExists, powerUpSequenceID, localParams);
        localParams.NameHash = 0x950f1749134c03dc;
        entry->ReadOptionalStructure(powerDownSequence, powerDownSequenceExists, powerDownSequenceID, localParams);
        localParams.NameHash = 0x9fcd21d012deae02;
        entry->ReadOptionalStructure(regAddrInfoFlash, regAddrInfoFlashExists, regAddrInfoFlashID, localParams);
        localParams.NameHash = 0xab2746113b36de02;
        entry->ReadOptionalStructure(i2cInfo, i2cInfoExists, i2cInfoID, localParams);
        localParams.NameHash = 0x8c4a7a1eb5f0e423;
        entry->ReadOptionalStructure(flashInformation, flashInformationExists, flashInformationID, localParams);
        localParams.NameHash = 0x9a039ced661fd6c7;
        entry->ReadSimpleTypeFixedArray(&numberOfFlashs, 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 FlashDriverData::LoadArray(
    ParameterLoadParameters& __params,
    void*                    __array,
    UINT32                   __count)
{
    if (__array != nullptr)
    {
        FlashDriverData* arrayPtr = (FlashDriverData*)__array;
        for (UINT32 i = 0; i < __count; i++)
        {
            __params.Index = i;
            arrayPtr[i].Load(__params);
        }
    }
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashDriverData::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 FlashDriverData::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* FlashDriverData::module_versionStruct::AllocArray(
    UINT32 __count)
{
    module_versionStruct* result = nullptr;
    if (__count > 0)
    {
        result = PARAMETER_NEW module_versionStruct[__count];
    }
    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload FlashI2CInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashI2CInformation::Unload(ParameterFileSymbolTable* const __table)
{
    flashInitSettings.Unload(__table);
    flashOffSettings.Unload(__table);
    flashLowSettings.Unload(__table);
    flashHighSettings.Unload(__table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload FlashInformation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashInformation::Unload(ParameterFileSymbolTable* const __table)
{
    ParameterFileSymbolTable::ReleaseObject(__table, triggerInfo);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload FlashDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void FlashDriverData::Unload(ParameterFileSymbolTable* const __table)
{
    ParameterFileSymbolTable::ReleaseObject(__table, flashName);
    powerUpSequence.Unload(__table);
    powerDownSequence.Unload(__table);
    i2cInfo.Unload(__table);
    flashInformation.Unload(__table);
}

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

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

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Create module, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* FlashDriverDataClass::Create(
    ModuleData* const    moduleData,
    DefaultModule* const defModule) const
{
    FlashDriverDataClass* 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 = (FlashDriverDataClass*)module;
        }
        else
        {
            cls = PARAMETER_NEW FlashDriverDataClass(Name, moduleData);
            cls->SymbolTableID = id;
            defModule->AddModule((ParameterModule*)cls);
        }
    }
    else if (Version.Value != moduleData->Version.Value)
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create FlashDriverDataClass, binary version (%lld) does not match source version (%lld)\n",
            moduleData->Version.Value, Version.Value);
    }
    else
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create FlashDriverDataClass, 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 FlashDriverDataClass::LoadModule(
    ParameterFileSymbolTable* const table)
{
    bool result = true;

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

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

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

        if (!result)
        {
            PARAMETER_LOG_ERROR(entry->Table->SetManager, "FlashDriverDataClass::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 FlashDriverDataClass::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 FlashDriverDataClass::Release()
{
    ParameterModule::Release();
}

CAMX_NAMESPACE_END
