Hello Sukender,

Quoting Sukender <[EMAIL PROTECTED]>:
> Has anyone *benchmarked* the difference between a dynamic_cast and a virtual
> call to identify the type of a class? Before my benchmark, I guessed the
> virtual call was cheaper, but how much? I just knew it depends a lot on how
> types are related for the dynamic_cast.

interesting results, I wouldn't have thought it'd be that different.

However when doing a dynamic_cast you probably don't want to check for exact
type (which is what the name compare is doing) but rather find out if an object
supports a certain interface i.e. is derived from a specific base class.  You
simply can't do that by checking the class name.

Also for consistency you should add (and time) a static_cast<> after your strcmp
to get a pointer to the actual data type:

    if (pointer->className() == "Target") {
      Target* t = static_cast<Target*>(pointer);
    }

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to