Start TRint with custom class instances

I have a compiled program that makes use of custom classes. Just before the end of execution I run a TRint instance so I can examine the results of the program interactively. Available in the TRint session are a TTree and a TH1D that I had created in my code, but not the TCustomClass that I had instantiated. I have TCustomClass inherit from TNamed and create the instance with something like:

[code]
// Source code
TCustomClass::TCustomClass(const char* name, const char* title) : TNamed(name, title) {}

// main
TCustomClass* cc = new TCustomClass(“cc”, “My Custom Class”)[/code]

What else do I need to do to access my instance?

Hi,

In order for an ‘instance’ to be available on the CINT prompt, you need to explicit declared it there (and have the dictionary for its class loaded). For example:gROOT->ProcessLine(TString::Format("TCustomClass *cc = %p;",cc));

Cheers,
Philippe.

Thanks. I’ll give it a shot.

Being able to investigate variables/instances of by dumping the program into an interactive state has helped me greatly in my python development in the past (running ipython -i script.py, for example). Is the method you named above the most natural way to achieve this for a CINT interface given that I would like to compile my code using g++ for speed?

HI,

One thing you can do is to compile the code with ACLiC which will expose to the interpreter all the functions, class and global variables declared in the script.

Cheers,
Philippe.

Thanks Philippe. That’ll work for me.