Const iterators, what's next ?

Casper Boemann cbr at boemann.dk
Thu Oct 19 08:28:42 CEST 2006


Hi

First of all I don't get it. What exactly have you constified. A const 
iterator can't move so it can't be like a const class.

Previously we had a bool writable argument. Is that what you intend/have 
removed in favour of two destinct classes with slightly different signatures 
regarding access to pixels?

I would like that, and as a consequence I also like two different factory 
methods. I think it makes things more clear. However I don't think they 
should be named const iterators, but rather Read and Write iterators (if that 
is what they are?)

>
> Now it's time to constify a little bit more our API, but I have two
> questions:
>
> 1) right now const and non const iterators share the same function
> signature, I mean we have (for instance):
>     KisHLineConstIteratorPixel createHLineIterator(qint32 x, qint32 y,
> qint32 w) const;
>     KisHLineIteratorPixel createHLineIterator(qint32 x, qint32 y, qint32
> w); Which is what we often see, but I was wondering if it wasn't best to
> have instead: KisHLineConstIteratorPixel createHLineConstIterator(qint32 x,
> qint32 y, qint32 w) const;
> Because in the current situation, if we have:
> KisPaintDeviceSP device = smthg;
> KisHLineConstIteratorPixel  it = smthg->createHLineConstIterator(smthg);
> Then it's the non const function that is called, and the iterator is
> converted to KisHLineConstIteratorPixel, and I am not sure that first
> creating a non const iterator is really a good idea ? Any thought ? (maybe
> bart or casper will know best)
>
> 2) In KisFilter, we have :
> virtual void process(KisPaintDeviceSP src, KisPaintDeviceSP dst,
> KisFilterConfiguration*, const QRect&) = 0;
> The next logical step is to transform it to:
> virtual void process(const KisPaintDeviceSP src, KisPaintDeviceSP dst,
> KisFilterConfiguration*, const QRect&) = 0;
>
> The question we need to settle is "do we keep src" ? Or do we choose to
> have this function in KisFilter : virtual void process(KisPaintDeviceSP
> dev, KisFilterConfiguration*, const QRect&) = 0;

-- 
best regards / venlig hilsen
Casper Boemann


More information about the kimageshop mailing list