[Insight-users] determine class name dynamically

Ivan Macia imacia at vicomtech . es
Fri, 7 Nov 2003 14:11:17 +0100


Hi Bing

You could use the method GetClassName() in itk::Object to obtain the name of
the class as a string and compare it. I ignore if there are any other
methods in ITK for run-time type information.

You can also use the C++ dynamic_cast<>() operator. With this operator you
can make a downcast from a base class to a derived class pointer. If the
conversion is not possible the dynamic_cast operator will return NULL.
Otherwise it will convert the base class pointer to the derived class
pointer. You may check this condition.

Regards

Ivan Macia


> -----Original Message-----
> From: insight-users-admin at itk . org [mailto:insight-users-admin at itk . org]On
> Behalf Of Bing Jian
> Sent: Freitag, 7. November 2003 05:53
> To: Insight-Users at itk . org
> Subject: [Insight-users] determine class name dynamically
>
>
>
> Hi,
>
> I'd like to know how to know the object's class
> dynamically in ITK. For example, I need to do
> something like
>
>   if (classname(m_Memeber) is A)
>    { ... }
>   else
>    { ... }
>
>
>   Maybe this is an issue only concerned with C++.
>
>   Thanks!
>
> --
> Best wishes,
> Bing Jian
> bjian at cise . ufl . edu
>
>
>
>
>