#include "TROOT.h"
#include "TTree.h"
#include "THashList.h"
#include "TSelectorCint.h"
#include "TError.h"
ClassImp(TSelectorCint)
TSelectorCint::TSelectorCint() : TSelector(),
fClass(0),
fFuncVersion (0),
fFuncInit (0),
fFuncBegin (0),
fFuncSlBegin (0),
fFuncNotif (0),
fFuncSlTerm (0),
fFuncTerm (0),
fFuncCut (0),
fFuncFill (0),
fFuncProc (0),
fFuncOption (0),
fFuncObj (0),
fFuncInp (0),
fFuncOut (0),
fFuncGetAbort (0),
fFuncGetStat (0),
fIntSelector(0),fIsOwner(kFALSE)
{
}
TSelectorCint::~TSelectorCint()
{
gCint->CallFunc_Delete(fFuncVersion);
gCint->CallFunc_Delete(fFuncInit);
gCint->CallFunc_Delete(fFuncBegin);
gCint->CallFunc_Delete(fFuncSlBegin);
gCint->CallFunc_Delete(fFuncNotif);
gCint->CallFunc_Delete(fFuncSlTerm);
gCint->CallFunc_Delete(fFuncTerm);
gCint->CallFunc_Delete(fFuncCut);
gCint->CallFunc_Delete(fFuncFill);
gCint->CallFunc_Delete(fFuncProc);
gCint->CallFunc_Delete(fFuncOption);
gCint->CallFunc_Delete(fFuncObj);
gCint->CallFunc_Delete(fFuncInp);
gCint->CallFunc_Delete(fFuncOut);
gCint->CallFunc_Delete(fFuncGetAbort);
gCint->CallFunc_Delete(fFuncGetStat);
if (fIsOwner && fIntSelector) gCint->ClassInfo_Delete(fClass,fIntSelector);
gCint->ClassInfo_Delete(fClass);
}
void TSelectorCint::SetFuncProto(CallFunc_t *cf, ClassInfo_t *cl,
const char* fname, const char* argtype,
Bool_t required)
{
Long_t offset = 0;
gCint->CallFunc_SetFuncProto(cf, cl,fname,argtype,&offset);
if (gDebug > 2)
Info("SetFuncProto","set %s(%s) offset = %ld",fname,argtype,offset);
if (!gCint->CallFunc_IsValid(cf) && required)
Error("SetFuncProto","cannot set %s(%s)",fname,argtype);
}
void TSelectorCint::Build(TSelector *iselector, ClassInfo_t *cl, Bool_t isowner)
{
gCint->CallFunc_Delete(fFuncVersion);
gCint->CallFunc_Delete(fFuncInit);
gCint->CallFunc_Delete(fFuncBegin);
gCint->CallFunc_Delete(fFuncSlBegin);
gCint->CallFunc_Delete(fFuncNotif);
gCint->CallFunc_Delete(fFuncSlTerm);
gCint->CallFunc_Delete(fFuncTerm);
gCint->CallFunc_Delete(fFuncCut);
gCint->CallFunc_Delete(fFuncFill);
gCint->CallFunc_Delete(fFuncProc);
gCint->CallFunc_Delete(fFuncOption);
gCint->CallFunc_Delete(fFuncObj);
gCint->CallFunc_Delete(fFuncInp);
gCint->CallFunc_Delete(fFuncOut);
gCint->CallFunc_Delete(fFuncGetAbort);
gCint->CallFunc_Delete(fFuncGetStat);
if (fIsOwner && fIntSelector) gCint->ClassInfo_Delete(fClass, fIntSelector);
gCint->ClassInfo_Delete(fClass);
R__ASSERT(cl);
fClass = gCint->ClassInfo_Factory(cl);
fIntSelector = iselector;
fIsOwner = isowner;
fFuncVersion = gCint->CallFunc_Factory();
fFuncInit = gCint->CallFunc_Factory();
fFuncBegin = gCint->CallFunc_Factory();
fFuncSlBegin = gCint->CallFunc_Factory();
fFuncNotif = gCint->CallFunc_Factory();
fFuncSlTerm = gCint->CallFunc_Factory();
fFuncTerm = gCint->CallFunc_Factory();
fFuncCut = gCint->CallFunc_Factory();
fFuncFill = gCint->CallFunc_Factory();
fFuncProc = gCint->CallFunc_Factory();
fFuncOption = gCint->CallFunc_Factory();
fFuncObj = gCint->CallFunc_Factory();
fFuncInp = gCint->CallFunc_Factory();
fFuncOut = gCint->CallFunc_Factory();
fFuncGetAbort = gCint->CallFunc_Factory();
fFuncGetStat = gCint->CallFunc_Factory();
SetFuncProto(fFuncVersion,fClass,"Version","",kFALSE);
SetFuncProto(fFuncInit,fClass,"Init","TTree*");
SetFuncProto(fFuncBegin,fClass,"Begin","TTree*");
SetFuncProto(fFuncSlBegin,fClass,"SlaveBegin","TTree*",kFALSE);
SetFuncProto(fFuncNotif,fClass,"Notify","");
SetFuncProto(fFuncSlTerm,fClass,"SlaveTerminate","",kFALSE);
SetFuncProto(fFuncTerm,fClass,"Terminate","");
SetFuncProto(fFuncCut,fClass,"ProcessCut","Long64_t",kFALSE);
SetFuncProto(fFuncFill,fClass,"ProcessFill","Long64_t",kFALSE);
SetFuncProto(fFuncProc,fClass,"Process","Long64_t",kFALSE);
SetFuncProto(fFuncOption,fClass,"SetOption","const char*");
SetFuncProto(fFuncObj,fClass,"SetObject","TObject*");
SetFuncProto(fFuncInp,fClass,"SetInputList","TList*");
SetFuncProto(fFuncOut,fClass,"GetOutputList","");
SetFuncProto(fFuncGetAbort,fClass,"GetAbort","",kFALSE);
SetFuncProto(fFuncGetStat,fClass,"GetStatus","");
}
int TSelectorCint::Version() const
{
if (gDebug > 2)
Info("Version","Call Version");
if (gCint->CallFunc_IsValid(fFuncVersion)) {
gCint->CallFunc_ResetArg(fFuncVersion);
return gCint->CallFunc_ExecInt(fFuncVersion, fIntSelector);
} else {
return 0;
}
}
void TSelectorCint::Init(TTree *tree)
{
if (gDebug > 2)
Info("Init","Call Init tree = %p", tree);
gCint->CallFunc_ResetArg(fFuncInit);
gCint->CallFunc_SetArg(fFuncInit, (Long_t)tree);
gCint->CallFunc_Exec(fFuncInit, fIntSelector);
}
void TSelectorCint::Begin(TTree *tree)
{
if (gDebug > 2)
Info("Begin","Call Begin tree = %p", tree);
gCint->CallFunc_ResetArg(fFuncBegin);
gCint->CallFunc_SetArg(fFuncBegin, (Long_t)tree);
gCint->CallFunc_ExecInt(fFuncBegin, fIntSelector);
}
void TSelectorCint::SlaveBegin(TTree *tree)
{
if (gDebug > 2)
Info("SlaveBegin","Call SlaveBegin tree = %p", tree);
if (gCint->CallFunc_IsValid(fFuncSlBegin)) {
gCint->CallFunc_ResetArg(fFuncSlBegin);
gCint->CallFunc_SetArg(fFuncSlBegin, (Long_t)tree);
gCint->CallFunc_ExecInt(fFuncSlBegin, fIntSelector);
} else {
if (gDebug > 1)
Info("SlaveBegin","SlaveBegin unavailable");
}
}
Bool_t TSelectorCint::Notify()
{
if (gDebug > 2)
Info("Notify","Call Notify");
Long64_t sel = gCint->CallFunc_ExecInt(fFuncNotif, fIntSelector);
return (Bool_t)sel;
}
Bool_t TSelectorCint::ProcessCut(Long64_t entry)
{
if (gDebug > 3)
Info("ProcessCut","Call ProcessCut entry = %d", entry);
if(gCint->CallFunc_IsValid(fFuncCut)) {
gCint->CallFunc_ResetArg(fFuncCut);
gCint->CallFunc_SetArg(fFuncCut, (Long_t)entry);
Int_t sel = gCint->CallFunc_ExecInt(fFuncCut, fIntSelector);
return (Bool_t)sel;
} else {
Error("ProcessCut","ProcessCut unavailable");
return kFALSE;
}
}
void TSelectorCint::ProcessFill(Long64_t entry)
{
if (gDebug > 3)
Info("ProcessFill","Call ProcessFill entry = %d", entry);
if(gCint->CallFunc_IsValid(fFuncFill)) {
gCint->CallFunc_ResetArg(fFuncFill);
gCint->CallFunc_SetArg(fFuncFill, (Long_t)entry);
gCint->CallFunc_Exec(fFuncFill, fIntSelector);
} else {
Error("ProcessFill","ProcessFill unavailable");
}
}
Bool_t TSelectorCint::Process(Long64_t entry)
{
if (gDebug > 3)
Info("Process","Call Process entry = %d", entry);
if(gCint->CallFunc_IsValid(fFuncProc)) {
gCint->CallFunc_ResetArg(fFuncProc);
gCint->CallFunc_SetArg(fFuncProc, (Long_t)entry);
Int_t sel = gCint->CallFunc_ExecInt(fFuncProc, fIntSelector);
return (Bool_t)sel;
} else {
Error("Process","Process unavailable");
return kFALSE;
}
}
void TSelectorCint::SetOption(const char *option)
{
if (gDebug > 2)
Info("SetOption","Option = %s", option);
gCint->CallFunc_ResetArg(fFuncOption);
gCint->CallFunc_SetArg(fFuncOption, (Long_t)option);
gCint->CallFunc_Exec(fFuncOption, fIntSelector);
}
void TSelectorCint::SetObject(TObject *obj)
{
if (gDebug > 3)
Info("SetObject","Object = %p", obj);
gCint->CallFunc_ResetArg(fFuncObj);
gCint->CallFunc_SetArg(fFuncObj, (Long_t)obj);
gCint->CallFunc_Exec(fFuncObj, fIntSelector);
}
void TSelectorCint::SetInputList(TList *input)
{
if (gDebug > 2)
Info("SetInputList","Object = %p", input);
gCint->CallFunc_ResetArg(fFuncInp);
gCint->CallFunc_SetArg(fFuncInp,(Long_t)input);
gCint->CallFunc_Exec(fFuncInp,fIntSelector);
}
TList *TSelectorCint::GetOutputList() const
{
TList *out = (TList *) gCint->CallFunc_ExecInt(fFuncOut, fIntSelector);
if (gDebug > 2)
Info("GetOutputList","List = %p", out);
return out;
}
void TSelectorCint::SlaveTerminate()
{
if (gDebug > 2)
Info("SlaveTerminate","Call SlaveTerminate");
if(gCint->CallFunc_IsValid(fFuncSlTerm)) {
gCint->CallFunc_Exec(fFuncSlTerm, fIntSelector);
} else {
if (gDebug > 1)
Info("SlaveTerminate","SlaveTerminate unavailable");
}
}
void TSelectorCint::Terminate()
{
if (gDebug > 2)
Info("Terminate","Call Terminate");
gCint->CallFunc_Exec(fFuncTerm,fIntSelector);
}
TSelector::EAbort TSelectorCint::GetAbort() const
{
if (gDebug > 2)
Info("GetAbort","Call GetAbort");
if (gCint->CallFunc_IsValid(fFuncGetAbort)) {
gCint->CallFunc_ResetArg(fFuncGetAbort);
return (EAbort)gCint->CallFunc_ExecInt(fFuncGetAbort, fIntSelector);
} else {
return kContinue;
}
}
Long64_t TSelectorCint::GetStatus() const
{
if (gDebug > 2)
Info("GetStatus","Call GetStatus");
if (gCint->CallFunc_IsValid(fFuncGetStat)) {
gCint->CallFunc_ResetArg(fFuncGetStat);
return gCint->CallFunc_ExecInt64(fFuncGetStat, fIntSelector);
} else {
return 0;
}
}