serialWatch/include/ComWatch.h

28 lines
558 B
C++

#ifndef COMWATCH_H
#include "serial.h"
#include "spdlog/spdlog.h"
#include <functional>
#include <string>
#include <mutex>
#include <thread>
enum class SIGNAL_TYPE{
REMOVE_,
ADD_,
};
class SerialWatch {
private:
std::function<void(const std::string&, SIGNAL_TYPE type)> callback;
std::jthread work_thread;
std::stop_source s;
std::mutex m;
public:
SerialWatch() = default;
~SerialWatch();
void set_callback(std::function<void(const std::string&, SIGNAL_TYPE type)> func);
void work();
};
#endif // !COMWATCH_H