#pragma once

#include <QJsonObject>
#include <QString>
#include <memory>

#include "device_bus/tree/DeviceTreeModel.h"

namespace softbus::device_bus {

class DeviceBus {
public:
  static DeviceBus &instance();

  bool initialize(const QJsonObject &rootConfig);
  void shutdown();

  void setConfigPath(const QString& path);
  QString configPath() const;

  // 共享设备树模型（单一真源）
  std::shared_ptr<DeviceTreeModel> deviceTreeModel() const;

  // 注册/更新设备树后调用，确保 shutdown 会落盘
  void markDeviceTreeDirty();

private:
  DeviceBus();
  ~DeviceBus();
  DeviceBus(const DeviceBus &) = delete;
  DeviceBus &operator=(const DeviceBus &) = delete;

  class Impl;
  Impl *d;
};

} // namespace softbus::device_bus
