#pragma once
#include <type_traits>
#include <cstdint>
enum class Tag
{
    NONE = 0,           // 无标签
    SCENE = 1 << 0,     // 场景标签
    ACTOR = 1 << 1,     // 角色标签
    COMPONENT = 1 << 2, // 组件标签
    UPDATE = 1 << 3,    // 更新标签
    RENDER = 1 << 4,    // 渲染标签
    TRANSFORM = 1 << 5, // 变换标签
    HANDEL_EVENT = 1 << 6, // 事件处理标签
};

constexpr Tag operator|(Tag a, Tag b)
{
    using Underlying = std::underlying_type_t<Tag>;
    return static_cast<Tag>(static_cast<Underlying>(a) | static_cast<Underlying>(b));
}

constexpr Tag operator&(Tag a, Tag b)
{
    using Underlying = std::underlying_type_t<Tag>;
    return static_cast<Tag>(static_cast<Underlying>(a) & static_cast<Underlying>(b));
}
class TagGed
{
private:
    uint64_t m_tags;

public:
    TagGed(Tag initialTag = Tag::NONE)
        : m_tags(static_cast<uint64_t>(initialTag)) {}

    // 添加标签
    void addTag(Tag tag)
    {
        if (!hasTag(tag))
            m_tags |= static_cast<uint64_t>(tag);
    }

    // 移除标签
    void removeTag(Tag tag)
    {
        if (hasTag(tag))
            m_tags &= ~static_cast<uint64_t>(tag);
    }

    // 判断是否包含指定标签
    bool hasTag(Tag tag) const
    {
        return (m_tags & static_cast<uint64_t>(tag)) != 0;
    }

    // 判断是否包含所有指定标签
    bool hasAllTags(Tag tags) const
    {
        return (m_tags & static_cast<uint64_t>(tags)) == static_cast<uint64_t>(tags);
    }

    // 清除所有标签
    void clearTags()
    {
        m_tags = 0;
    }
};
