[Marble-devel] Review Request: provide nodeType information for downcasting

Jens-Michael Hoffmann jensmh at gmx.de
Sat Jul 25 20:41:17 CEST 2009


Am Saturday 25 July 2009 14:52:07 schrieb tgridel at free.fr:
> 
> > On 2009-07-25 12:20:58, jmho_ wrote:
> > > I think this is conceptually wrong for the following reasons:
> > > 
> > > 1) casting in C++ is like goto in C, we should not use it.
> > > 2) if we want to cast in a safe way, we should use the compilers RTTI, or maybe Qt's,
> > >   but not build our own RTTI
> 
> Please let me explain the reason beforehand:
> 
> The solution has been discussed yesterday with Torsten, Saro and Andrew on IRC 
> to cover the specific need to write back the GeoData to a file, using a pattern
> similar to the GeoParser.
> In that respect, parsing the stack of GeoNodes is not funny.

Yes, I know.
I'm not proposing an alternative solution, I just wanted to point out that I think this is conceptually the wrong approach.

> Moreover, there already are some isSomething() boolean to cover more specific
> identification needs which i fear would not scale much.

my comment would apply to those as well.

> Last, Qt Provides the same solution to identify QGraphicsItem with type() and a
> cast template.

and in principle also to those.


> 
> The patch i propose is a solution to this problem, if you have a better idea
> I would be very happy to see it.

no, unfortunately I don't have a better idea.

> 
> With regards compiler RTTI this is not a given everywhere (Qt can compile
> without this support)


Best Regards

Jens-Michael


More information about the Marble-devel mailing list