-- automatically generated by the FlatBuffers compiler, do not modify

-- namespace: ppx

local flatbuffers = require('flatbuffers')

local Observe = {} -- the module
local Observe_mt = {} -- the class metatable

function Observe.New()
    local o = {}
    setmetatable(o, {__index = Observe_mt})
    return o
end
function Observe.GetRootAsObserve(buf, offset)
    if type(buf) == "string" then
        buf = flatbuffers.binaryArray.New(buf)
    end
    local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
    local o = Observe.New()
    o:Init(buf, n + offset)
    return o
end
function Observe_mt:Init(buf, pos)
    self.view = flatbuffers.view.New(buf, pos)
end
function Observe_mt:Address()
    local o = self.view:Offset(4)
    if o ~= 0 then
        return self.view:String(o + self.view.pos)
    end
end
function Observe_mt:Name()
    local o = self.view:Offset(6)
    if o ~= 0 then
        return self.view:String(o + self.view.pos)
    end
end
function Observe_mt:DistributionType()
    local o = self.view:Offset(8)
    if o ~= 0 then
        return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
    end
    return 0
end
function Observe_mt:Distribution()
    local o = self.view:Offset(10)
    if o ~= 0 then
        local obj = flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)
        self.view:Union(obj, o)
        return obj
    end
end
function Observe_mt:Value()
    local o = self.view:Offset(12)
    if o ~= 0 then
        local x = self.view:Indirect(o + self.view.pos)
        local obj = require('ppx.Tensor').New()
        obj:Init(self.view.bytes, x)
        return obj
    end
end
function Observe.Start(builder) builder:StartObject(5) end
function Observe.AddAddress(builder, address) builder:PrependUOffsetTRelativeSlot(0, address, 0) end
function Observe.AddName(builder, name) builder:PrependUOffsetTRelativeSlot(1, name, 0) end
function Observe.AddDistributionType(builder, distributionType) builder:PrependUint8Slot(2, distributionType, 0) end
function Observe.AddDistribution(builder, distribution) builder:PrependUOffsetTRelativeSlot(3, distribution, 0) end
function Observe.AddValue(builder, value) builder:PrependUOffsetTRelativeSlot(4, value, 0) end
function Observe.End(builder) return builder:EndObject() end

return Observe -- return the module