Logo ROOT  
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 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// Default TFunctionTemplate ctor.
25 
27  fInfo(info), fClass(cl)
28 {
29  if (fInfo) {
32  }
33 }
34 
35 ////////////////////////////////////////////////////////////////////////////////
36 /// Copy operator.
37 
39 {
40  if (orig.fInfo) {
42  } else
43  fInfo = 0;
44  fClass = orig.fClass;
45 }
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Assignment operator.
49 
51 {
52  if (this != &rhs) {
54  if (rhs.fInfo) {
58  } else
59  fInfo = 0;
60  }
61  return *this;
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// TFunctionTemplate dtor deletes adopted CINT FuncTempInfo.
66 
68 {
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Clone method.
74 
75 TObject *TFunctionTemplate::Clone(const char *newname) const
76 {
77  TNamed *newobj = new TFunctionTemplate(*this);
78  if (newname && strlen(newname)) newobj->SetName(newname);
79  return newobj;
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Return true if this function template object is pointing to a currently
84 /// loaded function. If a function is unloaded after the TFunction
85 /// is created, the TFunction will be set to be invalid.
86 
88 {
89  // Register the transaction when checking the validity of the object.
91  // Only for global functions. For data member functions TMethod does it.
92  DeclId_t newId = gInterpreter->GetFunction(0, fName);
93  if (newId) {
94  FuncTempInfo_t *info = gInterpreter->FuncTempInfo_Factory(newId);
95  Update(info);
96  }
97  return newId != 0;
98  }
99  return fInfo != 0;
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Number of function arguments.
104 
106 {
108 }
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// Number of function optional (default) arguments.
112 
114 {
115  // FIXME: when unload this is an over-estimate.
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Get property description word. For meaning of bits see EProperty.
121 
123 {
124  return fInfo ? gCling->FuncTempInfo_Property(fInfo) : 0;
125 }
126 
127 ////////////////////////////////////////////////////////////////////////////////
128 /// Get the properties not already defined in Property.See TDictionary's EFunctionProperty.
129 
131 {
133 }
134 
135 ////////////////////////////////////////////////////////////////////////////////
136 
138 {
139  return gInterpreter->GetDeclId(fInfo);
140 }
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 /// Update the TFunctionTemplate to reflect the new info.
144 ///
145 /// This can be used to implement unloading (info == 0) and then reloading
146 /// (info being the 'new' decl address).
147 
148 Bool_t TFunctionTemplate::Update(FuncTempInfo_t *info)
149 {
150  if (info == 0) {
152  fInfo = 0;
153  return kTRUE;
154  } else {
156  fInfo = info;
158  return kTRUE;
159  }
160 }
161 
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TNamed::SetName
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
TFunctionTemplate::Update
virtual bool Update(FuncTempInfo_t *info)
Update the TFunctionTemplate to reflect the new info.
Definition: TFunctionTemplate.cxx:148
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
gInterpreter
#define gInterpreter
Definition: TInterpreter.h:558
TFunctionTemplate::GetDeclId
DeclId_t GetDeclId() const
Definition: TFunctionTemplate.cxx:137
TNamed::fName
TString fName
Definition: TNamed.h:38
TClass.h
TFunctionTemplate::Property
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TFunctionTemplate.cxx:122
TInterpreter::FuncTempInfo_Name
virtual void FuncTempInfo_Name(FuncTempInfo_t *, TString &name) const =0
TDictionary::DeclId_t
const typedef void * DeclId_t
Definition: TDictionary.h:209
bool
TFunctionTemplate::fClass
TClass * fClass
Definition: TFunctionTemplate.h:35
TNamed::fTitle
TString fTitle
Definition: TNamed.h:39
TFunctionTemplate::Clone
virtual TObject * Clone(const char *newname="") const
Clone method.
Definition: TFunctionTemplate.cxx:75
TFunctionTemplate::GetTemplateMinReqArgs
UInt_t GetTemplateMinReqArgs() const
Number of function optional (default) arguments.
Definition: TFunctionTemplate.cxx:113
TFunctionTemplate::IsValid
virtual Bool_t IsValid()
Return true if this function template object is pointing to a currently loaded function.
Definition: TFunctionTemplate.cxx:87
TInterpreter::FuncTempInfo_Delete
virtual void FuncTempInfo_Delete(FuncTempInfo_t *) const =0
TInterpreter::FuncTempInfo_FactoryCopy
virtual FuncTempInfo_t * FuncTempInfo_FactoryCopy(FuncTempInfo_t *) const =0
TNamed
Definition: TNamed.h:29
Long_t
long Long_t
Definition: RtypesCore.h:54
TFunctionTemplate::GetTemplateNargs
UInt_t GetTemplateNargs() const
Number of function arguments.
Definition: TFunctionTemplate.cxx:105
TInterpreter::FuncTempInfo_ExtraProperty
virtual Long_t FuncTempInfo_ExtraProperty(FuncTempInfo_t *) const =0
TFunctionTemplate::~TFunctionTemplate
virtual ~TFunctionTemplate()
TFunctionTemplate dtor deletes adopted CINT FuncTempInfo.
Definition: TFunctionTemplate.cxx:67
fClass
Cppyy::TCppType_t fClass
Definition: DeclareConverters.h:259
TDictionary
Definition: TDictionary.h:162
unsigned int
TInterpreter::FuncTempInfo_Property
virtual Long_t FuncTempInfo_Property(FuncTempInfo_t *) const =0
TFunctionTemplate::ExtraProperty
Long_t ExtraProperty() const
Get the properties not already defined in Property.See TDictionary's EFunctionProperty.
Definition: TFunctionTemplate.cxx:130
TInterpreter.h
TClass
Definition: TClass.h:80
TObject
Definition: TObject.h:37
gCling
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:559
TFunctionTemplate::fInfo
FuncTempInfo_t * fInfo
Definition: TFunctionTemplate.h:34
TDictionary::UpdateInterpreterStateMarker
Bool_t UpdateInterpreterStateMarker()
the Cling ID of the transaction that last updated the object
Definition: TDictionary.cxx:109
TFunctionTemplate::operator=
TFunctionTemplate & operator=(const TFunctionTemplate &rhs)
Assignment operator.
Definition: TFunctionTemplate.cxx:50
TFunctionTemplate::TFunctionTemplate
TFunctionTemplate(FuncTempInfo_t *info, TClass *cl)
Default TFunctionTemplate ctor.
Definition: TFunctionTemplate.cxx:26
TFunctionTemplate.h
TInterpreter::FuncTempInfo_TemplateMinReqArgs
virtual UInt_t FuncTempInfo_TemplateMinReqArgs(FuncTempInfo_t *) const =0
TInterpreter::FuncTempInfo_Title
virtual void FuncTempInfo_Title(FuncTempInfo_t *, TString &title) const =0
TFunctionTemplate
Definition: TFunctionTemplate.h:26
TInterpreter::FuncTempInfo_TemplateNargs
virtual UInt_t FuncTempInfo_TemplateNargs(FuncTempInfo_t *) const =0