#pragma once

#include <string>
#include <memory>

#include <file_system/file_path.h>


namespace Map2 {

class MapLayer {
public:
    virtual ~MapLayer() = default;

    virtual void setName(const std::string& name) { name_ = name; }
    virtual const std::string& getName() const { return name_; }

    virtual void setID(int id) { id_ = id; }
    virtual int getID() const { return id_; }

    virtual bool saveToFile(const std::string& filename) const = 0;

    virtual bool loadFromFile(const std::string& filename) = 0;

    bool saveFromFolder(const std::string &folder,
                        const std::string &file_name) {
        std::string full_path = FileSystem2::JoinPath(folder, file_name);
        return saveToFile(full_path);
    }

    bool loadFromFolder(const std::string &folder,
                        const std::string &file_name) {
        std::string full_path = FileSystem2::JoinPath(folder, file_name);
        return loadFromFile(full_path);
    }

    bool loadFromFolder(const std::string &folder) {
        std::string full_path = FileSystem2::JoinPath(folder, getName());
        return loadFromFile(full_path);
    }

    bool saveFromFolder(const std::string &folder) {
        std::string full_path = FileSystem2::JoinPath(folder, getName());
        return saveToFile(full_path);
    }

    // 可选：获取类型名称（用于日志或反射）
    virtual std::string getTypeName() const = 0;


protected:
    std::string name_ = "unnamed_map";
    int id_ = -1;
};

}