summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-12 14:37:38 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-08-17 18:47:17 +0300
commit1554d0b6e645da7b3345436f8c7264823cbe0151 (patch)
tree1c95832fbaf8a1cd4388c8d33b4759bd96599af4
parent2b25819ec07e8de0b4be658c7d46f6c1c495766d (diff)
libcamera: Add parent argument to constructors of Object-derived classes
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>
-rw-r--r--include/libcamera/event_notifier.h2
-rw-r--r--include/libcamera/timer.h2
-rw-r--r--src/libcamera/event_notifier.cpp5
-rw-r--r--src/libcamera/timer.cpp5
4 files changed, 8 insertions, 6 deletions
diff --git a/include/libcamera/event_notifier.h b/include/libcamera/event_notifier.h
index f80945c7..a37b02ee 100644
--- a/include/libcamera/event_notifier.h
+++ b/include/libcamera/event_notifier.h
@@ -23,7 +23,7 @@ public:
Exception,
};
- EventNotifier(int fd, Type type);
+ EventNotifier(int fd, Type type, Object *parent = nullptr);
virtual ~EventNotifier();
Type type() const { return type_; }
diff --git a/include/libcamera/timer.h b/include/libcamera/timer.h
index 853808e0..f47b6a58 100644
--- a/include/libcamera/timer.h
+++ b/include/libcamera/timer.h
@@ -19,7 +19,7 @@ class Message;
class Timer : public Object
{
public:
- Timer();
+ Timer(Object *parent = nullptr);
~Timer();
void start(unsigned int msec);
diff --git a/src/libcamera/event_notifier.cpp b/src/libcamera/event_notifier.cpp
index 96be2760..687969b0 100644
--- a/src/libcamera/event_notifier.cpp
+++ b/src/libcamera/event_notifier.cpp
@@ -61,9 +61,10 @@ namespace libcamera {
* \brief Construct an event notifier with a file descriptor and event type
* \param[in] fd The file descriptor to monitor
* \param[in] type The event type to monitor
+ * \param[in] parent The parent Object
*/
-EventNotifier::EventNotifier(int fd, Type type)
- : fd_(fd), type_(type), enabled_(false)
+EventNotifier::EventNotifier(int fd, Type type, Object *parent)
+ : Object(parent), fd_(fd), type_(type), enabled_(false)
{
setEnabled(true);
}
diff --git a/src/libcamera/timer.cpp b/src/libcamera/timer.cpp
index f45061d4..c61d77e5 100644
--- a/src/libcamera/timer.cpp
+++ b/src/libcamera/timer.cpp
@@ -39,9 +39,10 @@ LOG_DEFINE_CATEGORY(Timer)
/**
* \brief Construct a timer
+ * \param[in] parent The parent Object
*/
-Timer::Timer()
- : interval_(0), deadline_(0)
+Timer::Timer(Object *parent)
+ : Object(parent), interval_(0), deadline_(0)
{
}