# automatically generated by the FlatBuffers compiler, do not modify

# namespace:

import flatbuffers


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

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

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

    # SpectraDetectorMapping
    def Spectrum(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Int32Flags,
                a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4),
            )
        return 0

    # SpectraDetectorMapping
    def SpectrumAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
        return 0

    # SpectraDetectorMapping
    def SpectrumLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # SpectraDetectorMapping
    def DetectorId(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Int32Flags,
                a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4),
            )
        return 0

    # SpectraDetectorMapping
    def DetectorIdAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
        return 0

    # SpectraDetectorMapping
    def DetectorIdLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # SpectraDetectorMapping
    def NSpectra(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 0


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


def SpectraDetectorMappingAddSpectrum(builder, spectrum):
    builder.PrependUOffsetTRelativeSlot(
        0, flatbuffers.number_types.UOffsetTFlags.py_type(spectrum), 0
    )


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


def SpectraDetectorMappingAddDetectorId(builder, detectorId):
    builder.PrependUOffsetTRelativeSlot(
        1, flatbuffers.number_types.UOffsetTFlags.py_type(detectorId), 0
    )


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


def SpectraDetectorMappingAddNSpectra(builder, nSpectra):
    builder.PrependInt32Slot(2, nSpectra, 0)


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