From patchwork Sun Jul 25 17:18:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13111 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 9EFF3C322C for ; Sun, 25 Jul 2021 17:18:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 96991687BC; Sun, 25 Jul 2021 19:18:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ftm9yrUq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 03BAD60273 for ; Sun, 25 Jul 2021 19:18:36 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EB3AADD for ; Sun, 25 Jul 2021 19:18:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627233516; bh=pIurULwjjvvcygKlGWiUV1fKdIrgOm1nTyUDQJxg3Oc=; h=From:To:Subject:Date:From; b=Ftm9yrUqWMAW531OPkvbkYkysLFI/pOx80EdrYnOsSKTvY6PaWfbI1ZM20r22SRpE H8ACO4u3/VyuQId+ibojJ2gm6S04iD2+wkPmCVhW2AOE1f9PLq+Jj5z84UQyEbJfaW qOhXPnnque8HhfRoz9Pw7eiBtGuKeHEiFSyJgyLE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 25 Jul 2021 20:18:22 +0300 Message-Id: <20210725171827.23643-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 0/5] libcamera: Add type-safe enum-based flags 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hello, This small series contains patches that I've carried in my tree for some time, and that I think could be useful. Please see patches for details. The API is influenced by https://doc.qt.io/qt-5/qflags.html but goes a step further by disallowing some invalid usage of the operators that Qt silently allows for internal implementation reasons. Compared to v1, the code has been rebased on top of the latest libcamera master branch, and moved to the base library. Patches 3/5 to 5/5 have been added to showcase usage of Flags in a real world use case. Please make sure to use a Doxygen version that contains commit 309b397be106 ("issue #8281: Out-of-line documentation of scoped enums in the same namespace"), which at this point of time means the Doxygen master branch, or you will get documentation warnings. The Flags class will be used by the camera configuration API. Laurent Pinchart (5): libcamera: flags: Add type-safe enum-based flags test: Add tests for the Flags class libcamera: file: Use Flags<> class for map flags libcamera: file: Use Flags<> class for open flags libcamera: file: Turn MapFlag and OpenModeFlag into enum class include/libcamera/base/file.h | 18 ++- include/libcamera/base/flags.h | 195 +++++++++++++++++++++++++++ include/libcamera/base/meson.build | 1 + src/ipa/vimc/vimc.cpp | 2 +- src/libcamera/base/file.cpp | 48 ++++--- src/libcamera/base/flags.cpp | 192 +++++++++++++++++++++++++++ src/libcamera/base/meson.build | 1 + src/libcamera/ipa_manager.cpp | 2 +- src/libcamera/ipa_module.cpp | 6 +- test/file.cpp | 32 ++--- test/flags.cpp | 204 +++++++++++++++++++++++++++++ test/meson.build | 1 + 12 files changed, 657 insertions(+), 45 deletions(-) create mode 100644 include/libcamera/base/flags.h create mode 100644 src/libcamera/base/flags.cpp create mode 100644 test/flags.cpp