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

#include "camxoisdriver.h"
#include "parametersetmanager.h"

CAMX_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SetValue/GetValue Functions
/// Gets or sets the requested value
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Read enum value
/// @param entry [in] Symbol table entry
/// @param enumValue [out] Enum value to read
/// @param alignment [in] Symbol table byte alignment
/// @return true if successful
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ReadEnum_TimeStampUnitInfo(
    ParameterFileSymbolTableEntry* const entry,
    TimeStampUnitInfo& enumValue,
    BYTE const alignment)
{
    bool result {false};

    UINT32 uintValue {entry->ReadEnum(&result, alignment)};

    if (result)
    {
        switch (uintValue)
        {
        case static_cast<UINT32>(TimeStampUnitInfo::MILLISECONDS):
            enumValue = TimeStampUnitInfo::MILLISECONDS;
            result    = true;
            break;
        case static_cast<UINT32>(TimeStampUnitInfo::MICROSECONDS):
            enumValue = TimeStampUnitInfo::MICROSECONDS;
            result    = true;
            break;
        case static_cast<UINT32>(TimeStampUnitInfo::NANOSECONDS):
            enumValue = TimeStampUnitInfo::NANOSECONDS;
            result    = true;
            break;
        case static_cast<UINT32>(TimeStampUnitInfo::INTERNALCLOCKTICKS):
            enumValue = TimeStampUnitInfo::INTERNALCLOCKTICKS;
            result    = true;
            break;
        default:
            PARAMETER_LOG_ERROR(entry->SetManager, "Invalid value(% u) converting UINT32 to TimeStampUnitInfo", uintValue);
            break;
        }
    }
    return result;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OISDriverDataClass::OISDriverDataClass(
    const CHAR* const name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, nullptr)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(opcode);
    PARAMETER_INITIALIZE(oisfwinitSettingsExists);
    PARAMETER_INITIALIZE(oisfwinitSettings);
    PARAMETER_INITIALIZE(oisfwInfomationExists);
    PARAMETER_INITIALIZE(oisfwInfomation);
    PARAMETER_INITIALIZE(oisCalibSettingsExists);
    PARAMETER_INITIALIZE(oisCalibSettings);
    PARAMETER_INITIALIZE(oisinitSettings);
    PARAMETER_INITIALIZE(enableOisSettings);
    PARAMETER_INITIALIZE(disableOisSettings);
    PARAMETER_INITIALIZE(enterDownloadModeSettingsExists);
    PARAMETER_INITIALIZE(enterDownloadModeSettings);
    PARAMETER_INITIALIZE(movieModeSettingsExists);
    PARAMETER_INITIALIZE(movieModeSettings);
    PARAMETER_INITIALIZE(stillModeSettingsExists);
    PARAMETER_INITIALIZE(stillModeSettings);
    PARAMETER_INITIALIZE(centeringOnSettingsExists);
    PARAMETER_INITIALIZE(centeringOnSettings);
    PARAMETER_INITIALIZE(centeringOffSettingsExists);
    PARAMETER_INITIALIZE(centeringOffSettings);
    PARAMETER_INITIALIZE(pantiltOnSettingsExists);
    PARAMETER_INITIALIZE(pantiltOnSettings);
    PARAMETER_INITIALIZE(sceneOisSettingsExists);
    PARAMETER_INITIALIZE(sceneOisSettings);
    PARAMETER_INITIALIZE(sceneFilterOnSettingsExists);
    PARAMETER_INITIALIZE(sceneFilterOnSettings);
    PARAMETER_INITIALIZE(sceneFilterOffSettingsExists);
    PARAMETER_INITIALIZE(sceneFilterOffSettings);
    PARAMETER_INITIALIZE(sceneRangeOnSettingsExists);
    PARAMETER_INITIALIZE(sceneRangeOnSettings);
    PARAMETER_INITIALIZE(sceneRangeOffSettingsExists);
    PARAMETER_INITIALIZE(sceneRangeOffSettings);
    PARAMETER_INITIALIZE(lensPositionReadInfoExists);
    PARAMETER_INITIALIZE(lensPositionReadInfo);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OISDriverDataClass::OISDriverDataClass(
    const CHAR* const name,
    ModuleData* const moduleData)
    : ParameterModule(name, MAJOR, MINOR, PATCH, moduleData)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(opcode);
    PARAMETER_INITIALIZE(oisfwinitSettings);
    PARAMETER_INITIALIZE(oisfwInfomation);
    PARAMETER_INITIALIZE(oisCalibSettings);
    PARAMETER_INITIALIZE(oisinitSettings);
    PARAMETER_INITIALIZE(enableOisSettings);
    PARAMETER_INITIALIZE(disableOisSettings);
    PARAMETER_INITIALIZE(enterDownloadModeSettings);
    PARAMETER_INITIALIZE(movieModeSettings);
    PARAMETER_INITIALIZE(stillModeSettings);
    PARAMETER_INITIALIZE(centeringOnSettings);
    PARAMETER_INITIALIZE(centeringOffSettings);
    PARAMETER_INITIALIZE(pantiltOnSettings);
    PARAMETER_INITIALIZE(sceneOisSettings);
    PARAMETER_INITIALIZE(sceneFilterOnSettings);
    PARAMETER_INITIALIZE(sceneFilterOffSettings);
    PARAMETER_INITIALIZE(sceneRangeOnSettings);
    PARAMETER_INITIALIZE(sceneRangeOffSettings);
    PARAMETER_INITIALIZE(lensPositionReadInfo);
}

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

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

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

    PARAMETER_INITIALIZE(OISName);
    PARAMETER_INITIALIZE(slaveAddress);
    PARAMETER_INITIALIZE(i2cFrequencyMode);
    PARAMETER_INITIALIZE(fwflag);
    PARAMETER_INITIALIZE(oiscalib);
    PARAMETER_INITIALIZE(powerUpSequence);
    PARAMETER_INITIALIZE(powerDownSequence);


    // Reading String OISName 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, OISName, count, alignment)
    }
    SYMBOL_TABLE_ENTRY_READ(entry, result, slaveAddress, alignment)
    if (result)
    {
        result = ReadEnum_I2CFrequencyMode(entry, i2cFrequencyMode, alignment);
    }
    SYMBOL_TABLE_ENTRY_READ(entry, result, fwflag, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, oiscalib, alignment)
    if (result)
    {
        result = powerUpSequence.Load(entry, alignment);
    }
    if (result)
    {
        result = powerDownSequence.Load(entry, alignment);
    }

    return result;
}

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

    PARAMETER_INITIALIZE(prog);
    PARAMETER_INITIALIZE(coeff);
    PARAMETER_INITIALIZE(pheripheral);
    PARAMETER_INITIALIZE(memory);

    SYMBOL_TABLE_ENTRY_READ(entry, result, prog, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, coeff, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, pheripheral, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, memory, alignment)

    return result;
}

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

    PARAMETER_INITIALIZE(offset);
    PARAMETER_INITIALIZE(sizeInBytes);
    PARAMETER_INITIALIZE(offsetIncrementBytes);

    SYMBOL_TABLE_ENTRY_READ(entry, result, offset, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, sizeInBytes, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, offsetIncrementBytes, alignment)

    return result;
}

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

    PARAMETER_INITIALIZE(positionValidSamples);
    PARAMETER_INITIALIZE(positionX);
    PARAMETER_INITIALIZE(positionY);
    PARAMETER_INITIALIZE(timeStamp);
    PARAMETER_INITIALIZE(isPerSampleTimestamp);
    PARAMETER_INITIALIZE(timerClockFrequencyExists);
    PARAMETER_INITIALIZE(timerClockFrequency);
    PARAMETER_INITIALIZE(timeStampUnit);

    result = positionValidSamples.Load(entry, alignment);
    if (result)
    {
        result = positionX.Load(entry, alignment);
    }
    if (result)
    {
        result = positionY.Load(entry, alignment);
    }
    if (result)
    {
        result = timeStamp.Load(entry, alignment);
    }
    SYMBOL_TABLE_ENTRY_READ(entry, result, isPerSampleTimestamp, alignment)

    // Reading Optional parameter timerClockFrequency from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, timerClockFrequencyExists, alignment)
        timerClockFrequencyID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && timerClockFrequencyExists)
        {
            SYMBOL_TABLE_ENTRY_READ(pointerEntry, result, timerClockFrequency, alignment)
        }
        else
        {
            PARAMETER_INITIALIZE(timerClockFrequency);
        }
    }
    if (result)
    {
        result = ReadEnum_TimeStampUnitInfo(entry, timeStampUnit, alignment);
    }

    return result;
}

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

    PARAMETER_INITIALIZE(sampleFrequencyInHZ);
    PARAMETER_INITIALIZE(totalSamples);
    PARAMETER_INITIALIZE(readIntervalInMS);
    PARAMETER_INITIALIZE(readSettings);
    PARAMETER_INITIALIZE(writeTimeSettingsExists);
    PARAMETER_INITIALIZE(writeTimeSettings);
    PARAMETER_INITIALIZE(formatInfoExists);
    PARAMETER_INITIALIZE(formatInfo);

    SYMBOL_TABLE_ENTRY_READ(entry, result, sampleFrequencyInHZ, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, totalSamples, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, readIntervalInMS, alignment)
    if (result)
    {
        result = readSettings.Load(entry, alignment);
    }

    // Reading Optional parameter writeTimeSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, writeTimeSettingsExists, alignment)
        writeTimeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && writeTimeSettingsExists)
        {
            if (result)
            {
                result = writeTimeSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(writeTimeSettings);
        }
    }

    // Reading Optional parameter formatInfo from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, formatInfoExists, alignment)
        formatInfoID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && formatInfoExists)
        {
            if (result)
            {
                result = formatInfo.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(formatInfo);
        }
    }

    return result;
}

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

    PARAMETER_INITIALIZE(fwName);
    PARAMETER_INITIALIZE(fwStartPositionByte);
    PARAMETER_INITIALIZE(fwWriteSizeInBytes);
    PARAMETER_INITIALIZE(fwLenPerWriteInBytes);
    PARAMETER_INITIALIZE(fwRegAddr);
    PARAMETER_INITIALIZE(fwInitExists);
    PARAMETER_INITIALIZE(fwInit);
    PARAMETER_INITIALIZE(fwVersionCheckExists);
    PARAMETER_INITIALIZE(fwVersionCheck);
    PARAMETER_INITIALIZE(fwFinalizeExists);
    PARAMETER_INITIALIZE(fwFinalize);


    // Reading String fwName 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, fwName, count, alignment)
    }
    SYMBOL_TABLE_ENTRY_READ(entry, result, fwStartPositionByte, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, fwWriteSizeInBytes, alignment)
    SYMBOL_TABLE_ENTRY_READ(entry, result, fwLenPerWriteInBytes, alignment)
    if (result)
    {
        result = fwRegAddr.Load(entry, alignment);
    }

    // Reading Optional parameter fwInit from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, fwInitExists, alignment)
        fwInitID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && fwInitExists)
        {
            if (result)
            {
                result = fwInit.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(fwInit);
        }
    }

    // Reading Optional parameter fwVersionCheck from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, fwVersionCheckExists, alignment)
        fwVersionCheckID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && fwVersionCheckExists)
        {
            if (result)
            {
                result = fwVersionCheck.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(fwVersionCheck);
        }
    }

    // Reading Optional parameter fwFinalize from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, fwFinalizeExists, alignment)
        fwFinalizeID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && fwFinalizeExists)
        {
            if (result)
            {
                result = fwFinalize.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(fwFinalize);
        }
    }

    return result;
}

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

    PARAMETER_INITIALIZE(fwEndianness);
    PARAMETER_INITIALIZE(oisEndianness);
    PARAMETER_INITIALIZE(oisfwData);

    result = ReadEnum_EndianType(entry, fwEndianness, alignment);
    if (result)
    {
        result = ReadEnum_EndianType(entry, oisEndianness, alignment);
    }

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

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

    return result;
}

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

    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(slaveInfo);
    PARAMETER_INITIALIZE(opcode);
    PARAMETER_INITIALIZE(oisfwinitSettingsExists);
    PARAMETER_INITIALIZE(oisfwinitSettings);
    PARAMETER_INITIALIZE(oisfwInfomationExists);
    PARAMETER_INITIALIZE(oisfwInfomation);
    PARAMETER_INITIALIZE(oisCalibSettingsExists);
    PARAMETER_INITIALIZE(oisCalibSettings);
    PARAMETER_INITIALIZE(oisinitSettings);
    PARAMETER_INITIALIZE(enableOisSettings);
    PARAMETER_INITIALIZE(disableOisSettings);
    PARAMETER_INITIALIZE(enterDownloadModeSettingsExists);
    PARAMETER_INITIALIZE(enterDownloadModeSettings);
    PARAMETER_INITIALIZE(movieModeSettingsExists);
    PARAMETER_INITIALIZE(movieModeSettings);
    PARAMETER_INITIALIZE(stillModeSettingsExists);
    PARAMETER_INITIALIZE(stillModeSettings);
    PARAMETER_INITIALIZE(centeringOnSettingsExists);
    PARAMETER_INITIALIZE(centeringOnSettings);
    PARAMETER_INITIALIZE(centeringOffSettingsExists);
    PARAMETER_INITIALIZE(centeringOffSettings);
    PARAMETER_INITIALIZE(pantiltOnSettingsExists);
    PARAMETER_INITIALIZE(pantiltOnSettings);
    PARAMETER_INITIALIZE(sceneOisSettingsExists);
    PARAMETER_INITIALIZE(sceneOisSettings);
    PARAMETER_INITIALIZE(sceneFilterOnSettingsExists);
    PARAMETER_INITIALIZE(sceneFilterOnSettings);
    PARAMETER_INITIALIZE(sceneFilterOffSettingsExists);
    PARAMETER_INITIALIZE(sceneFilterOffSettings);
    PARAMETER_INITIALIZE(sceneRangeOnSettingsExists);
    PARAMETER_INITIALIZE(sceneRangeOnSettings);
    PARAMETER_INITIALIZE(sceneRangeOffSettingsExists);
    PARAMETER_INITIALIZE(sceneRangeOffSettings);
    PARAMETER_INITIALIZE(lensPositionReadInfoExists);
    PARAMETER_INITIALIZE(lensPositionReadInfo);

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

    // Reading Optional parameter oisfwinitSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, oisfwinitSettingsExists, alignment)
        oisfwinitSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && oisfwinitSettingsExists)
        {
            if (result)
            {
                result = oisfwinitSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(oisfwinitSettings);
        }
    }

    // Reading Optional parameter oisfwInfomation from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, oisfwInfomationExists, alignment)
        oisfwInfomationID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && oisfwInfomationExists)
        {
            if (result)
            {
                result = oisfwInfomation.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(oisfwInfomation);
        }
    }

    // Reading Optional parameter oisCalibSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, oisCalibSettingsExists, alignment)
        oisCalibSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && oisCalibSettingsExists)
        {
            if (result)
            {
                result = oisCalibSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(oisCalibSettings);
        }
    }
    if (result)
    {
        result = oisinitSettings.Load(entry, alignment);
    }
    if (result)
    {
        result = enableOisSettings.Load(entry, alignment);
    }
    if (result)
    {
        result = disableOisSettings.Load(entry, alignment);
    }

    // Reading Optional parameter enterDownloadModeSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, enterDownloadModeSettingsExists, alignment)
        enterDownloadModeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && enterDownloadModeSettingsExists)
        {
            if (result)
            {
                result = enterDownloadModeSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(enterDownloadModeSettings);
        }
    }

    // Reading Optional parameter movieModeSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, movieModeSettingsExists, alignment)
        movieModeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && movieModeSettingsExists)
        {
            if (result)
            {
                result = movieModeSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(movieModeSettings);
        }
    }

    // Reading Optional parameter stillModeSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, stillModeSettingsExists, alignment)
        stillModeSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && stillModeSettingsExists)
        {
            if (result)
            {
                result = stillModeSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(stillModeSettings);
        }
    }

    // Reading Optional parameter centeringOnSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, centeringOnSettingsExists, alignment)
        centeringOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && centeringOnSettingsExists)
        {
            if (result)
            {
                result = centeringOnSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(centeringOnSettings);
        }
    }

    // Reading Optional parameter centeringOffSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, centeringOffSettingsExists, alignment)
        centeringOffSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && centeringOffSettingsExists)
        {
            if (result)
            {
                result = centeringOffSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(centeringOffSettings);
        }
    }

    // Reading Optional parameter pantiltOnSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, pantiltOnSettingsExists, alignment)
        pantiltOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && pantiltOnSettingsExists)
        {
            if (result)
            {
                result = pantiltOnSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(pantiltOnSettings);
        }
    }

    // Reading Optional parameter sceneOisSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, sceneOisSettingsExists, alignment)
        sceneOisSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && sceneOisSettingsExists)
        {
            if (result)
            {
                result = sceneOisSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(sceneOisSettings);
        }
    }

    // Reading Optional parameter sceneFilterOnSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, sceneFilterOnSettingsExists, alignment)
        sceneFilterOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && sceneFilterOnSettingsExists)
        {
            if (result)
            {
                result = sceneFilterOnSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(sceneFilterOnSettings);
        }
    }

    // Reading Optional parameter sceneFilterOffSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, sceneFilterOffSettingsExists, alignment)
        sceneFilterOffSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && sceneFilterOffSettingsExists)
        {
            if (result)
            {
                result = sceneFilterOffSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(sceneFilterOffSettings);
        }
    }

    // Reading Optional parameter sceneRangeOnSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, sceneRangeOnSettingsExists, alignment)
        sceneRangeOnSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && sceneRangeOnSettingsExists)
        {
            if (result)
            {
                result = sceneRangeOnSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(sceneRangeOnSettings);
        }
    }

    // Reading Optional parameter sceneRangeOffSettings from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, sceneRangeOffSettingsExists, alignment)
        sceneRangeOffSettingsID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && sceneRangeOffSettingsExists)
        {
            if (result)
            {
                result = sceneRangeOffSettings.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(sceneRangeOffSettings);
        }
    }

    // Reading Optional parameter lensPositionReadInfo from symbol table
    {
        SYMBOL_TABLE_ENTRY_READ(entry, result, lensPositionReadInfoExists, alignment)
        lensPositionReadInfoID = entry->ID;
        ParameterFileSymbolTableEntry  pointerEntryCls;
        ParameterFileSymbolTableEntry* const pointerEntry = &pointerEntryCls;
        if (result)
        {
            result = entry->Table->ReadPointerEntry(pointerEntryCls, entry, alignment);
        }
        if (result && lensPositionReadInfoExists)
        {
            if (result)
            {
                result = lensPositionReadInfo.Load(pointerEntry, alignment);
            }
        }
        else
        {
            PARAMETER_INITIALIZE(lensPositionReadInfo);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool OISDriverData::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;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OISSlaveInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OISSlaveInfo::Unload(ParameterFileSymbolTable* const __table)
{
    if (__table != nullptr && __table->ReleaseDupObject(OISName))
    {
        PARAMETER_DELETE[] OISName;
    }
    OISName = nullptr;
    powerUpSequence.Unload(__table);
    powerDownSequence.Unload(__table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OISLensPositionReadInfo
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OISLensPositionReadInfo::Unload(ParameterFileSymbolTable* const __table)
{
    readSettings.Unload(__table);
    writeTimeSettings.Unload(__table);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OISFWData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OISFWData::Unload(ParameterFileSymbolTable* const __table)
{
    if (__table != nullptr && __table->ReleaseDupObject(fwName))
    {
        PARAMETER_DELETE[] fwName;
    }
    fwName = nullptr;
    fwRegAddr.Unload(__table);
    fwInit.Unload(__table);
    fwVersionCheck.Unload(__table);
    fwFinalize.Unload(__table);
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload OISDriverData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void OISDriverData::Unload(ParameterFileSymbolTable* const __table)
{
    slaveInfo.Unload(__table);
    oisfwinitSettings.Unload(__table);
    oisfwInfomation.Unload(__table);
    oisCalibSettings.Unload(__table);
    oisinitSettings.Unload(__table);
    enableOisSettings.Unload(__table);
    disableOisSettings.Unload(__table);
    enterDownloadModeSettings.Unload(__table);
    movieModeSettings.Unload(__table);
    stillModeSettings.Unload(__table);
    centeringOnSettings.Unload(__table);
    centeringOffSettings.Unload(__table);
    pantiltOnSettings.Unload(__table);
    sceneOisSettings.Unload(__table);
    sceneFilterOnSettings.Unload(__table);
    sceneFilterOffSettings.Unload(__table);
    sceneRangeOnSettings.Unload(__table);
    sceneRangeOffSettings.Unload(__table);
    lensPositionReadInfo.Unload(__table);
}

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

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Create module, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* OISDriverDataClass::Create(
    ModuleData*    moduleData,
    DefaultModule* const defModule) const
{
    OISDriverDataClass* 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 = (OISDriverDataClass*)module;
        }
        else
        {
            cls = PARAMETER_NEW OISDriverDataClass(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 OISDriverDataClass, binary version (%lld) does not match source version (%lld)\n",
            moduleData->Version.Value, Version.Value);
    }
    else
    {
        PARAMETER_LOG_ERROR(moduleData->SetManager, "Unable to create OISDriverDataClass, binary name (%s) does not match source name (%s)\n",
            moduleData->Type, Type);
    }

    return (ParameterModule*)cls;
}

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

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

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

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

CAMX_NAMESPACE_END
