[libcamera-devel] [PATCH 0/5] Delete Copy-Move-Assign
Kieran Bingham
kieran.bingham at ideasonboard.com
Thu Oct 22 15:56:00 CEST 2020
Here's a series which has been niggling me on my task list since the
topic came up which highlighted that the non-copyability of the
FrameBufferAllocator had been incorrectly implemented.
We discussed providing a non-copyable class which could be inherited or
the addition of a macro.
I've chosen to go down the macro route, because I think its clearer,
easier to customise, and doesn't extend the inheritance (and thus
increase the size) of classes.
Along the way, the following tasks have occured:
- Classes which delete their copy constructor and copy assignment
operator, have had those replaced by DELETE_COPY_MOVE_AND_ASSIGN.
Where the existing copy/assignment deletion occured in public:, the
DELETE_COPY_MOVE_AND_ASSIGN addition has been placed in private: so
that Doxygen does not complain. (and it shoudl have the same effect)
- The Buffer class deletes all of the copy, and move constructor and
assignment operators, so this has been kept. But as the only class
which goes this far, it seems to stand out on its own. I have simply
converted to the new usage, I didn't want to change any functionality
here.
- Media objects deleted only their copy construtor. I believe this to
be an oversight, as if the copy constructor is deleted, then the copy
assignment operator should also be deleted. Therefore I see this macro
as a win here.
- MappedBuffer : This did not delete it's copy constructor, and I
believe it should have - so I've added it. I have not done a thorough
search of the tree to find other instances that should also delete
anything yet though.
I'm sure that more classes could be tightened up with the addition of
these restrictions where necessary, or perhaps other variants might crop
up. I'm not sure yet.
Kieran Bingham (5):
libcamera: Provide class.h
libcamera: buffer: Utilise DELETE_COPY_MOVE_AND_ASSIGN
libcamera: media_object: Utilise DELETE_COPY_AND_ASSIGN
libcamera: Utilise DELETE_COPY_AND_ASSIGN
libcamera: MappedBuffer: Delete copy and assignment
include/libcamera/buffer.h | 10 +++---
include/libcamera/camera.h | 7 ++--
include/libcamera/camera_manager.h | 5 +--
include/libcamera/class.h | 35 +++++++++++++++++++
include/libcamera/controls.h | 7 ++--
include/libcamera/framebuffer_allocator.h | 7 ++--
include/libcamera/internal/buffer.h | 4 +++
.../libcamera/internal/byte_stream_buffer.h | 4 +--
include/libcamera/internal/camera_sensor.h | 6 ++--
include/libcamera/internal/file.h | 6 ++--
include/libcamera/internal/log.h | 6 +++-
include/libcamera/internal/media_object.h | 8 +++--
include/libcamera/internal/pipeline_handler.h | 4 +--
include/libcamera/internal/v4l2_subdevice.h | 5 +--
include/libcamera/internal/v4l2_videodevice.h | 6 ++--
include/libcamera/meson.build | 1 +
include/libcamera/request.h | 5 +--
17 files changed, 87 insertions(+), 39 deletions(-)
create mode 100644 include/libcamera/class.h
--
2.25.1
More information about the libcamera-devel
mailing list