Logo ROOT   6.12/07
Reference Guide
TFunctionTemplate.cxx
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Philippe Canal November 2013.
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 TFunctionTemplate
13 Dictionary for function template
14 This class describes one single function template.
15 */
16 
17 #include "TFunctionTemplate.h"
18 #include "TInterpreter.h"
19 #include "TClass.h"
20 #include "TROOT.h"
21 
23 
24 ////////////////////////////////////////////////////////////////////////////////
25 /// Default TFunctionTemplate ctor.
26 
28  fInfo(info), fClass(cl)
29 {
30  if (fInfo) {
33  }
34 }
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 /// Copy operator.
38 
40 {
41  if (orig.fInfo) {
43  } else
44  fInfo = 0;
45  fClass = orig.fClass;
46 }
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// Assignment operator.
50 
52 {
53  if (this != &rhs) {
55  if (rhs.fInfo) {
59  } else
60  fInfo = 0;
61  }
62  return *this;
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// TFunctionTemplate dtor deletes adopted CINT FuncTempInfo.
67 
69 {
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Clone method.
75 
76 TObject *TFunctionTemplate::Clone(const char *newname) const
77 {
78  TNamed *newobj = new TFunctionTemplate(*this);
79  if (newname && strlen(newname)) newobj->SetName(newname);
80  return newobj;
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Return true if this function template object is pointing to a currently
85 /// loaded function. If a function is unloaded after the TFunction
86 /// is created, the TFunction will be set to be invalid.
87 
89 {
90  // Register the transaction when checking the validity of the object.
92  // Only for global functions. For data member functions TMethod does it.
93  DeclId_t newId = gInterpreter->GetFunction(0, fName);
94  if (newId) {
95  FuncTempInfo_t *info = gInterpreter->FuncTempInfo_Factory(newId);
96  Update(info);
97  }
98  return newId != 0;
99  }
100  return fInfo != 0;
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Number of function arguments.
105 
107 {
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// Number of function optional (default) arguments.
113 
115 {
116  // FIXME: when unload this is an over-estimate.
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 /// Get property description word. For meaning of bits see EProperty.
122 
124 {
125  return fInfo ? gCling->FuncTempInfo_Property(fInfo) : 0;
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 
131 {
132  return gInterpreter->GetDeclId(fInfo);
133 }
134 
135 ////////////////////////////////////////////////////////////////////////////////
136 /// Update the TFunctionTemplate to reflect the new info.
137 ///
138 /// This can be used to implement unloading (info == 0) and then reloading
139 /// (info being the 'new' decl address).
140 
141 Bool_t TFunctionTemplate::Update(FuncTempInfo_t *info)
142 {
143  if (info == 0) {
145  fInfo = 0;
146  return kTRUE;
147  } else {
149  fInfo = info;
151  return kTRUE;
152  }
153 }
154 
TString fTitle
Definition: TNamed.h:33
TFunctionTemplate & operator=(const TFunctionTemplate &rhs)
Assignment operator.
DeclId_t GetDeclId() const
TFunctionTemplate(FuncTempInfo_t *info, TClass *cl)
Default TFunctionTemplate ctor.
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const =0
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const =0
Bool_t UpdateInterpreterStateMarker()
the Cling ID of the transaction that last updated the object
Dictionary for function template This class describes one single function template.
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const =0
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual Long_t FuncTempInfo_Property(FuncTempInfo_t *) const =0
bool Bool_t
Definition: RtypesCore.h:59
#define gInterpreter
Definition: TInterpreter.h:526
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
virtual bool Update(FuncTempInfo_t *info)
Update the TFunctionTemplate to reflect the new info.
const void * DeclId_t
Definition: TDictionary.h:205
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual TObject * Clone(const char *newname="") const
Clone method.
UInt_t GetTemplateMinReqArgs() const
Number of function optional (default) arguments.
This class defines an abstract interface that must be implemented by all classes that contain diction...
Definition: TDictionary.h:158
unsigned int UInt_t
Definition: RtypesCore.h:42
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
FuncTempInfo_t * fInfo
virtual Bool_t IsValid()
Return true if this function template object is pointing to a currently loaded function.
TString fName
Definition: TNamed.h:32
UInt_t GetTemplateNargs() const
Number of function arguments.
virtual ~TFunctionTemplate()
TFunctionTemplate dtor deletes adopted CINT FuncTempInfo.
long Long_t
Definition: RtypesCore.h:50
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &title) const =0
Mother of all ROOT objects.
Definition: TObject.h:37
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const =0
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:528
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const =0