# automatically generated by the FlatBuffers compiler, do not modify

# namespace: proto

from autobahn import flatbuffers
from autobahn.flatbuffers.compat import import_numpy

np = import_numpy()


class EventReceived(object):
    __slots__ = ["_tab"]

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

    @classmethod
    def GetRootAsEventReceived(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)

    # EventReceived
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # EventReceived
    def Session(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(
                flatbuffers.number_types.Uint64Flags, o + self._tab.Pos
            )
        return 0

    # EventReceived
    def Publication(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(
                flatbuffers.number_types.Uint64Flags, o + self._tab.Pos
            )
        return 0

    # EventReceived
    def ForwardFor(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from autobahn.wamp.gen.wamp.proto.Principal import Principal

            obj = Principal()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # EventReceived
    def ForwardForLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # EventReceived
    def ForwardForIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0


def EventReceivedStart(builder):
    builder.StartObject(3)


def Start(builder):
    EventReceivedStart(builder)


def EventReceivedAddSession(builder, session):
    builder.PrependUint64Slot(0, session, 0)


def AddSession(builder, session):
    EventReceivedAddSession(builder, session)


def EventReceivedAddPublication(builder, publication):
    builder.PrependUint64Slot(1, publication, 0)


def AddPublication(builder, publication):
    EventReceivedAddPublication(builder, publication)


def EventReceivedAddForwardFor(builder, forwardFor):
    builder.PrependUOffsetTRelativeSlot(
        2, flatbuffers.number_types.UOffsetTFlags.py_type(forwardFor), 0
    )


def AddForwardFor(builder, forwardFor):
    EventReceivedAddForwardFor(builder, forwardFor)


def EventReceivedStartForwardForVector(builder, numElems):
    return builder.StartVector(4, numElems, 4)


def StartForwardForVector(builder, numElems):
    return EventReceivedStartForwardForVector(builder, numElems)


def EventReceivedEnd(builder):
    return builder.EndObject()


def End(builder):
    return EventReceivedEnd(builder)
