| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_SHARED_MEM_BASED_SENSOR_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_SHARED_MEM_BASED_SENSOR_H_ |
| |
| #include <memory> |
| #include <optional> |
| #include <string> |
| |
| #include "absl/status/statusor.h" |
| #include "boost/asio.hpp" //NOLINT: boost::asio is commonly used in BMC |
| #include "hal_common_config.pb.h" |
| #include "shared_mem_sensor_config.pb.h" |
| #include "sensor.pb.h" |
| #include "tlbmc/sensors/sensor.h" |
| #include "tlbmc/sensors/sync_polling_sensor.h" |
| |
| namespace milotic_tlbmc { |
| class SharedMemBasedSensor : public SyncPollingSensor { |
| private: |
| class Token; |
| |
| public: |
| static bool IsSharedMemSensorKey(const std::string& key); |
| static absl::StatusOr<std::shared_ptr<Sensor>> Create( |
| const SharedMemSensorConfig& config, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| std::optional<NotificationCb> on_batch_notify = std::nullopt); |
| |
| SharedMemBasedSensor( |
| Token token, SharedMemSensorType sensor_type, |
| const EntityCommonConfig& entity_common_config, |
| const SensorInstanceProperties& sensor_properties, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| std::optional<NotificationCb> on_batch_notify = std::nullopt); |
| |
| ~SharedMemBasedSensor() override = default; |
| |
| protected: |
| absl::StatusOr<SensorValue> ReadSensorData() override; |
| |
| private: |
| class Token { |
| private: |
| explicit Token() = default; |
| friend SharedMemBasedSensor; |
| }; |
| |
| const SharedMemSensorType sensor_type_ = SHARED_MEM_SENSOR_TYPE_TYPE0_UNKNOWN; |
| const std::string sensor_name_; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_SHARED_MEM_BASED_SENSOR_H_ |