From patchwork Sat Jan 13 14:22:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 19394 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2074DC32BC for ; Sat, 13 Jan 2024 14:22:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 927A5628BF; Sat, 13 Jan 2024 15:22:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1705155764; bh=fBzL2s5oxRsGrkzd2/fc8S9Z2CN3n1c7m6lC/Zmfzww=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=P1xx3LySYzNOFBkw65caZTCb4gNCqs7y1IG0u5OGNIXd3q0D+YZ37uz7z6hgDSfoG 1pZthS7ohRZMlL9dtWo3oVaM+XUrUE7AAVwNz8F5K1Y2vPSxeYr0EL2fEpxFjo6RC8 xpI2B5t+fxH0+nFPyje1cFngEqfu3/Z5+laTdKLUrjWDuQ5kyFUBZep8I+swnIF92b BxLCi/wJfbchZKwwSuQXAGpLcbVo+TI21KIaqkzQBZx2uCTfiUmDeVQ5is9/as3Y/p FJkkKMvmL0DZiQBvxiFlO9M1GomhQVdnc2FfiZsX/RRTHX6PAC6wUmGrPUNwuYsi17 5hnthXK8XuVCw== Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 05FD0628B1 for ; Sat, 13 Jan 2024 15:22:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="DJObr7HE"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705155760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H1oIVgkw6WX1+fpLPBZklA9UQJyKLouaD0z3IEBI+IY=; b=DJObr7HE0I4kK5KPZeXGsmKVhogf965Adv5z+tuh4wUbr29viWORR9S+Q2QXZIfV7FBtxl pJqIvnJ2XlUS56F3PbixhRu7o5fVn1iOyzH2oSStGAYKXRGOxUSl6aOPdFgvYQtGd0uJsw 6npSForzMak9A8w4fkfr++Se6l/taac= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-594lwOrdMayC1xqNKFoBUg-1; Sat, 13 Jan 2024 09:22:38 -0500 X-MC-Unique: 594lwOrdMayC1xqNKFoBUg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1306D85A588; Sat, 13 Jan 2024 14:22:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27DE13C25; Sat, 13 Jan 2024 14:22:36 +0000 (UTC) To: libcamera-devel@lists.libcamera.org, Andrey Konovalov Date: Sat, 13 Jan 2024 15:22:05 +0100 Message-ID: <20240113142218.28063-6-hdegoede@redhat.com> In-Reply-To: <20240113142218.28063-1-hdegoede@redhat.com> References: <20240113142218.28063-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [libcamera-devel] [PATCH v2 05/18] libcamera: internal: Document the SharedMemObject class X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans de Goede via libcamera-devel From: Hans de Goede Reply-To: Hans de Goede Cc: Maxime Ripard , g.martti@gmail.com, t.langendam@gmail.com, srinivas.kandagatla@linaro.org, Pavel Machek , Bryan O'Donoghue , admin@dennisbonke.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Dennis Bonke Document the SharedMemObject class. Signed-off-by: Dennis Bonke Signed-off-by: Hans de Goede Tested-by: Bryan O'Donoghue # sc8280xp Lenovo x13s Tested-by: Pavel Machek Reviewed-by: Kieran Bingham --- .../libcamera/internal/shared_mem_object.h | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h index bfb639ee..e862ce48 100644 --- a/include/libcamera/internal/shared_mem_object.h +++ b/include/libcamera/internal/shared_mem_object.h @@ -19,10 +19,20 @@ namespace libcamera { +/** + * \class SharedMemObject + * \brief Helper class for shared memory allocations. + * + * Takes a template T which is used to indicate the + * data type of the object stored. + */ template class SharedMemObject { public: + /** + * \brief The size of the object that is going to be stored here. + */ static constexpr std::size_t SIZE = sizeof(T); SharedMemObject() @@ -30,6 +40,11 @@ public: { } + /** + * \brief Contstructor for the SharedMemObject. + * \param[in] name The requested name. + * \param[in] args Any additional args. + */ template SharedMemObject(const std::string &name, Args &&...args) : name_(name), obj_(nullptr) @@ -57,6 +72,10 @@ public: obj_ = new (mem) T(std::forward(args)...); } + /** + * \brief Move constructor for SharedMemObject. + * \param[in] rhs The object to move. + */ SharedMemObject(SharedMemObject &&rhs) { this->name_ = std::move(rhs.name_); @@ -76,6 +95,10 @@ public: /* Make SharedMemObject non-copyable for now. */ LIBCAMERA_DISABLE_COPY(SharedMemObject) + /** + * \brief Operator= for SharedMemObject. + * \param[in] rhs The SharedMemObject object to take the data from. + */ SharedMemObject &operator=(SharedMemObject &&rhs) { this->name_ = std::move(rhs.name_); @@ -85,31 +108,61 @@ public: return *this; } + /** + * \brief Operator-> for SharedMemObject. + * + * \return the object. + */ T *operator->() { return obj_; } + /** + * \brief Operator-> for SharedMemObject. + * + * \return the object. + */ const T *operator->() const { return obj_; } + /** + * \brief Operator* for SharedMemObject. + * + * \return the object. + */ T &operator*() { return *obj_; } + /** + * \brief Operator* for SharedMemObject. + * + * \return the object. + */ const T &operator*() const { return *obj_; } + /** + * \brief Gets the file descriptor for the underlaying storage file. + * + * \return the file descriptor. + */ const SharedFD &fd() const { return fd_; } + /** + * \brief Operator bool() for SharedMemObject. + * + * \return true if the object is not null, false otherwise. + */ explicit operator bool() const { return !!obj_;