# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Packets

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class ChangeConfigurationParam(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = ChangeConfigurationParam()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsChangeConfigurationParam(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # ChangeConfigurationParam
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # ChangeConfigurationParam
    def Config(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from gamium.protocol.generated.Types.Configuration import Configuration
            obj = Configuration()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def ChangeConfigurationParamStart(builder): builder.StartObject(1)
def Start(builder):
    return ChangeConfigurationParamStart(builder)
def ChangeConfigurationParamAddConfig(builder, config): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(config), 0)
def AddConfig(builder, config):
    return ChangeConfigurationParamAddConfig(builder, config)
def ChangeConfigurationParamEnd(builder): return builder.EndObject()
def End(builder):
    return ChangeConfigurationParamEnd(builder)
import gamium.protocol.generated.Types.Configuration
try:
    from typing import Optional
except:
    pass

class ChangeConfigurationParamT(object):

    # ChangeConfigurationParamT
    def __init__(self):
        self.config = None  # type: Optional[gamium.protocol.generated.Types.Configuration.ConfigurationT]

    @classmethod
    def InitFromBuf(cls, buf, pos):
        changeConfigurationParam = ChangeConfigurationParam()
        changeConfigurationParam.Init(buf, pos)
        return cls.InitFromObj(changeConfigurationParam)

    @classmethod
    def InitFromPackedBuf(cls, buf, pos=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
        return cls.InitFromBuf(buf, pos+n)

    @classmethod
    def InitFromObj(cls, changeConfigurationParam):
        x = ChangeConfigurationParamT()
        x._UnPack(changeConfigurationParam)
        return x

    # ChangeConfigurationParamT
    def _UnPack(self, changeConfigurationParam):
        if changeConfigurationParam is None:
            return
        if changeConfigurationParam.Config() is not None:
            self.config = gamium.protocol.generated.Types.Configuration.ConfigurationT.InitFromObj(changeConfigurationParam.Config())

    # ChangeConfigurationParamT
    def Pack(self, builder):
        if self.config is not None:
            config = self.config.Pack(builder)
        ChangeConfigurationParamStart(builder)
        if self.config is not None:
            ChangeConfigurationParamAddConfig(builder, config)
        changeConfigurationParam = ChangeConfigurationParamEnd(builder)
        return changeConfigurationParam
