# automatically generated by the FlatBuffers compiler, do not modify

# namespace: meta

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


# Generic **tags attached** to objects in other tables. Primary key of this table is ``(table_oid, object_oid, tag_oid)``.
class Tag(object):
    __slots__ = ["_tab"]

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

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

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

    # Table of the object with the tag attached.
    # Tag
    def TableOid(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.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # Tag
    def TableOidAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

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

    # Tag
    def TableOidIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

    # Object (within the table) with the tag attached.
    # Tag
    def ObjectOid(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.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # Tag
    def ObjectOidAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

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

    # Tag
    def ObjectOidIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # Tag definition attached to the object.
    # Tag
    def TagOid(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # Tag
    def TagOidAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

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

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

    # Timestamp when the tag was attached to the object referenced.
    # Tag
    def Attached(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0


def TagStart(builder):
    builder.StartObject(4)


def Start(builder):
    TagStart(builder)


def TagAddTableOid(builder, tableOid):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(tableOid), 0)


def AddTableOid(builder, tableOid):
    TagAddTableOid(builder, tableOid)


def TagStartTableOidVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartTableOidVector(builder, numElems: int) -> int:
    return TagStartTableOidVector(builder, numElems)


def TagAddObjectOid(builder, objectOid):
    builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(objectOid), 0)


def AddObjectOid(builder, objectOid):
    TagAddObjectOid(builder, objectOid)


def TagStartObjectOidVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartObjectOidVector(builder, numElems: int) -> int:
    return TagStartObjectOidVector(builder, numElems)


def TagAddTagOid(builder, tagOid):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(tagOid), 0)


def AddTagOid(builder, tagOid):
    TagAddTagOid(builder, tagOid)


def TagStartTagOidVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartTagOidVector(builder, numElems: int) -> int:
    return TagStartTagOidVector(builder, numElems)


def TagAddAttached(builder, attached):
    builder.PrependUint64Slot(3, attached, 0)


def AddAttached(builder, attached):
    TagAddAttached(builder, attached)


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


def End(builder):
    return TagEnd(builder)
