[libcamera-devel,RFC,6/6] test: Remove using namespace in header files
diff mbox series

Message ID 20211005073114.3997303-7-hiroh@chromium.org
State Accepted
Headers show
Series
  • Remove using namespace in header files
Related show

Commit Message

Hirokazu Honda Oct. 5, 2021, 7:31 a.m. UTC
"using namespace" in a header file propagates the namespace to
the files including the header file. So it should be avoided.
This removes "using namespace" in header files in test.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
---
 test/camera/camera_reconfigure.cpp            |  1 +
 test/camera/capture.cpp                       |  1 +
 test/camera/configuration_default.cpp         |  1 +
 test/camera/configuration_set.cpp             |  1 +
 test/camera/statemachine.cpp                  |  1 +
 test/gstreamer/gstreamer_test.h               |  2 --
 test/libtest/buffer_source.cpp                |  2 ++
 test/libtest/buffer_source.h                  | 10 ++++------
 test/libtest/camera_test.h                    |  6 ++----
 test/mapped-buffer.cpp                        |  1 +
 test/media_device/media_device_test.h         |  6 ++----
 test/serialization/serialization_test.h       | 10 ++++------
 test/v4l2_subdevice/v4l2_subdevice_test.h     |  8 +++-----
 test/v4l2_videodevice/buffer_sharing.cpp      |  2 ++
 test/v4l2_videodevice/capture_async.cpp       |  2 ++
 test/v4l2_videodevice/v4l2_videodevice_test.h | 14 ++++++--------
 16 files changed, 33 insertions(+), 35 deletions(-)

Comments

Laurent Pinchart Oct. 5, 2021, 9:46 a.m. UTC | #1
Hi Hiro,

Thank you for the patch.

