| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_GPIO_SENSOR_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_GPIO_SENSOR_H_ |
| |
| #include <memory> |
| #include <optional> |
| #include <string> |
| |
| #include "absl/status/statusor.h" |
| #include "tlbmc/collector/gpio_collector.h" |
| #include "gpio_sensor_config.pb.h" |
| #include "sensor.pb.h" |
| #include "tlbmc/sensors/sync_polling_sensor.h" |
| |
| namespace milotic_tlbmc { |
| |
| class GpioSensor : public SyncPollingSensor { |
| private: |
| class Token; |
| |
| public: |
| static absl::StatusOr<std::shared_ptr<GpioSensor>> Create( |
| const GpioSensorConfig& config, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| GpioCollector* gpio_collector, |
| std::optional<NotificationCb> on_batch_notify = std::nullopt); |
| |
| GpioSensor(Token token, const std::string& gpio_pin_name, |
| const EntityCommonConfig& entity_common_config, |
| const SensorInstanceProperties& sensor_instance_properties, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| GpioCollector* gpio_collector, |
| std::optional<NotificationCb> on_batch_notify = std::nullopt); |
| |
| ~GpioSensor() override = default; |
| |
| protected: |
| absl::StatusOr<SensorValue> ReadSensorData() override; |
| |
| private: |
| class Token { |
| private: |
| explicit Token() = default; |
| friend GpioSensor; |
| }; |
| |
| const std::string sensor_name_; |
| const std::string gpio_pin_name_; |
| GpioCollector* gpio_collector_; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_GPIO_SENSOR_H_ |