//
// Created by zx on 23-11-28.
//

#ifndef CERES_TEST_TransitData_H
#define CERES_TEST_TransitData_H

#include <opencv2/opencv.hpp>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include "tool/timedlockdata.hpp"
#include "tool/singleton.hpp"
#include <mutex>

#define NUM_ 4

class TransitData : public Singleton<TransitData> {
    friend Singleton<TransitData>;
public:
    struct MeasureInfo {
        float x;
        float y;
        float transx;
        float transy;
        float theta;
        float width;
        float wheelbase;
        float ftheta;
        int border_plc;
        int border_display;
        std::string error;

        MeasureInfo &operator=(const MeasureInfo &info) {
            x = info.x;
            y = info.y;
            theta = info.theta;
            transx = info.transx;
            transy = info.transy;
            width = info.width;
            wheelbase = info.wheelbase;
            ftheta = info.ftheta;
            border_plc = info.border_plc;
            border_display = info.border_display;
            error = info.error;
            return *this;
        }
    };

public:

    void setImage(cv::Mat image, int id);

    void setImageCL(cv::Mat &image, int id);

    void setMask(std::vector<cv::Point> mask, int id);

    void setMeasureInfo(MeasureInfo info);

    bool getImage(cv::Mat &image, int id, float timeout);

    bool getImageCL(cv::Mat &image, int id, float timeout);

    bool getMask(std::vector<cv::Point> &mask, int id, float timeout);

    bool getMeasureInfo(MeasureInfo &info, float timeout);

private:
    TransitData();

    std::mutex mutex_;
    TimedLockData<cv::Mat> image_[NUM_];
    TimedLockData<cv::Mat> imageCL_[NUM_];

    TimedLockData<std::vector<cv::Point>> mask_[NUM_];
    TimedLockData<MeasureInfo> measureInfo_;

};

#endif //CERES_TEST_TransitData_H
