| #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_ |