/*
 * Copyright (C) Photon Vision.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY

package org.photonvision.struct;

import org.photonvision.common.dataflow.structures.Packet;
import org.photonvision.common.dataflow.structures.PacketSerde;
import org.photonvision.utils.PacketUtils;

// Assume that the base class lives here and we can import it
import org.photonvision.targeting.*;

// WPILib imports (if any)
import edu.wpi.first.util.struct.Struct;


/**
 * Auto-generated serialization/deserialization helper for PhotonPipelineResult
 */
public class PhotonPipelineResultSerde implements PacketSerde<PhotonPipelineResult> {

    @Override
    public final String getInterfaceUUID() { return "4b2ff16a964b5e2bf04be0c1454d91c4"; }
    @Override
    public final String getSchema() { return "PhotonPipelineMetadata:ac0a45f686457856fb30af77699ea356 metadata;PhotonTrackedTarget:cc6dbb5c5c1e0fa808108019b20863f1 targets[?];optional MultiTargetPNPResult:541096947e9f3ca2d3f425ff7b04aa7b multitagResult;"; }
    @Override
    public final String getTypeName() { return "PhotonPipelineResult"; }

    @Override
    public int getMaxByteSize() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'");
    }

    @Override
    public void pack(Packet packet, PhotonPipelineResult value) {
        // field metadata is of non-intrinsic type PhotonPipelineMetadata
        PhotonPipelineMetadata.photonStruct.pack(packet, value.metadata);

        // targets is a custom VLA!
        packet.encodeList(value.targets);

        // multitagResult is optional! it better not be a VLA too
        packet.encodeOptional(value.multitagResult);
    }

    @Override
    public PhotonPipelineResult unpack(Packet packet) {
        var ret = new PhotonPipelineResult();

        // metadata is of non-intrinsic type PhotonPipelineMetadata
        ret.metadata = PhotonPipelineMetadata.photonStruct.unpack(packet);

        // targets is a custom VLA!
        ret.targets = packet.decodeList(PhotonTrackedTarget.photonStruct);

        // multitagResult is optional! it better not be a VLA too
        ret.multitagResult = packet.decodeOptional(MultiTargetPNPResult.photonStruct);

        return ret;
    }

    @Override
    public PacketSerde<?>[] getNestedPhotonMessages() {
        return new PacketSerde<?>[] {
            PhotonPipelineMetadata.photonStruct,MultiTargetPNPResult.photonStruct,PhotonTrackedTarget.photonStruct
        };
    }

    @Override
    public Struct<?>[] getNestedWpilibMessages() {
        return new Struct<?>[] {
            
        };
    }
}
