# automatically generated by the FlatBuffers compiler, do not modify

# namespace: isp

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

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

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

    @classmethod
    def GetRootAsState(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    @classmethod
    def StateBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
        return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x49\x53\x50\x46", size_prefixed=size_prefixed)

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

    # State
    def Obs(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from communications.isp.Obs import Obs
            obj = Obs()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # State
    def Reward(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # State
    def Done(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

    # State
    def Info(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from communications.isp.Info import Info
            obj = Info()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def StateStart(builder): builder.StartObject(4)
def Start(builder):
    return StateStart(builder)
def StateAddObs(builder, obs): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(obs), 0)
def AddObs(builder, obs):
    return StateAddObs(builder, obs)
def StateAddReward(builder, reward): builder.PrependFloat64Slot(1, reward, 0.0)
def AddReward(builder, reward):
    return StateAddReward(builder, reward)
def StateAddDone(builder, done): builder.PrependBoolSlot(2, done, 0)
def AddDone(builder, done):
    return StateAddDone(builder, done)
def StateAddInfo(builder, info): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(info), 0)
def AddInfo(builder, info):
    return StateAddInfo(builder, info)
def StateEnd(builder): return builder.EndObject()
def End(builder):
    return StateEnd(builder)