On Tue, Oct 05, 2021 at 04:31:14PM +0900, Hirokazu Honda wrote:
> "using namespace" in a header file propagates the namespace to
> the files including the header file. So it should be avoided.
> This removes "using namespace" in header files in test.
> 
> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  test/camera/camera_reconfigure.cpp            |  1 +
>  test/camera/capture.cpp                       |  1 +
>  test/camera/configuration_default.cpp         |  1 +
>  test/camera/configuration_set.cpp             |  1 +
>  test/camera/statemachine.cpp                  |  1 +
>  test/gstreamer/gstreamer_test.h               |  2 --
>  test/libtest/buffer_source.cpp                |  2 ++
>  test/libtest/buffer_source.h                  | 10 ++++------
>  test/libtest/camera_test.h                    |  6 ++----
>  test/mapped-buffer.cpp                        |  1 +
>  test/media_device/media_device_test.h         |  6 ++----
>  test/serialization/serialization_test.h       | 10 ++++------
>  test/v4l2_subdevice/v4l2_subdevice_test.h     |  8 +++-----
>  test/v4l2_videodevice/buffer_sharing.cpp      |  2 ++
>  test/v4l2_videodevice/capture_async.cpp       |  2 ++
>  test/v4l2_videodevice/v4l2_videodevice_test.h | 14 ++++++--------
>  16 files changed, 33 insertions(+), 35 deletions(-)
> 
> diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp
> index 48d61c00..0fd8ab70 100644
> --- a/test/camera/camera_reconfigure.cpp
> +++ b/test/camera/camera_reconfigure.cpp
> @@ -21,6 +21,7 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> +using namespace libcamera;
>  using namespace std;
>  
>  namespace {
> diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
> index 238d98db..41ae00d7 100644
> --- a/test/camera/capture.cpp
> +++ b/test/camera/capture.cpp
> @@ -16,6 +16,7 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> +using namespace libcamera;
>  using namespace std;
>  
>  namespace {
> diff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp
> index c2b20194..209eb6a5 100644
> --- a/test/camera/configuration_default.cpp
> +++ b/test/camera/configuration_default.cpp
> @@ -10,6 +10,7 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> +using namespace libcamera;
>  using namespace std;
>  
>  namespace {
> diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp
> index a1dc446a..4281a1c4 100644
> --- a/test/camera/configuration_set.cpp
> +++ b/test/camera/configuration_set.cpp
> @@ -10,6 +10,7 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> +using namespace libcamera;
>  using namespace std;
>  
>  namespace {
> diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp
> index 26fb5ca1..9c2b0c6a 100644
> --- a/test/camera/statemachine.cpp
> +++ b/test/camera/statemachine.cpp
> @@ -12,6 +12,7 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> +using namespace libcamera;
>  using namespace std;
>  
>  namespace {
> diff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h
> index 9c50e288..ccfe0b92 100644
> --- a/test/gstreamer/gstreamer_test.h
> +++ b/test/gstreamer/gstreamer_test.h
> @@ -17,8 +17,6 @@
>  
>  #include <gst/gst.h>
>  
> -using namespace std;
> -
>  class GstreamerTest
>  {
>  public:
> diff --git a/test/libtest/buffer_source.cpp b/test/libtest/buffer_source.cpp
> index 64e7376a..1b261697 100644
> --- a/test/libtest/buffer_source.cpp
> +++ b/test/libtest/buffer_source.cpp
> @@ -14,6 +14,8 @@
>  
>  #include "test.h"
>  
> +using namespace libcamera;
> +
>  BufferSource::BufferSource()
>  {
>  }
> diff --git a/test/libtest/buffer_source.h b/test/libtest/buffer_source.h
> index 14b4770e..84e2fa8f 100644
> --- a/test/libtest/buffer_source.h
> +++ b/test/libtest/buffer_source.h
> @@ -12,20 +12,18 @@
>  #include "libcamera/internal/media_device.h"
>  #include "libcamera/internal/v4l2_videodevice.h"
>  
> -using namespace libcamera;
> -
>  class BufferSource
>  {
>  public:
>  	BufferSource();
>  	~BufferSource();
>  
> -	int allocate(const StreamConfiguration &config);
> -	const std::vector<std::unique_ptr<FrameBuffer>> &buffers();
> +	int allocate(const libcamera::StreamConfiguration &config);
> +	const std::vector<std::unique_ptr<libcamera::FrameBuffer>> &buffers();
>  
>  private:
> -	std::shared_ptr<MediaDevice> media_;
> -	std::vector<std::unique_ptr<FrameBuffer>> buffers_;
> +	std::shared_ptr<libcamera::MediaDevice> media_;
> +	std::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_;
>  };
>  
>  #endif /* __LIBCAMERA_BUFFER_SOURCE_TEST_H__ */
> diff --git a/test/libtest/camera_test.h b/test/libtest/camera_test.h
> index f56e343e..23122245 100644
> --- a/test/libtest/camera_test.h
> +++ b/test/libtest/camera_test.h
> @@ -12,8 +12,6 @@
>  #include <libcamera/camera.h>
>  #include <libcamera/camera_manager.h>
>  
> -using namespace libcamera;
> -
>  class CameraTest
>  {
>  public:
> @@ -21,8 +19,8 @@ public:
>  	~CameraTest();
>  
>  protected:
> -	CameraManager *cm_;
> -	std::shared_ptr<Camera> camera_;
> +	libcamera::CameraManager *cm_;
> +	std::shared_ptr<libcamera::Camera> camera_;
>  	int status_;
>  };
>  
> diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp
> index 97571945..b4422f7d 100644
> --- a/test/mapped-buffer.cpp
> +++ b/test/mapped-buffer.cpp
> @@ -14,6 +14,7 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> +using namespace libcamera;
>  using namespace std;
>  
>  namespace {
> diff --git a/test/media_device/media_device_test.h b/test/media_device/media_device_test.h
> index 0c8bf9f2..a88de56c 100644
> --- a/test/media_device/media_device_test.h
> +++ b/test/media_device/media_device_test.h
> @@ -14,8 +14,6 @@
>  
>  #include "test.h"
>  
> -using namespace libcamera;
> -
>  class MediaDeviceTest : public Test
>  {
>  public:
> @@ -25,10 +23,10 @@ public:
>  protected:
>  	int init();
>  
> -	std::shared_ptr<MediaDevice> media_;
> +	std::shared_ptr<libcamera::MediaDevice> media_;
>  
>  private:
> -	std::unique_ptr<DeviceEnumerator> enumerator_;
> +	std::unique_ptr<libcamera::DeviceEnumerator> enumerator_;
>  };
>  
>  #endif /* __LIBCAMERA_MEDIADEVICE_TEST_H__ */
> diff --git a/test/serialization/serialization_test.h b/test/serialization/serialization_test.h
> index f51ae546..d654c7bf 100644
> --- a/test/serialization/serialization_test.h
> +++ b/test/serialization/serialization_test.h
> @@ -14,8 +14,6 @@
>  #include "camera_test.h"
>  #include "test.h"
>  
> -using namespace libcamera;
> -
>  class SerializationTest : public CameraTest, public Test
>  {
>  public:
> @@ -24,10 +22,10 @@ public:
>  	{
>  	}
>  
> -	static bool equals(const ControlInfoMap &lhs,
> -			   const ControlInfoMap &rhs);
> -	static bool equals(const ControlList &lhs,
> -			   const ControlList &rhs);
> +	static bool equals(const libcamera::ControlInfoMap &lhs,
> +			   const libcamera::ControlInfoMap &rhs);
> +	static bool equals(const libcamera::ControlList &lhs,
> +			   const libcamera::ControlList &rhs);
>  };
>  
>  #endif /* __LIBCAMERA_SERIALIZATION_TEST_H__ */
> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h
> index e981abf7..83beb6a2 100644
> --- a/test/v4l2_subdevice/v4l2_subdevice_test.h
> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.h
> @@ -16,8 +16,6 @@
>  
>  #include "test.h"
>  
> -using namespace libcamera;
> -
>  class V4L2SubdeviceTest : public Test
>  {
>  public:
> @@ -30,9 +28,9 @@ protected:
>  	int init() override;
>  	void cleanup() override;
>  
> -	std::unique_ptr<DeviceEnumerator> enumerator_;
> -	std::shared_ptr<MediaDevice> media_;
> -	V4L2Subdevice *scaler_;
> +	std::unique_ptr<libcamera::DeviceEnumerator> enumerator_;
> +	std::shared_ptr<libcamera::MediaDevice> media_;
> +	libcamera::V4L2Subdevice *scaler_;
>  };
>  
>  #endif /* __LIBCAMERA_V4L2_SUBDEVICE_TEST_H__ */
> diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp
> index 6af96a98..75ee93ce 100644
> --- a/test/v4l2_videodevice/buffer_sharing.cpp
> +++ b/test/v4l2_videodevice/buffer_sharing.cpp
> @@ -20,6 +20,8 @@
>  
>  #include "v4l2_videodevice_test.h"
>  
> +using namespace libcamera;
> +
>  class BufferSharingTest : public V4L2VideoDeviceTest
>  {
>  public:
> diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp
> index 805cb610..3aa4ca0b 100644
> --- a/test/v4l2_videodevice/capture_async.cpp
> +++ b/test/v4l2_videodevice/capture_async.cpp
> @@ -15,6 +15,8 @@
>  
>  #include "v4l2_videodevice_test.h"
>  
> +using namespace libcamera;
> +
>  class CaptureAsyncTest : public V4L2VideoDeviceTest
>  {
>  public:
> diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.h b/test/v4l2_videodevice/v4l2_videodevice_test.h
> index d46540d4..e7762294 100644
> --- a/test/v4l2_videodevice/v4l2_videodevice_test.h
> +++ b/test/v4l2_videodevice/v4l2_videodevice_test.h
> @@ -19,8 +19,6 @@
>  
>  #include "test.h"
>  
> -using namespace libcamera;
> -
>  class V4L2VideoDeviceTest : public Test
>  {
>  public:
> @@ -36,12 +34,12 @@ protected:
>  
>  	std::string driver_;
>  	std::string entity_;
> -	std::unique_ptr<DeviceEnumerator> enumerator_;
> -	std::shared_ptr<MediaDevice> media_;
> -	CameraSensor *sensor_;
> -	V4L2Subdevice *debayer_;
> -	V4L2VideoDevice *capture_;
> -	std::vector<std::unique_ptr<FrameBuffer>> buffers_;
> +	std::unique_ptr<libcamera::DeviceEnumerator> enumerator_;
> +	std::shared_ptr<libcamera::MediaDevice> media_;
> +	libcamera::CameraSensor *sensor_;
> +	libcamera::V4L2Subdevice *debayer_;
> +	libcamera::V4L2VideoDevice *capture_;
> +	std::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_;
>  };
>  
>  #endif /* __LIBCAMERA_V4L2_DEVICE_TEST_H_ */

Patch
diff mbox series

diff --git a/test/camera/camera_reconfigure.cpp b/test/camera/camera_reconfigure.cpp
index 48d61c00..0fd8ab70 100644
--- a/test/camera/camera_reconfigure.cpp
+++ b/test/camera/camera_reconfigure.cpp
@@ -21,6 +21,7 @@ 
 #include "camera_test.h"
 #include "test.h"
 
+using namespace libcamera;
 using namespace std;
 
 namespace {
diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp
index 238d98db..41ae00d7 100644
--- a/test/camera/capture.cpp
+++ b/test/camera/capture.cpp
@@ -16,6 +16,7 @@ 
 #include "camera_test.h"
 #include "test.h"
 
+using namespace libcamera;
 using namespace std;
 
 namespace {
diff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp
index c2b20194..209eb6a5 100644
--- a/test/camera/configuration_default.cpp
+++ b/test/camera/configuration_default.cpp
@@ -10,6 +10,7 @@ 
 #include "camera_test.h"
 #include "test.h"
 
+using namespace libcamera;
 using namespace std;
 
 namespace {
diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp
index a1dc446a..4281a1c4 100644
--- a/test/camera/configuration_set.cpp
+++ b/test/camera/configuration_set.cpp
@@ -10,6 +10,7 @@ 
 #include "camera_test.h"
 #include "test.h"
 
+using namespace libcamera;
 using namespace std;
 
 namespace {
diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp
index 26fb5ca1..9c2b0c6a 100644
--- a/test/camera/statemachine.cpp
+++ b/test/camera/statemachine.cpp
@@ -12,6 +12,7 @@ 
 #include "camera_test.h"
 #include "test.h"
 
+using namespace libcamera;
 using namespace std;
 
 namespace {
diff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h
index 9c50e288..ccfe0b92 100644
--- a/test/gstreamer/gstreamer_test.h
+++ b/test/gstreamer/gstreamer_test.h
@@ -17,8 +17,6 @@ 
 
 #include <gst/gst.h>
 
-using namespace std;
-
 class GstreamerTest
 {
 public:
diff --git a/test/libtest/buffer_source.cpp b/test/libtest/buffer_source.cpp
index 64e7376a..1b261697 100644
--- a/test/libtest/buffer_source.cpp
+++ b/test/libtest/buffer_source.cpp
@@ -14,6 +14,8 @@ 
 
 #include "test.h"
 
+using namespace libcamera;
+
 BufferSource::BufferSource()
 {
 }
diff --git a/test/libtest/buffer_source.h b/test/libtest/buffer_source.h
index 14b4770e..84e2fa8f 100644
--- a/test/libtest/buffer_source.h
+++ b/test/libtest/buffer_source.h
@@ -12,20 +12,18 @@ 
 #include "libcamera/internal/media_device.h"
 #include "libcamera/internal/v4l2_videodevice.h"
 
-using namespace libcamera;
-
 class BufferSource
 {
 public:
 	BufferSource();
 	~BufferSource();
 
-	int allocate(const StreamConfiguration &config);
-	const std::vector<std::unique_ptr<FrameBuffer>> &buffers();
+	int allocate(const libcamera::StreamConfiguration &config);
+	const std::vector<std::unique_ptr<libcamera::FrameBuffer>> &buffers();
 
 private:
-	std::shared_ptr<MediaDevice> media_;
-	std::vector<std::unique_ptr<FrameBuffer>> buffers_;
+	std::shared_ptr<libcamera::MediaDevice> media_;
+	std::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_;
 };
 
 #endif /* __LIBCAMERA_BUFFER_SOURCE_TEST_H__ */
diff --git a/test/libtest/camera_test.h b/test/libtest/camera_test.h
index f56e343e..23122245 100644
--- a/test/libtest/camera_test.h
+++ b/test/libtest/camera_test.h
@@ -12,8 +12,6 @@ 
 #include <libcamera/camera.h>
 #include <libcamera/camera_manager.h>
 
-using namespace libcamera;
-
 class CameraTest
 {
 public:
@@ -21,8 +19,8 @@  public:
 	~CameraTest();
 
 protected:
-	CameraManager *cm_;
-	std::shared_ptr<Camera> camera_;
+	libcamera::CameraManager *cm_;
+	std::shared_ptr<libcamera::Camera> camera_;
 	int status_;
 };
 
diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp
index 97571945..b4422f7d 100644
--- a/test/mapped-buffer.cpp
+++ b/test/mapped-buffer.cpp
@@ -14,6 +14,7 @@ 
 #include "camera_test.h"
 #include "test.h"
 
+using namespace libcamera;
 using namespace std;
 
 namespace {
diff --git a/test/media_device/media_device_test.h b/test/media_device/media_device_test.h
index 0c8bf9f2..a88de56c 100644
--- a/test/media_device/media_device_test.h
+++ b/test/media_device/media_device_test.h
@@ -14,8 +14,6 @@ 
 
 #include "test.h"
 
-using namespace libcamera;
-
 class MediaDeviceTest : public Test
 {
 public:
@@ -25,10 +23,10 @@  public:
 protected:
 	int init();
 
-	std::shared_ptr<MediaDevice> media_;
+	std::shared_ptr<libcamera::MediaDevice> media_;
 
 private:
-	std::unique_ptr<DeviceEnumerator> enumerator_;
+	std::unique_ptr<libcamera::DeviceEnumerator> enumerator_;
 };
 
 #endif /* __LIBCAMERA_MEDIADEVICE_TEST_H__ */
diff --git a/test/serialization/serialization_test.h b/test/serialization/serialization_test.h
index f51ae546..d654c7bf 100644
--- a/test/serialization/serialization_test.h
+++ b/test/serialization/serialization_test.h
@@ -14,8 +14,6 @@ 
 #include "camera_test.h"
 #include "test.h"
 
-using namespace libcamera;
-
 class SerializationTest : public CameraTest, public Test
 {
 public:
@@ -24,10 +22,10 @@  public:
 	{
 	}
 
-	static bool equals(const ControlInfoMap &lhs,
-			   const ControlInfoMap &rhs);
-	static bool equals(const ControlList &lhs,
-			   const ControlList &rhs);
+	static bool equals(const libcamera::ControlInfoMap &lhs,
+			   const libcamera::ControlInfoMap &rhs);
+	static bool equals(const libcamera::ControlList &lhs,
+			   const libcamera::ControlList &rhs);
 };
 
 #endif /* __LIBCAMERA_SERIALIZATION_TEST_H__ */
diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h
index e981abf7..83beb6a2 100644
--- a/test/v4l2_subdevice/v4l2_subdevice_test.h
+++ b/test/v4l2_subdevice/v4l2_subdevice_test.h
@@ -16,8 +16,6 @@ 
 
 #include "test.h"
 
-using namespace libcamera;
-
 class V4L2SubdeviceTest : public Test
 {
 public:
@@ -30,9 +28,9 @@  protected:
 	int init() override;
 	void cleanup() override;
 
-	std::unique_ptr<DeviceEnumerator> enumerator_;
-	std::shared_ptr<MediaDevice> media_;
-	V4L2Subdevice *scaler_;
+	std::unique_ptr<libcamera::DeviceEnumerator> enumerator_;
+	std::shared_ptr<libcamera::MediaDevice> media_;
+	libcamera::V4L2Subdevice *scaler_;
 };
 
 #endif /* __LIBCAMERA_V4L2_SUBDEVICE_TEST_H__ */
diff --git a/test/v4l2_videodevice/buffer_sharing.cpp b/test/v4l2_videodevice/buffer_sharing.cpp
index 6af96a98..75ee93ce 100644
--- a/test/v4l2_videodevice/buffer_sharing.cpp
+++ b/test/v4l2_videodevice/buffer_sharing.cpp
@@ -20,6 +20,8 @@ 
 
 #include "v4l2_videodevice_test.h"
 
+using namespace libcamera;
+
 class BufferSharingTest : public V4L2VideoDeviceTest
 {
 public:
diff --git a/test/v4l2_videodevice/capture_async.cpp b/test/v4l2_videodevice/capture_async.cpp
index 805cb610..3aa4ca0b 100644
--- a/test/v4l2_videodevice/capture_async.cpp
+++ b/test/v4l2_videodevice/capture_async.cpp
@@ -15,6 +15,8 @@ 
 
 #include "v4l2_videodevice_test.h"
 
+using namespace libcamera;
+
 class CaptureAsyncTest : public V4L2VideoDeviceTest
 {
 public:
diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.h b/test/v4l2_videodevice/v4l2_videodevice_test.h
index d46540d4..e7762294 100644
--- a/test/v4l2_videodevice/v4l2_videodevice_test.h
+++ b/test/v4l2_videodevice/v4l2_videodevice_test.h
@@ -19,8 +19,6 @@ 
 
 #include "test.h"
 
-using namespace libcamera;
-
 class V4L2VideoDeviceTest : public Test
 {
 public:
@@ -36,12 +34,12 @@  protected:
 
 	std::string driver_;
 	std::string entity_;
-	std::unique_ptr<DeviceEnumerator> enumerator_;
-	std::shared_ptr<MediaDevice> media_;
-	CameraSensor *sensor_;
-	V4L2Subdevice *debayer_;
-	V4L2VideoDevice *capture_;
-	std::vector<std::unique_ptr<FrameBuffer>> buffers_;
+	std::unique_ptr<libcamera::DeviceEnumerator> enumerator_;
+	std::shared_ptr<libcamera::MediaDevice> media_;
+	libcamera::CameraSensor *sensor_;
+	libcamera::V4L2Subdevice *debayer_;
+	libcamera::V4L2VideoDevice *capture_;
+	std::vector<std::unique_ptr<libcamera::FrameBuffer>> buffers_;
 };
 
 #endif /* __LIBCAMERA_V4L2_DEVICE_TEST_H_ */