#pragma once

#include <softbus_bus/Bus.h>
#include <softbus_core/models/DOMMessage.h>

#include <map>
#include <string>

struct UA_Server;

#if SOFTBUS_HAS_OPCUA
#include <open62541/types.h>
#else
typedef struct UA_NodeId UA_NodeId;
#endif

namespace softbus::opcua {

class UaModelBinder {
public:
    explicit UaModelBinder(UA_Server* server);

    void registerPointNode(const std::string& objectRef, const UA_NodeId& nodeId);
    void attachBus(softbus::bus::Bus* bus);
    bool bind(const softbus::core::DOMMessage& message);
    bool bindValue(const std::string& objectRef, double value, const std::string& traceId = "");

private:
    void onBusMessage(const softbus::bus::BusMessage& message);

    UA_Server* server_{nullptr};
    softbus::bus::Bus* bus_{nullptr};
    softbus::bus::Bus::SubscriptionId dataSub_{0};
    std::map<std::string, UA_NodeId> pointNodes_;
};

} // namespace softbus::opcua
