Now that the Object class implements parent-child relationships, make it possible to create EventNotifier and Timer instances with a parent by adding a parent argument to their constructors. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
48 lines
810 B
C++
48 lines
810 B
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* timer.h - Generic timer
|
|
*/
|
|
#ifndef __LIBCAMERA_TIMER_H__
|
|
#define __LIBCAMERA_TIMER_H__
|
|
|
|
#include <cstdint>
|
|
|
|
#include <libcamera/object.h>
|
|
#include <libcamera/signal.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class Message;
|
|
|
|
class Timer : public Object
|
|
{
|
|
public:
|
|
Timer(Object *parent = nullptr);
|
|
~Timer();
|
|
|
|
void start(unsigned int msec);
|
|
void stop();
|
|
bool isRunning() const;
|
|
|
|
unsigned int interval() const { return interval_; }
|
|
uint64_t deadline() const { return deadline_; }
|
|
|
|
Signal<Timer *> timeout;
|
|
|
|
protected:
|
|
void message(Message *msg) override;
|
|
|
|
private:
|
|
void registerTimer();
|
|
void unregisterTimer();
|
|
|
|
unsigned int interval_;
|
|
uint64_t deadline_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_TIMER_H__ */
|