Logo ROOT   6.10/09
Reference Guide
TSelectorCint.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 05/02/97
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TSelectorCint
13 \ingroup tree
14 
15 This class is a special version of TSelector for user interpreted classes.
16 */
17 
18 #include "TROOT.h"
19 #include "TTree.h"
20 #include "THashList.h"
21 #define ROOT_TSelectorCint_SRC_FILE
22 #include "TSelectorCint.h"
23 #undef ROOT_TSelectorCint_SRC_FILE
24 #include "TError.h"
25 
27 
28 ////////////////////////////////////////////////////////////////////////////////
29 
31  fClass(0),
32  fFuncVersion (0),
33  fFuncInit (0),
34  fFuncBegin (0),
35  fFuncSlBegin (0),
36  fFuncNotif (0),
37  fFuncSlTerm (0),
38  fFuncTerm (0),
39  fFuncCut (0),
40  fFuncFill (0),
41  fFuncProc (0),
42  fFuncOption (0),
43  fFuncObj (0),
44  fFuncInp (0),
45  fFuncOut (0),
46  fFuncAbort (0),
47  fFuncGetAbort (0),
48  fFuncResetAbort (0),
49  fFuncGetStat (0),
50  fIntSelector(0),fIsOwner(kFALSE)
51 
52 {
53  // Default constructor for a Selector.
54 
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Destructor for a Selector.
59 
61 {
80 
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 /// Set the function prototype.
87 
88 void TSelectorCint::SetFuncProto(CallFunc_t *cf, ClassInfo_t *cl,
89  const char* fname, const char* argtype,
90  Bool_t required)
91 {
92  Long_t offset = 0;
93 
94  gCling->CallFunc_SetFuncProto(cf, cl,fname,argtype,&offset);
95 
96  if (gDebug > 2)
97  Info("SetFuncProto","set %s(%s) offset = %ld",fname,argtype,offset);
98 
99  if (!gCling->CallFunc_IsValid(cf) && required)
100  Error("SetFuncProto","cannot set %s(%s)",fname,argtype);
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Initialize the CallFunc objects when selector is interpreted.
105 
106 void TSelectorCint::Build(TSelector *iselector, ClassInfo_t *cl, Bool_t isowner)
107 {
126 
129 
130  R__ASSERT(cl);
131 
132  // The CINT MethodInfo created by SetFuncProto will remember the address
133  // of cl, so we need to keep it around.
135 
136  fIntSelector = iselector;
137  fIsOwner = isowner;
156 
157  SetFuncProto(fFuncVersion,fClass,"Version","",kFALSE);
158  SetFuncProto(fFuncInit,fClass,"Init","TTree*");
159  SetFuncProto(fFuncBegin,fClass,"Begin","TTree*");
160  SetFuncProto(fFuncSlBegin,fClass,"SlaveBegin","TTree*",kFALSE);
161  SetFuncProto(fFuncNotif,fClass,"Notify","");
162  SetFuncProto(fFuncSlTerm,fClass,"SlaveTerminate","",kFALSE);
163  SetFuncProto(fFuncTerm,fClass,"Terminate","");
164  SetFuncProto(fFuncCut,fClass,"ProcessCut","Long64_t",kFALSE);
165  SetFuncProto(fFuncFill,fClass,"ProcessFill","Long64_t",kFALSE);
166  SetFuncProto(fFuncProc,fClass,"Process","Long64_t",kFALSE);
167  SetFuncProto(fFuncOption,fClass,"SetOption","const char*");
168  SetFuncProto(fFuncObj,fClass,"SetObject","TObject*");
169  SetFuncProto(fFuncInp,fClass,"SetInputList","TList*");
170  SetFuncProto(fFuncOut,fClass,"GetOutputList","");
171  SetFuncProto(fFuncAbort,fClass,"Abort","const char *,TSelector::EAbort",kFALSE);
172  SetFuncProto(fFuncGetAbort,fClass,"GetAbort","",kFALSE);
173  SetFuncProto(fFuncResetAbort,fClass,"ResetAbort","",kFALSE);
174  SetFuncProto(fFuncGetStat,fClass,"GetStatus","");
175 }
176 
177 ////////////////////////////////////////////////////////////////////////////////
178 /// Invoke the Version function via the interpreter.
179 
181 {
182  if (gDebug > 2)
183  Info("Version","Call Version");
184 
188  } else {
189  return 0; // emulate for old version
190  }
191 }
192 
193 ////////////////////////////////////////////////////////////////////////////////
194 /// Invoke the Init function via the interpreter.
195 
197 {
198  if (gDebug > 2)
199  Info("Init","Call Init tree = %p", tree);
200 
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Invoke the Begin function via the interpreter.
208 
210 {
211  if (gDebug > 2)
212  Info("Begin","Call Begin tree = %p", tree);
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 /// Invoke the SlaveBegin function via the interpreter if available.
220 
222 {
223  if (gDebug > 2)
224  Info("SlaveBegin","Call SlaveBegin tree = %p", tree);
225 
230  } else {
231  if (gDebug > 1)
232  Info("SlaveBegin","SlaveBegin unavailable");
233  }
234 }
235 
236 ////////////////////////////////////////////////////////////////////////////////
237 /// Invoke the Notify function via the interpreter.
238 
240 {
241  if (gDebug > 2)
242  Info("Notify","Call Notify");
244  return (Bool_t)sel;
245 }
246 
247 ////////////////////////////////////////////////////////////////////////////////
248 /// Invoke the ProcessCut function via the interpreter.
249 
251 {
252  if (gDebug > 3)
253  Info("ProcessCut","Call ProcessCut entry = %lld", entry);
254 
259  return (Bool_t)sel;
260  } else {
261  Error("ProcessCut","ProcessCut unavailable");
262  return kFALSE;
263  }
264 }
265 
266 ////////////////////////////////////////////////////////////////////////////////
267 /// Invoke the ProcessFill function via the interpreter.
268 
270 {
271  if (gDebug > 3)
272  Info("ProcessFill","Call ProcessFill entry = %lld", entry);
273 
278  } else {
279  Error("ProcessFill","ProcessFill unavailable");
280  }
281 }
282 
283 ////////////////////////////////////////////////////////////////////////////////
284 /// Invoke the ProcessCut function via the interpreter.
285 
287 {
288  if (gDebug > 3)
289  Info("Process","Call Process entry = %lld", entry);
290 
295  return (Bool_t)sel;
296  } else {
297  Error("Process","Process unavailable");
298  return kFALSE;
299  }
300 }
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 /// Set the selector option.
304 
305 void TSelectorCint::SetOption(const char *option)
306 {
307  if (gDebug > 2)
308  Info("SetOption","Option = %s", option);
312 }
313 
314 ////////////////////////////////////////////////////////////////////////////////
315 /// Set the current object.
316 
318 {
319  if (gDebug > 3)
320  Info("SetObject","Object = %p", obj);
324 }
325 
326 ////////////////////////////////////////////////////////////////////////////////
327 /// Set the selector list of input objects.
328 
330 {
331  if (gDebug > 2)
332  Info("SetInputList","Object = %p", input);
336 }
337 
338 ////////////////////////////////////////////////////////////////////////////////
339 /// Return the list of output object.
340 
342 {
344 
345  if (gDebug > 2)
346  Info("GetOutputList","List = %p", out);
347 
348  return out;
349 }
350 
351 ////////////////////////////////////////////////////////////////////////////////
352 /// Invoke the SlaveTerminate function via the interpreter if available.
353 
355 {
356  if (gDebug > 2)
357  Info("SlaveTerminate","Call SlaveTerminate");
358 
361  } else {
362  if (gDebug > 1)
363  Info("SlaveTerminate","SlaveTerminate unavailable");
364  }
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Invoke the Terminate function via the interpreter.
369 
371 {
372  if (gDebug > 2)
373  Info("Terminate","Call Terminate");
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// Invoke the GetAbort function via the interpreter.
379 
380 void TSelectorCint::Abort(const char *mesg, EAbort what)
381 {
382  if (gDebug > 2)
383  Info("Abort","Call Abort");
384 
390  }
391 }
392 
393 ////////////////////////////////////////////////////////////////////////////////
394 /// Invoke the GetAbort function via the interpreter.
395 
397 {
398  if (gDebug > 2)
399  Info("GetAbort","Call GetAbort");
400 
404  } else {
405  return kContinue; // emulate for old version
406  }
407 }
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 /// Invoke the GetAbort function via the interpreter.
411 
413 {
414  if (gDebug > 2)
415  Info("ResetAbort","Call ResetAbort");
416 
420  }
421 }
422 
423 ////////////////////////////////////////////////////////////////////////////////
424 /// Invoke the GetStatus function via the interpreter.
425 
427 {
428  if (gDebug > 2)
429  Info("GetStatus","Call GetStatus");
430 
434  } else {
435  return 0; // emulate for old version
436  }
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Retrieve the TClass object for the interpreted class.
441 
443 {
444  if (!fClass) return 0;
446 }
CallFunc_t * fFuncBegin
Definition: TSelectorCint.h:41
virtual void CallFunc_SetFuncProto(CallFunc_t *, ClassInfo_t *, const char *, const char *, Long_t *, ROOT::EFunctionMatchMode=ROOT::kConversionMatch) const
Definition: TInterpreter.h:335
CallFunc_t * fFuncOption
Definition: TSelectorCint.h:49
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:847
CallFunc_t * fFuncVersion
Definition: TSelectorCint.h:39
long long Long64_t
Definition: RtypesCore.h:69
virtual int Version() const
Invoke the Version function via the interpreter.
virtual TClass * GetInterpretedClass() const
Retrieve the TClass object for the interpreted class.
virtual CallFunc_t * CallFunc_Factory() const
Definition: TInterpreter.h:266
virtual void ProcessFill(Long64_t entry)
Invoke the ProcessFill function via the interpreter.
CallFunc_t * fFuncFill
Definition: TSelectorCint.h:47
#define R__ASSERT(e)
Definition: TError.h:96
virtual Long_t CallFunc_ExecInt(CallFunc_t *, void *) const
Definition: TInterpreter.h:263
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TSelector * fIntSelector
Pointer to interpreted selector (if interpreted)
Definition: TSelectorCint.h:57
virtual void Terminate()
Invoke the Terminate function via the interpreter.
virtual void SetObject(TObject *obj)
Set the current object.
CallFunc_t * fFuncNotif
Definition: TSelectorCint.h:43
ClassInfo_t * fClass
Definition: TSelectorCint.h:38
virtual void SetInputList(TList *input)
Set the selector list of input objects.
virtual EAbort GetAbort() const
Invoke the GetAbort function via the interpreter.
virtual void CallFunc_SetArg(CallFunc_t *, Long_t) const =0
CallFunc_t * fFuncSlTerm
Definition: TSelectorCint.h:44
virtual void Abort(const char *why, EAbort what=kAbortProcess)
Invoke the GetAbort function via the interpreter.
virtual ClassInfo_t * ClassInfo_Factory(Bool_t=kTRUE) const =0
CallFunc_t * fFuncTerm
Definition: TSelectorCint.h:45
CallFunc_t * fFuncCut
Definition: TSelectorCint.h:46
CallFunc_t * fFuncInp
Definition: TSelectorCint.h:51
virtual void SetOption(const char *option)
Set the selector option.
virtual void Init(TTree *)
Invoke the Init function via the interpreter.
virtual Bool_t Process(Long64_t entry)
Invoke the ProcessCut function via the interpreter.
A doubly linked list.
Definition: TList.h:43
virtual void ResetAbort()
Invoke the GetAbort function via the interpreter.
virtual Long64_t CallFunc_ExecInt64(CallFunc_t *, void *) const
Definition: TInterpreter.h:264
CallFunc_t * fFuncSlBegin
Definition: TSelectorCint.h:42
CallFunc_t * fFuncResetAbort
Definition: TSelectorCint.h:55
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
void SetFuncProto(CallFunc_t *cf, ClassInfo_t *cl, const char *fname, const char *argtype, Bool_t required=kTRUE)
Set the function prototype.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
const Bool_t kFALSE
Definition: RtypesCore.h:92
long Long_t
Definition: RtypesCore.h:50
virtual void Build(TSelector *iselector, ClassInfo_t *cl, Bool_t isowner=kTRUE)
Initialize the CallFunc objects when selector is interpreted.
#define ClassImp(name)
Definition: Rtypes.h:336
CallFunc_t * fFuncGetStat
Definition: TSelectorCint.h:56
CallFunc_t * fFuncInit
Definition: TSelectorCint.h:40
virtual void CallFunc_Delete(CallFunc_t *) const
Definition: TInterpreter.h:258
virtual TList * GetOutputList() const
Return the list of output object.
virtual Long64_t GetStatus() const
Invoke the GetStatus function via the interpreter.
CallFunc_t * fFuncAbort
Definition: TSelectorCint.h:53
CallFunc_t * fFuncObj
Definition: TSelectorCint.h:50
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2885
virtual Bool_t Notify()
Invoke the Notify function via the interpreter.
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SlaveTerminate()
Invoke the SlaveTerminate function via the interpreter if available.
CallFunc_t * fFuncOut
Definition: TSelectorCint.h:52
virtual void ClassInfo_Delete(ClassInfo_t *) const
Definition: TInterpreter.h:344
virtual const char * ClassInfo_FullName(ClassInfo_t *) const
Definition: TInterpreter.h:373
virtual void SlaveBegin(TTree *)
Invoke the SlaveBegin function via the interpreter if available.
virtual Bool_t ProcessCut(Long64_t entry)
Invoke the ProcessCut function via the interpreter.
virtual void Begin(TTree *tree)
Invoke the Begin function via the interpreter.
R__EXTERN Int_t gDebug
Definition: Rtypes.h:83
CallFunc_t * fFuncGetAbort
Definition: TSelectorCint.h:54
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:78
This class is a special version of TSelector for user interpreted classes.
Definition: TSelectorCint.h:31
virtual Bool_t CallFunc_IsValid(CallFunc_t *) const
Definition: TInterpreter.h:271
virtual void CallFunc_Exec(CallFunc_t *, void *) const
Definition: TInterpreter.h:259
Bool_t fIsOwner
True if fIntSelector should be deleted when the this object is deleted.
Definition: TSelectorCint.h:58
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:501
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:33
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void CallFunc_ResetArg(CallFunc_t *) const
Definition: TInterpreter.h:273
CallFunc_t * fFuncProc
Definition: TSelectorCint.h:48
virtual ~TSelectorCint()
Destructor for a Selector.