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
25
26////////////////////////////////////////////////////////////////////////////////
27/// Default TGlobal ctor.
28
36
37////////////////////////////////////////////////////////////////////////////////
38/// Copy constructor
39
48
49////////////////////////////////////////////////////////////////////////////////
50/// Assignment operator.
51
53{
54 if (this != &rhs) {
56 if (rhs.fInfo) {
60 } else {
61 fInfo = nullptr;
62 SetName(rhs.GetName());
63 SetTitle(rhs.GetTitle());
64 }
65 }
66 return *this;
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// TGlobal dtor deletes adopted CINT DataMemberInfo object.
71
76
77////////////////////////////////////////////////////////////////////////////////
78/// Return address of global.
79
81{
82 return (void *)gCling->DataMemberInfo_Offset(fInfo);
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Return number of array dimensions.
87
89{
90 if (!fInfo) return 0;
92}
93
94////////////////////////////////////////////////////////////////////////////////
95
97{
98 return gInterpreter->GetDeclId(fInfo);
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Return maximum index for array dimension "dim".
103
105{
106 if (!fInfo) return 0;
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Get type of global variable, e,g.: "class TDirectory*" -> "TDirectory".
112/// Result needs to be used or copied immediately.
113
114const char *TGlobal::GetTypeName() const
115{
116 if (!fInfo) return nullptr;
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Get full type description of global variable, e,g.: "class TDirectory*".
122
123const char *TGlobal::GetFullTypeName() const
124{
125 if (!fInfo) return nullptr;
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Return true if this global object is pointing to a currently
131/// loaded global. If a global is unloaded after the TGlobal
132/// is created, the TGlobal will be set to be invalid.
133
135{
136 // Register the transaction when checking the validity of the object.
138 DeclId_t newId = gInterpreter->GetDataMember(nullptr, fName);
139 if (newId) {
140 DataMemberInfo_t *info = gInterpreter->DataMemberInfo_Factory(newId, nullptr);
141 Update(info);
142 }
143 return newId != nullptr;
144 }
145 return fInfo != nullptr;
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Get property description word. For meaning of bits see EProperty.
150
152{
153 if (!fInfo) return 0;
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Update the TFunction to reflect the new info.
159///
160/// This can be used to implement unloading (info == 0) and then reloading
161/// (info being the 'new' decl address).
162
173
174
175////////////////////////////////////////////////////////////////////////////////
176/// Constructor
177
178TGlobalMappedFunction::TGlobalMappedFunction(const char *name, const char *type, GlobalFunc_t funcPtr)
179 : fFuncPtr(funcPtr)
180{
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Returns list collected globals
186/// Used to storeTGlobalMappedFunctions from other libs, before gROOT was initialized
187
189{
190 // Used to storeTGlobalMappedFunctions from other libs, before gROOT was initialized
192 // For thread-safe setting of SetOwner(kTRUE).
194 = (fEarlyRegisteredGlobals.SetOwner(kTRUE), true);
195 (void) earlyRegisteredGlobalsSetOwner; // silence unused var
196
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Add to GetEarlyRegisteredGlobals() if gROOT is not yet initialized; add to
202/// gROOT->GetListOfGlobals() otherwise.
203
205{
206 // Use "gCling" as synonym for "gROOT is initialized"
207 if (gCling) {
208 gROOT->GetListOfGlobals()->Add(gmf);
209 } else {
211 }
212}
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
R__EXTERN TInterpreter * gCling
#define gInterpreter
#define gROOT
Definition TROOT.h:411
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:204
TGlobalMappedFunction(const char *name, const char *type, GlobalFunc_t funcPtr)
Constructor.
Definition TGlobal.cxx:178
static TList & GetEarlyRegisteredGlobals()
Returns list collected globals Used to storeTGlobalMappedFunctions from other libs,...
Definition TGlobal.cxx:188
Global variables class (global variables are obtained from CINT).
Definition TGlobal.h:28
virtual DeclId_t GetDeclId() const
Definition TGlobal.cxx:96
virtual Int_t GetArrayDim() const
Return number of array dimensions.
Definition TGlobal.cxx:88
TGlobal(DataMemberInfo_t *info=nullptr)
pointer to CINT data member info
Definition TGlobal.cxx:29
virtual const char * GetTypeName() const
Get type of global variable, e,g.: "class TDirectory*" -> "TDirectory".
Definition TGlobal.cxx:114
virtual ~TGlobal()
TGlobal dtor deletes adopted CINT DataMemberInfo object.
Definition TGlobal.cxx:72
DataMemberInfo_t * fInfo
Definition TGlobal.h:31
virtual bool Update(DataMemberInfo_t *info)
Update the TFunction to reflect the new info.
Definition TGlobal.cxx:163
virtual Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Definition TGlobal.cxx:104
virtual Bool_t IsValid()
Return true if this global object is pointing to a currently loaded global.
Definition TGlobal.cxx:134
TGlobal & operator=(const TGlobal &)
Assignment operator.
Definition TGlobal.cxx:52
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
Definition TGlobal.cxx:151
virtual void * GetAddress() const
Return address of global.
Definition TGlobal.cxx:80
virtual const char * GetFullTypeName() const
Get full type description of global variable, e,g.: "class TDirectory*".
Definition TGlobal.cxx:123
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 SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition TNamed.cxx:163