#pragma once
// 串口参数校验与默认值合并
// 参数回写设备树（持久化前置）
// 创建设备与驱动
// ingress / egress 绑定
// registry 注册与设备启动

#include <functional>
#include <memory>

#include <QHash>
#include <QJsonObject>
#include <QSharedPointer>
#include <QString>

#include "core/memory/MemoryPool.h"
#include "device_bus/registry/IDeviceRegistry.h"
#include "devices/physical/SerialDevice.h"

namespace softbus::message_bus::egress { class EgressRouter; }
namespace softbus::message_bus::ingress { class DriverIngressAdapter; }

class DeviceTreeModel;

namespace softbus::device_bus::manager
{

struct SerialInitDeps
{
    DeviceTreeModel* treeModel{nullptr};
    std::function<void()> dirtyCb;
    softbus::device_bus::registry::IDeviceRegistry* registry{nullptr};
    softbus::message_bus::ingress::DriverIngressAdapter* ingressAdapter{nullptr};
    std::shared_ptr<softbus::core::memory::MemoryPool> memoryPool;
    softbus::message_bus::egress::EgressRouter* egressRouter{nullptr};
    QHash<QString, QSharedPointer<softbus::devices::physical::SerialDevice>>* serialDevicesByEndpoint{nullptr};
};

bool initializeSerialDeviceWithDeps(const QString& endpoint, const QJsonObject& params, const SerialInitDeps& deps);

} // namespace softbus::device_bus::manager
