What I do in Qt doc is to have a static member with the provider and return that one.<br>That way every IDocumentation instance doesn't store a pointer to the provider (which is shared, of course).<br><br><div class="gmail_quote">
On Tue, Dec 1, 2009 at 9:39 PM, Milian Wolff <span dir="ltr"><<a href="mailto:mail@milianw.de">mail@milianw.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Tuesday, 1. December 2009 21:30:05 Milian Wolff wrote:<br>
> On Monday, 30. November 2009 22:54:19 Milian Wolff wrote:<br>
> > On Monday 30 November 2009 22:12:58 Andreas Pakulat wrote:<br>
> > > On 30.11.09 18:53:51, Milian Wolff wrote:<br>
> > > > On Monday, 30. November 2009 18:28:26 Andreas Pakulat wrote:<br>
> > > > > On 30.11.09 17:14:23, Milian Wolff wrote:<br>
> > > > > > Hey all, esp. Apol:<br>
> > > > > ><br>
> > > > > > Can I remove the "const" from IDocumentationProvider::homePage()<br>
> > > > > > ? Thing is, that I want to pass "this" as parent/provider to the<br>
> > > > > > returned IDocumentation. This fails, since this is const, but it<br>
> > > > > > should be non-const.<br>
> > > > ><br>
> > > > > I strongly object to that. A getter like homePage ought to be<br>
> > > > > const, else its suggesting to do something other than fetching some<br>
> > > > > data.<br>
> > > > ><br>
> > > > > As David said, either use const-cast, or maybe you should fix the<br>
> > > > > rest of the calling chain to also be const.<br>
> > > ><br>
> > > > Hm, ok but than I'd say other places have to become const as well:<br>
> > > ><br>
> > > > Provider:<br>
> > > > - documentationForIndex (same problem with parent as above)<br>
> > > > - documentationForDeclaration (again, same)<br>
> > > > - indexModel (this one definitely, will change it asap)<br>
> > ><br>
> > > See below<br>
> > ><br>
> > > > - jumpedTo (since it only emits addHistory with a IDocumentation ptr)<br>
> > ><br>
> > > This one sounds more like a signal thats being emitted, IMHO its a bad<br>
> > > name for anything else than that..<br>
> ><br>
> > It takes just an KUrl and emits addHistory(KSharedPtr<IDocumentation>),<br>
> > so it's more than a simple signal (but very close to it).<br>
> ><br>
> > > > Documentation:<br>
> > > > - provider() should return a const KDevelop::IDocumentationProvider*<br>
> > > ><br>
> > > > Should I do that? Imo having it all const I'd have no problems<br>
> > > > what-so-ever and wouldn't require any const-casts. The provider stays<br>
> > > > the same, the DocumentationController is the one that changes.<br>
> > ><br>
> > > Without any look at the api that makes sense to me from purely the<br>
> > > function names. Of course you might start on a snowball here if the<br>
> > > implementations for those functions also need some kind of non-const<br>
> > > object...<br>
> ><br>
> > I'll have a look at it, and if it works out I'll change it accordingly.<br>
><br>
> OK, all done now. I think I constified pretty much everything in the API<br>
> and did not require any deep changes in the implementations. Nice!<br>
<br>
</div></div>Hm, one thing I forgot:<br>
should the IDocumentationProvider returned by m_provider be const? I mean the<br>
public API only consists of const stuff, but I still have to const_cast<> it<br>
before I can return it...<br>
<br>
And it looks like pointer to providers are used quite often in KDevplatform<br>
(the documentation controller esp.).<br>
<br>
It would require lots of (simple) changes there, just to get rid of a single<br>
const_cast - is it worth it?<br>
<div><div></div><div class="h5"><br>
--<br>
Milian Wolff<br>
<a href="mailto:mail@milianw.de">mail@milianw.de</a><br>
<a href="http://milianw.de" target="_blank">http://milianw.de</a><br>
<br>
--<br>
KDevelop-devel mailing list<br>
<a href="mailto:KDevelop-devel@kdevelop.org">KDevelop-devel@kdevelop.org</a><br>
<a href="https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel" target="_blank">https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel</a><br>
</div></div></blockquote></div><br>