ProcessLine would be slower because every call to ProcessLine will parse the expression & then execute it.
Is it possible to do the onetime parsing (& compile) of such expression & then execute that byte code later multiple times?
E.g. I wrap this expression in a function like below:
const char *myFuncSrc=\
"int MyFunction(int size, int vol, int ADV,char* prod, char* ordClient)\
{\
if((size < 1000) && (vol < (0.001 * ADV)) && (prod == "Stock") && strstr("ABCD,EFGH,HIJK,NEWONE,song,JUNK,DONE",ordClient))\
return 1;\
else\
return 0;\
}"
// Parse & Compile this function
gInterpreter->ProcessLine(myFuncSrc);
while(1){
// --- data for variables come in from client application over a socket connection
char* argv[]=; // populate the input arguments....
Int result=0;
gInterpreter->Execute("MyFunction",argv,&result);
printf("result %d\n",result);
}
How do we do this kind of actions with Tinterpreter or other APIs of cint? Sorry for long list of questions.
Thanks & Regards,
Ganesh
-----Original Message-----
From: Axel Naumann [mailto:Axel.Naumann_at_cern.ch]
Sent: 05 December 2007 17:09
To: Rene Brun
Cc: Borse, Ganesh; roottalk_at_root.cern.ch; 'cint_at_root.cern.ch'
Subject: Re: [CINT] Re: [ROOT] Embedding CINT in C++ application
...or, for more of C++ including variable declaration etc, pass your C++ code as a string to ROOT's gInterpreter>ProcessLine(). gInterpreter is ROOT's global TCint object; a high level interface to CINT. See <http://root.cern.ch/root/html/TCint#TCint:ProcessLine> If you weant to do the same with CINT stand-alone then please let us know.
Cheers, Axel.
Rene Brun wrote:
> ROOT provides two classes (TFormula and TTreeFormula) for doing
> exactly what you want to do.
> see examples of use with ROOT Trees in the Users Guide
> ftp://root.cern.ch/root/doc/12Trees.pdf
> at section "Simple Analysis using Trees" at page 213 and following
>
> Rene Brun
>
> Borse, Ganesh wrote:
>>
>> Hi,
>> Is it possible to embed ROOT CINT in C++ application & use it for
>> doing dynamic expressions parsing, compilation and then multiple run
>> time evaluations those expressions?
>>
>> I can see the root/bin/cint has all its logic in root/lib/libCint.so,
>> with ldd command.
>>
>> E.g, I have the expressions as below:
>> ((size < 1000) && (vol < (0.001 * ADV)) && (prod == "Stock") &&
>> strstr("ABCD,EFGH,HIJK,NEWONE,song,JUNK,DONE",ordClient))
>>
>> The variables size, ADV, vol, etc. will be changing at runtime.
>> So, I would like to create function which will take these variables
>> as input arguments & return the result of evaluated expression.
>>
>> Since, these expressions, the number & type of these variables is not
>> at compilation time, I cannot create & compile these function at
>> compiling my application.
>>
>> Hence, I need to use some kind of interpreter which can take these
>> expressions, etc as source code & compile them.
>>
>> I tried to use Python & Perl interpreters for embedding them in C++
>> application. But they don't provide the required performance level.
>>
>> Also, the syntax of the expressions is to be same that in these
>> scripting languages. Hence, it is little tedious to use them.
>>
>> May you please guide me, if I can use cint for this?
>> What are the functions, APIs & include headers, etc. I need to use
>> for this?
>>
>> A sample program of the same thing which I am doing with Cpython API
>> (embedding Python in C) is attached here.
>>
>> Thanks and Regards,
>> Ganesh
>> <<testeval.cpp>>
>>
>> =====================================================================
>> =========
>>
>> Please access the attached hyperlink for an important electronic
>> communications disclaimer:
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>> =====================================================================
>> =========
>>
>>
>
>
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
This archive was generated by hypermail 2.2.0 : Thu Dec 06 2007 - 11:50:02 CET