#pragma once
#include "map/map_layer.h"
#include "scancontext/Scancontext.h"
#include "file_system/file_path.h"
#include <cstddef>
#include <memory>

namespace Map2 {

class SCMap : public MapLayer {
public:
    using Ptr = std::shared_ptr<SCMap>;

    SCMap() {
        setName("sc.pbf");
    };

    bool saveToFile(const std::string& filename) const override {
        return sc_manager_->SaveToFile(filename);
    }

    bool loadFromFile(const std::string& filename) override {
        return sc_manager_->LoadFromFile(filename);
    }

    std::string getTypeName() const override { return "SC_Map"; }

    void addFrame(pcl::PointCloud<SCPointType> &scan_down,
                  const Eigen::Matrix4d &pose, const size_t &frame_id) {
        sc_manager_->makeAndSaveScancontextAndKeys(scan_down, pose, frame_id);
    }

    SCRelocInfo QueryMap(pcl::PointCloud<SCPointType> & scan_down) {
        return sc_manager_->QueryMap(scan_down);
    }

    SCRelocInfo detectLoopClosureID(pcl::PointCloud<SCPointType> & scan_down) {
        return sc_manager_->detectLoopClosureID();
    }

private:

    std::shared_ptr<SCManager> sc_manager_ = std::make_shared<SCManager>();

};

}