Re: [ROOT] using root macros to extend a program

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Apr 05 2003 - 11:15:29 MEST


Hi Caius,

There are several ways for doing what you want.
If you do not want to use the return value of functions, you can do
   gROOT->ProcessLine(".L myscript.C");
   gROOT->ProcessLine("myfunction()"); //where myfunction is in 
myscript.C

The class TMethodCall provides more functionality. You can see an 
example of use in the TPluginManager class. Look at functions
   SetupCallEnv  and ExecPlugin

In case you are not aware of the TPluginManager class, read the 
documentation:
http://root.cern.ch/root/htmldoc/TPluginManager.html

It may be that this class is already doing what you want.

Rene Brun

On Fri, 
4 Apr 2003, Caius 
Howcroft wrote:

> 
> Hi, I'm not quite clear what is possible with ROOT/CINT.
> 
> What I would like to do is have a running program that can load a script 
> that has either
> - a class definition that I can then new and call in my program.
> - functions that I can call from the program.
> 
> but I would like to get the return values of the functions I call and 
> allow the macro to call  functions in my compiled program. 
> 
> so
> 
> in the macro
> 
> int Configure(MyConfig* configmodule)
> {
> //call to compiled class 
> MyCompiledClass::Instance()->GetValue()
> return 1;
> }
> 
> MyInfo GetInfo(){
>   MyInfo tmp;
>   tmp.SetValue1(2);
>   return tmp;	
> 	
> }
> 
> in the compiled program...
> 
> int main()
> {
> MyConfig*  config=new MyConfig;
> gROOT->LoadMacro("mymacro.C")
> 
> int i = Config(config);
> MyInfo info = GetInfo();
> 
> MyCompiledClass::Instance()->DoSomething();
> 
> }
> 
> 
> 
> Is this kind of thing possible? I know you can use ProcessLine, but I dont 
> see how to pass parameters from the compiled code or get a return value.
> 
> Caius
> 
> ________________________________________
> -           CAIUS HOWCROFT             -
> -  +44 (0)1223 764 128      UK(office) -
> ========================================
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET