Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGlobal.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Rene Brun 13/11/95
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 TGlobal
13Global variables class (global variables are obtained from CINT).
14This class describes the attributes of a global variable.
15The TROOT class contains a list of all currently defined global
16variables (accessible via TROOT::GetListOfGlobals()).
17*/
18
19#include "TGlobal.h"
20#include "TInterpreter.h"
21#include "TList.h"
22#include "TROOT.h"
23
24
26
27////////////////////////////////////////////////////////////////////////////////
28/// Default TGlobal ctor.
29
30TGlobal::TGlobal(DataMemberInfo_t *info) : TDictionary(), fInfo(info)
31{
32 if (fInfo) {
35 }
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Copy constructor
40
41TGlobal::TGlobal(const TGlobal &rhs) : TDictionary( ), fInfo(nullptr)
42{
43 if (rhs.fInfo) {
47 }
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Assignment operator.
52
54{
55 if (this != &rhs) {
57 if (rhs.fInfo) {
61 }
62 }
63 return *this;
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// TGlobal dtor deletes adopted CINT DataMemberInfo object.
68
70{
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Return address of global.
76
78{
79 return (void *)gCling->DataMemberInfo_Offset(fInfo);
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Return number of array dimensions.
84
86{
87 if (!fInfo) return 0;
89}
90
91////////////////////////////////////////////////////////////////////////////////
92
94{
95 return gInterpreter->GetDeclId(fInfo);
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// Return maximum index for array dimension "dim".
100
102{
103 if (!fInfo) return 0;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Get type of global variable, e,g.: "class TDirectory*" -> "TDirectory".
109/// Result needs to be used or copied immediately.
110
111const char *TGlobal::GetTypeName() const
112{
113 if (!fInfo) return nullptr;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Get full type description of global variable, e,g.: "class TDirectory*".
119
120const char *TGlobal::GetFullTypeName() const
121{
122 if (!fInfo) return nullptr;
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Return true if this global object is pointing to a currently
128/// loaded global. If a global is unloaded after the TGlobal
129/// is created, the TGlobal will be set to be invalid.
130
132{
133 // Register the transaction when checking the validity of the object.
135 DeclId_t newId = gInterpreter->GetDataMember(nullptr, fName);
136 if (newId) {
137 DataMemberInfo_t *info = gInterpreter->DataMemberInfo_Factory(newId, nullptr);
138 Update(info);
139 }
140 return newId != nullptr;
141 }
142 return fInfo != nullptr;
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Get property description word. For meaning of bits see EProperty.
147
149{
150 if (!fInfo) return 0;
152}
153
154////////////////////////////////////////////////////////////////////////////////
155/// Update the TFunction to reflect the new info.
156///
157/// This can be used to implement unloading (info == 0) and then reloading
158/// (info being the 'new' decl address).
159
160Bool_t TGlobal::Update(DataMemberInfo_t *info)
161{
163 fInfo = info;
164 if (fInfo) {
167 }
168 return kTRUE;
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Constructor
174
175TGlobalMappedFunction::TGlobalMappedFunction(const char *name, const char *type, GlobalFunc_t funcPtr)
176 : fFuncPtr(funcPtr)
177{
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// Returns list collected globals
183/// Used to storeTGlobalMappedFunctions from other libs, before gROOT was initialized
184
186{
187 // Used to storeTGlobalMappedFunctions from other libs, before gROOT was initialized
188 static TList fEarlyRegisteredGlobals;
189 // For thread-safe setting of SetOwner(kTRUE).
190 static bool earlyRegisteredGlobalsSetOwner
191 = (fEarlyRegisteredGlobals.SetOwner(kTRUE), true);
192 (void) earlyRegisteredGlobalsSetOwner; // silence unused var
193
194 return fEarlyRegisteredGlobals;
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Add to GetEarlyRegisteredGlobals() if gROOT is not yet initialized; add to
199/// gROOT->GetListOfGlobals() otherwise.
200
202{
203 // Use "gCling" as synonym for "gROOT is initialized"
204 if (gCling) {
205 gROOT->GetListOfGlobals()->Add(gmf);
206 } else {
208 }
209}
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
long Long_t
Definition RtypesCore.h:54
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
R__EXTERN TInterpreter * gCling
#define gInterpreter
#define gROOT
Definition TROOT.h:404
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
This class defines an abstract interface that must be implemented by all classes that contain diction...
Bool_t UpdateInterpreterStateMarker()
the Cling ID of the transaction that last updated the object
const void * DeclId_t
static void Add(TGlobalMappedFunction *gmf)
Add to GetEarlyRegisteredGlobals() if gROOT is not yet initialized; add to gROOT->GetListOfGlobals() ...
Definition TGlobal.cxx:201
TGlobalMappedFunction(const char *name, const char *type, GlobalFunc_t funcPtr)
Constructor.
Definition TGlobal.cxx:175
static TList & GetEarlyRegisteredGlobals()
Returns list collected globals Used to storeTGlobalMappedFunctions from other libs,...
Definition TGlobal.cxx:185
Global variables class (global variables are obtained from CINT).
Definition TGlobal.h:28
virtual DeclId_t GetDeclId() const
Definition TGlobal.cxx:93
virtual Int_t GetArrayDim() const
Return number of array dimensions.
Definition TGlobal.cxx:85
TGlobal(DataMemberInfo_t *info=nullptr)
pointer to CINT data member info
Definition TGlobal.cxx:30
virtual const char * GetTypeName() const
Get type of global variable, e,g.: "class TDirectory*" -> "TDirectory".
Definition TGlobal.cxx:111
virtual ~TGlobal()
TGlobal dtor deletes adopted CINT DataMemberInfo object.
Definition TGlobal.cxx:69
DataMemberInfo_t * fInfo
Definition TGlobal.h:31
virtual bool Update(DataMemberInfo_t *info)
Update the TFunction to reflect the new info.
Definition TGlobal.cxx:160
virtual Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition TGlobal.cxx:148
virtual Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Definition TGlobal.cxx:101
virtual Bool_t IsValid()
Return true if this global object is pointing to a currently loaded global.
Definition TGlobal.cxx:131
TGlobal & operator=(const TGlobal &)
Assignment operator.
Definition TGlobal.cxx:53
virtual void * GetAddress() const
Return address of global.
Definition TGlobal.cxx:77
virtual const char * GetFullTypeName() const
Get full type description of global variable, e,g.: "class TDirectory*".
Definition TGlobal.cxx:120
virtual DataMemberInfo_t * DataMemberInfo_FactoryCopy(DataMemberInfo_t *) const
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *) const
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *) const
virtual Longptr_t DataMemberInfo_Offset(DataMemberInfo_t *) const
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *) const
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *) const
virtual void DataMemberInfo_Delete(DataMemberInfo_t *) const
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *, Int_t) const
virtual const char * DataMemberInfo_Title(DataMemberInfo_t *) const
virtual const char * TypeName(const char *s)=0
A doubly linked list.
Definition TList.h:38
virtual void Add(TObject *obj)
Definition TList.h:81
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition TNamed.cxx:154