[{"id":20059,"web_url":"https://patchwork.libcamera.org/comment/20059/","msgid":"<YVwe9hF3P0vG56f6@pendragon.ideasonboard.com>","date":"2021-10-05T09:46:30","subject":"Re: [libcamera-devel] [RFC PATCH 6/6] test: Remove using namespace\n\tin header files","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Tue, Oct 05, 2021 at 04:31:14PM +0900, Hirokazu Honda wrote:\n> \"using namespace\" in a header file propagates the namespace to\n> the files including the header file. So it should be avoided.\n> This removes \"using namespace\" in header files in test.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  test/camera/camera_reconfigure.cpp            |  1 +\n>  test/camera/capture.cpp                       |  1 +\n>  test/camera/configuration_default.cpp         |  1 +\n>  test/camera/configuration_set.cpp             |  1 +\n>  test/camera/statemachine.cpp                  |  1 +\n>  test/gstreamer/gstreamer_test.h               |  2 --\n>  test/libtest/buffer_source.cpp                |  2 ++\n>  test/libtest/buffer_source.h                  | 10 ++++------\n>  test/libtest/camera_test.h                    |  6 ++----\n>  test/mapped-buffer.cpp                        |  1 +\n>  test/media_device/media_device_test.h         |  6 ++----\n>  test/serialization/serialization_test.h       | 10 ++++------\n>  test/v4l2_subdevice/v4l2_subdevice_test.h     |  8 +++-----\n>  test/v4l2_videodevice/buffer_sharing.cpp      |  2 ++\n>  test/v4l2_videodevice/capture_async.cpp       |  2 ++\n>  test/v4l2_videodevice/v4l2_videodevice_test.h | 14 ++++++--------\n>  16 files changed, 33 insertions(+), 35 deletions(-)\n> \n> diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp\n> index 48d61c00..0fd8ab70 100644\n> --- a/test/camera/camera_reconfigure.cpp\n> +++ b/test/camera/camera_reconfigure.cpp\n> @@ -21,6 +21,7 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n>  using namespace std;\n>  \n>  namespace {\n> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp\n> index 238d98db..41ae00d7 100644\n> --- a/test/camera/capture.cpp\n> +++ b/test/camera/capture.cpp\n> @@ -16,6 +16,7 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n>  using namespace std;\n>  \n>  namespace {\n> diff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp\n> index c2b20194..209eb6a5 100644\n> --- a/test/camera/configuration_default.cpp\n> +++ b/test/camera/configuration_default.cpp\n> @@ -10,6 +10,7 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n>  using namespace std;\n>  \n>  namespace {\n> diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\n> index a1dc446a..4281a1c4 100644\n> --- a/test/camera/configuration_set.cpp\n> +++ b/test/camera/configuration_set.cpp\n> @@ -10,6 +10,7 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n>  using namespace std;\n>  \n>  namespace {\n> diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp\n> index 26fb5ca1..9c2b0c6a 100644\n> --- a/test/camera/statemachine.cpp\n> +++ b/test/camera/statemachine.cpp\n> @@ -12,6 +12,7 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n>  using namespace std;\n>  \n>  namespace {\n> diff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h\n> index 9c50e288..ccfe0b92 100644\n> --- a/test/gstreamer/gstreamer_test.h\n> +++ b/test/gstreamer/gstreamer_test.h\n> @@ -17,8 +17,6 @@\n>  \n>  #include <gst/gst.h>\n>  \n> -using namespace std;\n> -\n>  class GstreamerTest\n>  {\n>  public:\n> diff --git a/test/libtest/buffer_source.cpp b/test/libtest/buffer_source.cpp\n> index 64e7376a..1b261697 100644\n> --- a/test/libtest/buffer_source.cpp\n> +++ b/test/libtest/buffer_source.cpp\n> @@ -14,6 +14,8 @@\n>  \n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n> +\n>  BufferSource::BufferSource()\n>  {\n>  }\n> diff --git a/test/libtest/buffer_source.h b/test/libtest/buffer_source.h\n> index 14b4770e..84e2fa8f 100644\n> --- a/test/libtest/buffer_source.h\n> +++ b/test/libtest/buffer_source.h\n> @@ -12,20 +12,18 @@\n>  #include \"libcamera/internal/media_device.h\"\n>  #include \"libcamera/internal/v4l2_videodevice.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class BufferSource\n>  {\n>  public:\n>  \tBufferSource();\n>  \t~BufferSource();\n>  \n> -\tint allocate(const StreamConfiguration &config);\n> -\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers();\n> +\tint allocate(const libcamera::StreamConfiguration &config);\n> +\tconst std::vector<std::unique_ptr<libcamera::FrameBuffer>> &buffers();\n>  \n>  private:\n> -\tstd::shared_ptr<MediaDevice> media_;\n> -\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n> +\tstd::shared_ptr<libcamera::MediaDevice> media_;\n> +\tstd::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_;\n>  };\n>  \n>  #endif /* __LIBCAMERA_BUFFER_SOURCE_TEST_H__ */\n> diff --git a/test/libtest/camera_test.h b/test/libtest/camera_test.h\n> index f56e343e..23122245 100644\n> --- a/test/libtest/camera_test.h\n> +++ b/test/libtest/camera_test.h\n> @@ -12,8 +12,6 @@\n>  #include <libcamera/camera.h>\n>  #include <libcamera/camera_manager.h>\n>  \n> -using namespace libcamera;\n> -\n>  class CameraTest\n>  {\n>  public:\n> @@ -21,8 +19,8 @@ public:\n>  \t~CameraTest();\n>  \n>  protected:\n> -\tCameraManager *cm_;\n> -\tstd::shared_ptr<Camera> camera_;\n> +\tlibcamera::CameraManager *cm_;\n> +\tstd::shared_ptr<libcamera::Camera> camera_;\n>  \tint status_;\n>  };\n>  \n> diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp\n> index 97571945..b4422f7d 100644\n> --- a/test/mapped-buffer.cpp\n> +++ b/test/mapped-buffer.cpp\n> @@ -14,6 +14,7 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> +using namespace libcamera;\n>  using namespace std;\n>  \n>  namespace {\n> diff --git a/test/media_device/media_device_test.h b/test/media_device/media_device_test.h\n> index 0c8bf9f2..a88de56c 100644\n> --- a/test/media_device/media_device_test.h\n> +++ b/test/media_device/media_device_test.h\n> @@ -14,8 +14,6 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class MediaDeviceTest : public Test\n>  {\n>  public:\n> @@ -25,10 +23,10 @@ public:\n>  protected:\n>  \tint init();\n>  \n> -\tstd::shared_ptr<MediaDevice> media_;\n> +\tstd::shared_ptr<libcamera::MediaDevice> media_;\n>  \n>  private:\n> -\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n> +\tstd::unique_ptr<libcamera::DeviceEnumerator> enumerator_;\n>  };\n>  \n>  #endif /* __LIBCAMERA_MEDIADEVICE_TEST_H__ */\n> diff --git a/test/serialization/serialization_test.h b/test/serialization/serialization_test.h\n> index f51ae546..d654c7bf 100644\n> --- a/test/serialization/serialization_test.h\n> +++ b/test/serialization/serialization_test.h\n> @@ -14,8 +14,6 @@\n>  #include \"camera_test.h\"\n>  #include \"test.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class SerializationTest : public CameraTest, public Test\n>  {\n>  public:\n> @@ -24,10 +22,10 @@ public:\n>  \t{\n>  \t}\n>  \n> -\tstatic bool equals(const ControlInfoMap &lhs,\n> -\t\t\t   const ControlInfoMap &rhs);\n> -\tstatic bool equals(const ControlList &lhs,\n> -\t\t\t   const ControlList &rhs);\n> +\tstatic bool equals(const libcamera::ControlInfoMap &lhs,\n> +\t\t\t   const libcamera::ControlInfoMap &rhs);\n> +\tstatic bool equals(const libcamera::ControlList &lhs,\n> +\t\t\t   const libcamera::ControlList &rhs);\n>  };\n>  \n>  #endif /* __LIBCAMERA_SERIALIZATION_TEST_H__ */\n> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h\n> index e981abf7..83beb6a2 100644\n> --- a/test/v4l2_subdevice/v4l2_subdevice_test.h\n> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.h\n> @@ -16,8 +16,6 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class V4L2SubdeviceTest : public Test\n>  {\n>  public:\n> @@ -30,9 +28,9 @@ protected:\n>  \tint init() override;\n>  \tvoid cleanup() override;\n>  \n> -\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n> -\tstd::shared_ptr<MediaDevice> media_;\n> -\tV4L2Subdevice *scaler_;\n> +\tstd::unique_ptr<libcamera::DeviceEnumerator> enumerator_;\n> +\tstd::shared_ptr<libcamera::MediaDevice> media_;\n> +\tlibcamera::V4L2Subdevice *scaler_;\n>  };\n>  \n>  #endif /* __LIBCAMERA_V4L2_SUBDEVICE_TEST_H__ */\n> diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp\n> index 6af96a98..75ee93ce 100644\n> --- a/test/v4l2_videodevice/buffer_sharing.cpp\n> +++ b/test/v4l2_videodevice/buffer_sharing.cpp\n> @@ -20,6 +20,8 @@\n>  \n>  #include \"v4l2_videodevice_test.h\"\n>  \n> +using namespace libcamera;\n> +\n>  class BufferSharingTest : public V4L2VideoDeviceTest\n>  {\n>  public:\n> diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp\n> index 805cb610..3aa4ca0b 100644\n> --- a/test/v4l2_videodevice/capture_async.cpp\n> +++ b/test/v4l2_videodevice/capture_async.cpp\n> @@ -15,6 +15,8 @@\n>  \n>  #include \"v4l2_videodevice_test.h\"\n>  \n> +using namespace libcamera;\n> +\n>  class CaptureAsyncTest : public V4L2VideoDeviceTest\n>  {\n>  public:\n> diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.h b/test/v4l2_videodevice/v4l2_videodevice_test.h\n> index d46540d4..e7762294 100644\n> --- a/test/v4l2_videodevice/v4l2_videodevice_test.h\n> +++ b/test/v4l2_videodevice/v4l2_videodevice_test.h\n> @@ -19,8 +19,6 @@\n>  \n>  #include \"test.h\"\n>  \n> -using namespace libcamera;\n> -\n>  class V4L2VideoDeviceTest : public Test\n>  {\n>  public:\n> @@ -36,12 +34,12 @@ protected:\n>  \n>  \tstd::string driver_;\n>  \tstd::string entity_;\n> -\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n> -\tstd::shared_ptr<MediaDevice> media_;\n> -\tCameraSensor *sensor_;\n> -\tV4L2Subdevice *debayer_;\n> -\tV4L2VideoDevice *capture_;\n> -\tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n> +\tstd::unique_ptr<libcamera::DeviceEnumerator> enumerator_;\n> +\tstd::shared_ptr<libcamera::MediaDevice> media_;\n> +\tlibcamera::CameraSensor *sensor_;\n> +\tlibcamera::V4L2Subdevice *debayer_;\n> +\tlibcamera::V4L2VideoDevice *capture_;\n> +\tstd::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_;\n>  };\n>  \n>  #endif /* __LIBCAMERA_V4L2_DEVICE_TEST_H_ */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7DC55BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  5 Oct 2021 09:46:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4DE4E691B6;\n\tTue,  5 Oct 2021 11:46:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB934684C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  5 Oct 2021 11:46:37 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77D6825B;\n\tTue,  5 Oct 2021 11:46:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"U1xqfz0m\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633427197;\n\tbh=koqRQ+q438VX6Q0BWdJjdWwy7m9naLQKAgnIPOX/VgQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=U1xqfz0mZ+jt4d111pZSPfCAo9AlMruYtAHtMGbX4/481Tg28dzqBc/eyFKx23NbK\n\tmQBMcLhhBFr7BNfRm+SREEuO8qzXmfNm0UFZ72cdLR5c8rh7S1UcLqUo1MZY+ZUpqx\n\tiu5bPpBaWixF4yCK3UV6qro+I8lEz/3fmSqYNuiQ=","Date":"Tue, 5 Oct 2021 12:46:30 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YVwe9hF3P0vG56f6@pendragon.ideasonboard.com>","References":"<20211005073114.3997303-1-hiroh@chromium.org>\n\t<20211005073114.3997303-7-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211005073114.3997303-7-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [RFC PATCH 6/6] test: Remove using namespace\n\tin header files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]