[libcamera-devel] [PATCH 3/5] libcamera: media_object: Utilise DELETE_COPY_AND_ASSIGN

Kieran Bingham kieran.bingham at ideasonboard.com
Thu Oct 22 15:56:03 CEST 2020


Convert MediaLink, MediaPad, and MediaEntity to declare DELETE_COPY_AND_ASSIGN.
These classes already deleted their copy constructor but not the assignment operator.

Utilising the DELETE_COPY_AND_ASSIGN prevents all copying of these classes.

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

diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index be6fb8961349..f467883072d2 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;
@@ -50,7 +52,7 @@ private:
 
 	MediaLink(const struct media_v2_link *link,
 		  MediaPad *source, MediaPad *sink);
-	MediaLink(const MediaLink &) = delete;
+	DELETE_COPY_AND_ASSIGN(MediaLink);
 	~MediaLink() {}
 
 	MediaPad *source_;
@@ -72,7 +74,7 @@ private:
 	friend class MediaDevice;
 
 	MediaPad(const struct media_v2_pad *pad, MediaEntity *entity);
-	MediaPad(const MediaPad &) = delete;
+	DELETE_COPY_AND_ASSIGN(MediaPad);
 	~MediaPad();
 
 	unsigned int index_;
@@ -104,7 +106,7 @@ private:
 
 	MediaEntity(MediaDevice *dev, const struct media_v2_entity *entity,
 		    unsigned int major = 0, unsigned int minor = 0);
-	MediaEntity(const MediaEntity &) = delete;
+	DELETE_COPY_AND_ASSIGN(MediaEntity);
 	~MediaEntity();
 
 	void addPad(MediaPad *pad);
-- 
2.25.1



More information about the libcamera-devel mailing list