Files
soft_bus_edge/src/device_bus/monitor/IDeviceMonitor.h
flower_linux 90ad86b4d0 init
2026-05-13 16:46:07 +08:00

48 lines
916 B
C++

#pragma once
#include <functional>
#include <vector>
#include <QObject>
#include "device_bus/monitor/DeviceEvent.h"
namespace softbus::device_bus::monitor
{
class IDeviceMonitor : public QObject
{
Q_OBJECT
public:
using EventCallback = std::function<void(const DeviceEvent&)>;
explicit IDeviceMonitor(QObject* parent = nullptr)
: QObject(parent)
{
}
~IDeviceMonitor() override = default;
virtual bool start() = 0;
virtual void stop() = 0;
virtual std::vector<DeviceEvent> snapshotExisting() = 0;
void setCallback(EventCallback cb) { m_cb = std::move(cb); }
protected:
void emitEvent(const DeviceEvent& ev)
{
if (m_cb) {
m_cb(ev);
}
emit event(ev);
}
signals:
void event(const softbus::device_bus::monitor::DeviceEvent& ev);
private:
EventCallback m_cb;
};
} // namespace softbus::device_bus::monitor