[Kde-imaging] Re: Operator== for ImageCollection

Aurelien Gateau aurelien.gateau at free.fr
Sat Jul 17 11:31:05 CEST 2004


Le samedi 17 Juillet 2004 11:05, Renchi Raju a écrit :
> On Sat, 17 Jul 2004, Jesper K. Pedersen wrote:
> > On Saturday 17 July 2004 10:29, Aurelien Gateau wrote:
> > | Hi!
> > |
> > | I'm working on ImageCollectionSelector, I implemented the behaviour
> > | Jesper expected (if currentAlbum is not in allAlbums, select all image
> > | collections). To do so I need to check if an image collection is equal
> > | to another. Right now I implemented it according to the attached patch.
> > | Does it look ok?
> > |
> > | If it sounds good I'll commit this and my work on
> > | ImageCollectionSelector today.
> >
> > This assumes that the same image collection is returned twice as the same
> > pointer, doesn't it? At least I simply create a new ImageCollectionShared
> > each time, so it would not work out of the box for me - of course I would
> > never return true anyway, so you should not worry about me, but I'm
> > considering what every one else does (including new host apps in the
> > future)
>
> our implementation works the same way as jesper mentioned. so it will not
> work for us either. i would recommend having two different functions
> operator==() and equals(), one which does pointer comparison and the other
> compares the urls of included items.

I think having both methods is useless if the pointer comparison is not used. 
What about the following change:


bool KIPI::ImageCollection::operator==(const KIPI::ImageCollection& ic)
{
  return *_data==*(ic->_data);
}

And:

bool KIPI::ImageCollectionShared::operator==(
  const KIPI::ImageCollectionShared& ics) 
{
  return images()==ics.images();
}

This last one could be virtual so that an host app can implement its own 
comparison operator.

Does it sound better?

Aurélien


More information about the Kde-imaging mailing list