blob: b62afddb9a260be2b4428b477b6b1da390c3c4d0 [file] [log] [blame]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_GPIO_GPIO_MONITOR_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_GPIO_GPIO_MONITOR_H_
#include <memory>
#include <string>
#include "absl/status/statusor.h"
#include "boost/asio/io_context.hpp" // NOLINT: boost is commonly used in BMC codebase
#include "boost/asio/posix/stream_descriptor.hpp" // NOLINT: boost is commonly used in BMC codebase
#include "tlbmc/hal/gpio/gpio.h"
namespace milotic_tlbmc {
// A single instance of GpioMonitor is created for each GPIO line.
class GpioMonitor {
public:
static absl::StatusOr<std::unique_ptr<GpioMonitor>> Create(
const GpioConfig& gpio_config,
std::shared_ptr<boost::asio::io_context> io_context);
virtual ~GpioMonitor();
std::string GetGpioName() const { return gpio_->GetGpioName(); }
absl::StatusOr<bool> GetGpioValue() const { return gpio_->GetValue(); }
protected:
void ScheduleEventHandler();
virtual void EventHandler();
private:
GpioMonitor(
std::unique_ptr<Gpio> gpio, bool is_one_time_request,
std::unique_ptr<boost::asio::posix::stream_descriptor> event_descriptor);
std::unique_ptr<Gpio> gpio_;
bool is_one_time_request_;
std::unique_ptr<boost::asio::posix::stream_descriptor> event_descriptor_;
};
} // namespace milotic_tlbmc
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_HAL_GPIO_GPIO_MONITOR_H_