blob: f29833985a8bb00cb670a900a9c0ac92d398afaa [file]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_SYNC_POLLING_SENSOR_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_SYNC_POLLING_SENSOR_H_
#include <memory>
#include <optional>
#include "absl/functional/any_invocable.h"
#include "absl/status/statusor.h"
#include "boost/asio.hpp" //NOLINT: boost::asio is commonly used in BMC
#include "threshold_config.pb.h"
#include "sensor.pb.h"
#include "tlbmc/sensors/polling_base_sensor.h"
#include "tlbmc/sensors/sensor.h"
namespace milotic_tlbmc {
class SyncPollingSensor
: public PollingBaseSensor,
public std::enable_shared_from_this<SyncPollingSensor> {
public:
~SyncPollingSensor() override = default;
void RefreshOnceAsync(
absl::AnyInvocable<void(const std::shared_ptr<const SensorValue>&)>
callback) override;
protected:
SyncPollingSensor(SensorAttributesStatic&& sensor_attributes_static,
const ThresholdConfigs& threshold_configs,
const std::shared_ptr<boost::asio::io_context>& io_context,
std::optional<NotificationCb> notification_cb);
// Reads the sensor data. This function is called by RefreshOnceAsync.
// Derived classes must implement this to return a fully populated
// SensorValue.
virtual absl::StatusOr<SensorValue> ReadSensorData() = 0;
std::shared_ptr<boost::asio::io_context> io_context_;
};
} // namespace milotic_tlbmc
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_SYNC_POLLING_SENSOR_H_