blob: 7a2f992fa97cc6bfc85083ec73181a1f768fe28b [file] [log] [blame]
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THERMALD_TEMPERATURE_MONITOR_INTERFACE_H_
#define THERMALD_TEMPERATURE_MONITOR_INTERFACE_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/callback_list.h"
#include "base/macros.h"
namespace thermald {
// Interface for temperature monitors.
//
// A temperature monitor observes a single temperature. Subscribers can
// register with the temperature monitor to be notified upon changes of
// the monitored temperature.
class TemperatureMonitorInterface {
public:
typedef base::Callback<void(int)> TemperatureMonitorCallback;
typedef base::CallbackList<void(int)>::Subscription Subscription;
TemperatureMonitorInterface() {}
virtual ~TemperatureMonitorInterface() {}
virtual std::string name() const = 0;
// Subscribe for notifications about temperature changes.
//
// Returns a subscription object. The caller must keep a reference to this
// object for the time the subscription should be active. The subscription
// is canceled when the object is deleted.
virtual std::unique_ptr<Subscription> Subscribe(
const TemperatureMonitorCallback &cb) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(TemperatureMonitorInterface);
};
} // namespace thermald
#endif // THERMALD_TEMPERATURE_MONITOR_INTERFACE_H_