Headers which must not be exposed as part of the public libcamera API should include base/private.h. Any interface which includes the private.h header will only be able to build if the libcamera_private dependency is used (or the libcamera_base_private dependency directly). Build targets which are intended to use the private API's will use the libcamera_private to handle the automatic definition of the inclusion guard. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
51 lines
1 KiB
C++
51 lines
1 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* timer.h - Generic timer
|
|
*/
|
|
#ifndef __LIBCAMERA_BASE_TIMER_H__
|
|
#define __LIBCAMERA_BASE_TIMER_H__
|
|
|
|
#include <chrono>
|
|
#include <stdint.h>
|
|
|
|
#include <libcamera/base/private.h>
|
|
|
|
#include <libcamera/base/object.h>
|
|
#include <libcamera/base/signal.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class Message;
|
|
|
|
class Timer : public Object
|
|
{
|
|
public:
|
|
Timer(Object *parent = nullptr);
|
|
~Timer();
|
|
|
|
void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); }
|
|
void start(std::chrono::milliseconds duration);
|
|
void start(std::chrono::steady_clock::time_point deadline);
|
|
void stop();
|
|
bool isRunning() const;
|
|
|
|
std::chrono::steady_clock::time_point deadline() const { return deadline_; }
|
|
|
|
Signal<Timer *> timeout;
|
|
|
|
protected:
|
|
void message(Message *msg) override;
|
|
|
|
private:
|
|
void registerTimer();
|
|
void unregisterTimer();
|
|
|
|
bool running_;
|
|
std::chrono::steady_clock::time_point deadline_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_BASE_TIMER_H__ */
|