#include "./Area.hpp"

using namespace world::server;

std::shared_ptr<Region> Area::getRegion(const std::string& folderPath, const area_region_ref& id) {
    { // Found
        const auto shared = regions.lock_shared();
        const auto it = shared->find(id.region);
        if(it != shared->end())
            return it->second;
    }
    // Reading
    const auto reg = std::make_shared<Region>(folderPath, id);
    const auto unique = regions.lock();
    return unique->insert({id.region, reg}).first->second;
}
