[Xapian-devel] Branching for 1.1
Richard Boulton
richard at lemurconsulting.com
Fri Feb 22 12:20:28 GMT 2008
Olly Betts wrote:
> On Fri, Feb 22, 2008 at 11:57:12AM +0000, Richard Boulton wrote:
>> I'm not sure whether it's safe if the copy constructor or assignment
>> operator on the subclass are used, though - I'll double-check that.
>
> I think it will fail, because we expect to be able to do things like:
>
> Xapian::Stem copy_of_stemmer = stemmer;
>
> And that doesn't work if stemmer is a subclass of Xapian::Stem.
>
> Mind you, making Xapian::Stem wrap an enum doesn't help here either...
I agree. Argh.
One API for this, then, would be to change Xapian::Stem to be an
abstract class, and move the implementation to a Xapian::SnowballStem
class. However, this would break too much existing code to be a
reasonable solution, in the near term, anyway.
What about the following:
- add a Xapian::BaseStem class, which is abstract.
- make Xapian::Stem inherit from this.
- change TermGenerator and QueryParser to take a Xapian::BaseStem
instead of a stem class.
User code would continue to work (after a recompile), but users could
also create their own subclasses (of BaseStem) and use them with
TermGenerator and QueryParser.
Really though, what we want is a better reference counting scheme which
allows the reference counted objects to be subclassed. Bug 186 is the
relevant one, I suppose (though coming at it from the opposite direction
- it's about subclassable objects not being reference counted):
http://xapian.org/cgi-bin/bugzilla/show_bug.cgi?id=186
However, I'm not sure how we could implement this - any ideas?
--
Richard
More information about the Xapian-devel
mailing list