From patchwork Sat Aug 17 15:21:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1834 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF31061942 for ; Sat, 17 Aug 2019 17:21:18 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C89198C for ; Sat, 17 Aug 2019 17:21:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566055278; bh=tmxMDvEJ8F3jtRI6IXcB4It9W19GRXLvO7EOuPUdDhQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Rd1eh1y45Q+GQYWiBAnTL6psZ4lG6AKHlmFZwpjlDHm2RBf2VsEyfA4GzCKGbgUbe tnaQJE1LnPUwgZCsEXHpRzx1Gu/C0FFWxC/c4GT/biVWPh2FMm3AzOlm5JDSgQpgvm c/KfobC830WCmOLTrXY55sjZaH4JGfaV00dooH4M= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 17 Aug 2019 18:21:02 +0300 Message-Id: <20190817152104.10834-17-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190817152104.10834-1-laurent.pinchart@ideasonboard.com> References: <20190817152104.10834-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 16/18] libcamera: Add parent argument to constructors of Object-derived classes X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Aug 2019 15:21:19 -0000 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 Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- include/libcamera/event_notifier.h | 2 +- include/libcamera/timer.h | 2 +- src/libcamera/event_notifier.cpp | 5 +++-- src/libcamera/timer.cpp | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/libcamera/event_notifier.h b/include/libcamera/event_notifier.h index f80945c743dc..a37b02eee4b7 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 853808e07da8..f47b6a58404f 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 96be27601982..687969b0a8d1 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 f45061d4c6f6..c61d77e5128f 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) { }