blob: f7216f141687d5a181c16d300d0e5f0d228a91c5 [file] [log] [blame]
#pragma once
#include "NVMeSensor.hpp"
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/io_service.hpp>
#include <memory>
class NVMeContext : public std::enable_shared_from_this<NVMeContext>
{
public:
NVMeContext(boost::asio::io_service& io, int rootBus) :
scanTimer(io), rootBus(rootBus)
{}
virtual ~NVMeContext()
{
close();
}
void addSensor(std::shared_ptr<NVMeSensor> sensor)
{
sensors.emplace_back(sensor);
}
virtual void pollNVMeDevices()
{}
virtual void close()
{
scanTimer.cancel();
}
virtual void readAndProcessNVMeSensor()
{}
virtual void processResponse(void* msg, size_t len)
{
(void)msg;
(void)len;
}
protected:
boost::asio::deadline_timer scanTimer;
int rootBus; // Root bus for this drive
std::list<std::shared_ptr<NVMeSensor>> sensors; // used as a poll queue
};
using NVMEMap = boost::container::flat_map<int, std::shared_ptr<NVMeContext>>;
NVMEMap& getNVMEMap(void);