#include <softbus_daemon/registry/ObjectModelRegistry.h>

#include <softbus_core/identity/DeviceIdentity.h>

namespace softbus::daemon {

bool ObjectModelRegistry::loadFromFile(const std::string& path)
{
    return tree_.loadFromFile(path);
}

std::optional<softbus::core::ObjectRef> ObjectModelRegistry::findPointByRegister(int registerAddress) const
{
    for (const auto& device : tree_.devices) {
        for (const auto& point : device.points) {
            if (point.registerAddress == registerAddress) {
                return softbus::core::DeviceIdentity::buildObjectRef(
                    tree_, device.stableDeviceKey, point.name);
            }
        }
    }
    return std::nullopt;
}

} // namespace softbus::daemon
