Const iterators, what's next ?

Cyrille Berger cberger at cberger.net
Thu Oct 19 00:25:30 CEST 2006


Hi,
I have completed the first step of const iterators, at least the exposed 
iterators are clean, the internal is a little bit hacky as it is constructed 
on top of what we had before which wasn't designed with const in mind. But I 
will leave to someone who know best to transform the tilemanager to be 
cleaner.

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;

-- 
--- Cyrille Berger ---


More information about the kimageshop mailing list