#include "LuaGlobalBridge.h"

void LuaGlobalBridge::Set(const std::string& key, const Value& value)
{
    std::lock_guard<std::mutex> lock(mutex);
    globals[key] = value;
}

std::optional<LuaGlobalBridge::Value> LuaGlobalBridge::Get(const std::string& key)
{
    std::lock_guard<std::mutex> lock(mutex);
    auto it = globals.find(key);
    if (it != globals.end())
        return it->second;
    return std::nullopt;
}


std::unordered_map<std::string, LuaGlobalBridge::Value> LuaGlobalBridge::GetAll()
{
    std::lock_guard<std::mutex> lock(mutex);
    return globals;
}

void LuaGlobalBridge::Clear()
{
    std::lock_guard<std::mutex> lock(mutex);
    globals.clear();
}


