[libcamera-devel,1/2] media_entity: Overload == operator to use media-entities in maps
diff mbox series

Message ID 20210309112949.26251-2-m.cichy@pengutronix.de
State Rejected
Headers show
Series
  • [libcamera-devel,1/2] media_entity: Overload == operator to use media-entities in maps
Related show

Commit Message

Marian Cichy March 9, 2021, 11:29 a.m. UTC
Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
---
 include/libcamera/internal/media_object.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Laurent Pinchart March 9, 2021, 12:28 p.m. UTC | #1
Hi Marian,

Thank you for the patch.

On Tue, Mar 09, 2021 at 12:29:48PM +0100, Marian Cichy wrote:
> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
> ---
>  include/libcamera/internal/media_object.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index 1c82c279..1ed95863 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -102,6 +102,8 @@ public:
>  
>  	int setDeviceNode(const std::string &deviceNode);
>  
> +	bool operator==(const MediaEntity &other) { return name() == other.name(); }
> +

Documentation is missing, didn't doxygen warn you ?

This being said, this patch doesn't seem to be needed for 2/2, which
compiles fine without 1/2. Am I missing something ?

>  private:
>  	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)
>
Marian Cichy March 9, 2021, 1:51 p.m. UTC | #2
On 3/9/21 1:28 PM, Laurent Pinchart wrote:
> Hi Marian,
>
> Thank you for the patch.
>
> On Tue, Mar 09, 2021 at 12:29:48PM +0100, Marian Cichy wrote:
>> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
>> ---
>>   include/libcamera/internal/media_object.h | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
>> index 1c82c279..1ed95863 100644
>> --- a/include/libcamera/internal/media_object.h
>> +++ b/include/libcamera/internal/media_object.h
>> @@ -102,6 +102,8 @@ public:
>>   
>>   	int setDeviceNode(const std::string &deviceNode);
>>   
>> +	bool operator==(const MediaEntity &other) { return name() == other.name(); }
>> +
> Documentation is missing, didn't doxygen warn you ?
>
> This being said, this patch doesn't seem to be needed for 2/2, which
> compiles fine without 1/2. Am I missing something ?

You're right. I was under the impression that I need to overload this 
operator in order to use the class as keys in std::unordered_map, but it 
just works fine without the patch. So I guess better ignore this one.

Regards
Marian

>
>>   private:
>>   	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)
>>
Laurent Pinchart March 9, 2021, 3:29 p.m. UTC | #3
Hi Marian,

On Tue, Mar 09, 2021 at 02:51:18PM +0100, Marian Cichy wrote:
> On 3/9/21 1:28 PM, Laurent Pinchart wrote:
> > On Tue, Mar 09, 2021 at 12:29:48PM +0100, Marian Cichy wrote:
> >> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
> >> ---
> >>   include/libcamera/internal/media_object.h | 2 ++
> >>   1 file changed, 2 insertions(+)
> >>
> >> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> >> index 1c82c279..1ed95863 100644
> >> --- a/include/libcamera/internal/media_object.h
> >> +++ b/include/libcamera/internal/media_object.h
> >> @@ -102,6 +102,8 @@ public:
> >>   
> >>   	int setDeviceNode(const std::string &deviceNode);
> >>   
> >> +	bool operator==(const MediaEntity &other) { return name() == other.name(); }
> >> +
> > Documentation is missing, didn't doxygen warn you ?
> >
> > This being said, this patch doesn't seem to be needed for 2/2, which
> > compiles fine without 1/2. Am I missing something ?
> 
> You're right. I was under the impression that I need to overload this 
> operator in order to use the class as keys in std::unordered_map, but it 
> just works fine without the patch. So I guess better ignore this one.

If you were iusing MediaEntity perhaps, but you're storing pointers in
your containers, so nothing else should be needed.

> >>   private:
> >>   	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)
> >>

Patch
diff mbox series

diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
index 1c82c279..1ed95863 100644
--- a/include/libcamera/internal/media_object.h
+++ b/include/libcamera/internal/media_object.h
@@ -102,6 +102,8 @@  public:
 
 	int setDeviceNode(const std::string &deviceNode);
 
+	bool operator==(const MediaEntity &other) { return name() == other.name(); }
+
 private:
 	LIBCAMERA_DISABLE_COPY_AND_MOVE(MediaEntity)