[libcamera-devel,v3,4/7] libcamera: media_object: Utilise LIBCAMERA_DISABLE_COPY_AND_MOVE
diff mbox series

Message ID 20210212133056.873230-5-kieran.bingham@ideasonboard.com
State Accepted
Commit 234ee715176d1b631597ff535c8b82e66f59406f
Headers show
Series
  • Delete Copy-Move-Assign
Related show

Commit Message

Kieran Bingham Feb. 12, 2021, 1:30 p.m. UTC
Convert MediaLink, MediaPad, and MediaEntity to declare
LIBCAMERA_DISABLE_COPY_AND_MOVE. These classes already deleted their
copy constructor but not the assignment operator.

They should also not be movable, so expand to fully disable both copying
and moving.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 include/libcamera/internal/media_object.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Feb. 12, 2021, 2:08 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Fri, Feb 12, 2021 at 01:30:53PM +0000, Kieran Bingham wrote:
> Convert MediaLink, MediaPad, and MediaEntity to declare
> LIBCAMERA_DISABLE_COPY_AND_MOVE. These classes already deleted their
> copy constructor but not the assignment operator.
> 
> They should also not be movable, so expand to fully disable both copying
> and moving.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  include/libcamera/internal/media_object.h | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index 2b336961f98d..1c82c27928a8 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -12,6 +12,8 @@
>  
>  #include <linux/media.h>
>  
> +#include <libcamera/class.h>
> +
>  namespace libcamera {
>  
>  class MediaDevice;
> @@ -47,11 +49,12 @@ public:
>  	int setEnabled(bool enable);
>  
>  private:
> +	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink)
> +
>  	friend class MediaDevice;
>  
>  	MediaLink(const struct media_v2_link *link,
>  		  MediaPad *source, MediaPad *sink);
> -	MediaLink(const MediaLink &) = delete;
>  
>  	MediaPad *source_;
>  	MediaPad *sink_;
> @@ -69,10 +72,11 @@ public:
>  	void addLink(MediaLink *link);
>  
>  private:
> +	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaPad)
> +
>  	friend class MediaDevice;
>  
>  	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
> -	MediaPad(const MediaPad &) = delete;
>  
>  	unsigned int index_;
>  	MediaEntity *entity_;
> @@ -99,11 +103,12 @@ public:
>  	int setDeviceNode(const std::string &deviceNode);
>  
>  private:
> +	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)
> +
>  	friend class MediaDevice;
>  
>  	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
>  		    unsigned int major = 0, unsigned int minor = 0);
> -	MediaEntity(const MediaEntity &) = delete;
>  
>  	void addPad(MediaPad *pad);
>

Patch
diff mbox series

diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index 2b336961f98d..1c82c27928a8 100644
--- a/include/libcamera/internal/media_object.h
+++ b/include/libcamera/internal/media_object.h
@@ -12,6 +12,8 @@ 
 
 #include <linux/media.h>
 
+#include <libcamera/class.h>
+
 namespace libcamera {
 
 class MediaDevice;
@@ -47,11 +49,12 @@  public:
 	int setEnabled(bool enable);
 
 private:
+	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaLink)
+
 	friend class MediaDevice;
 
 	MediaLink(const struct media_v2_link *link,
 		  MediaPad *source, MediaPad *sink);
-	MediaLink(const MediaLink &) = delete;
 
 	MediaPad *source_;
 	MediaPad *sink_;
@@ -69,10 +72,11 @@  public:
 	void addLink(MediaLink *link);
 
 private:
+	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaPad)
+
 	friend class MediaDevice;
 
 	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
-	MediaPad(const MediaPad &) = delete;
 
 	unsigned int index_;
 	MediaEntity *entity_;
@@ -99,11 +103,12 @@  public:
 	int setDeviceNode(const std::string &deviceNode);
 
 private:
+	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)
+
 	friend class MediaDevice;
 
 	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
 		    unsigned int major = 0, unsigned int minor = 0);
-	MediaEntity(const MediaEntity &) = delete;
 
 	void addPad(MediaPad *pad);