Re: [ROOT] Checking inheritance

From: Anton Fokin (anton.fokin@smartquant.com)
Date: Thu Nov 01 2001 - 11:24:28 MET


Yeap, that's what I do,

TClass *cl = gROOT->GetClass("TMyOtherClass");

cl->InheritsFrom("TMyClass");

this works of course. But I want to have one function call instead of two.
Well, let's say ROOT API wrapper to work with class _names_. It is a bit
more obvious for others looking into the code I produce. At least people do
not need to bother what TClass, gROOT, etc. is.

Cheers,
Anton

Rene Brun wrote:

> Hi Anton,
>
> This functionality has always been in ROOT. Do:
>  TClass *cl1 = TMyClass::Class();
>  TClass *cl2 = TMyOtherClass::Class();
>  if (cl1->InheritsFrom(cl2)...
> you can also do
>  if (cl1->InheritsFrom("TMyOtherClass");
>
> See TClass
>
> In the interpreter, you can also do:
>  TClass *cl1 = gROOT->GetClass("TMyClass");
>
> Rene Brun
>
> Anton Fokin wrote:
> >
> > Hi people,
> >
> > I would like to do something like
> >
> >   ::InheritsFrom("TMyClass", "TMyAnotherClass");
> >
> > which as you see checks if TMyClass inherits from TMyAnother class and
> > takes class names as arguments.
> >
> > Is it possible? If not, I think it would be a useful RTTI CINT
> > extension.
> >
> > Cheers,
> > Anton



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:05 MET