from SecondLayerHLAs.SPDanalyzer.DDRSPD import DDRSPDHla
from SecondLayerHLAs.defaultAnalyzer.DDRdefault import DDRDefaultHla
from SecondLayerHLAs.defaultAnalyzer.BTdefault import BTDefaultHla
from SecondLayerHLAs.SPDanalyzer.SPD import SPDHla
from SecondLayerHLAs.defaultAnalyzer.default import DefaultHla
from SecondLayerHLAs.MCTPanalyzer.MCTP import MCTPPacketHla, MCTPMessageHla
from SecondLayerHLAs.MCTPanalyzer.DDRMCTP import DDRMCTPPacketHla, DDRMCTPMessageHla
from I3CDictionaries import DecodingModes


""" This handler will return an instance of the
second layer analyzer that was selected by the user
in the GUI.

Right know there are only two sets of two options supported:
    >SDR
        > None (I3C HLA)
        > SPD
    >DDR
        > None (I3C HLA)
        > SPD
"""
class SecondLayerAnalyzerHandler:

    def get(self, option: str, mode: DecodingModes):
        if mode.value == DecodingModes.SDR.value:
            if option == "None":
                second_layer_analyzer = DefaultHla()
            elif option == "SPD":
                second_layer_analyzer = SPDHla()
            elif option == "MCTP Packets":
                second_layer_analyzer = MCTPPacketHla()
            elif option == "MCTP Messages":
                second_layer_analyzer = MCTPMessageHla()
        if mode.value == DecodingModes.DDR.value:
            if option == "None":
                second_layer_analyzer = DDRDefaultHla()
            elif option == "SPD":
                second_layer_analyzer = DDRSPDHla()
            elif option == "MCTP Packets":
                second_layer_analyzer = DDRMCTPPacketHla()
            elif option == "MCTP Messages":
                second_layer_analyzer = DDRMCTPMessageHla()
        if mode.value == DecodingModes.BT.value:
            second_layer_analyzer = BTDefaultHla()
        return second_layer_analyzer