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 } else {
62 fInfo = nullptr;
63 SetName(rhs.GetName());
64 SetTitle(rhs.GetTitle());
65 }
66 }
67 return *this;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// TGlobal dtor deletes adopted CINT DataMemberInfo object.
72
74{
76}
77
78////////////////////////////////////////////////////////////////////////////////
79/// Return address of global.
80
82{
83 return (void *)gCling->DataMemberInfo_Offset(fInfo);
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Return number of array dimensions.
88
90{
91 if (!fInfo) return 0;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96
98{
99 return gInterpreter->GetDeclId(fInfo);
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Return maximum index for array dimension "dim".
104
106{
107 if (!fInfo) return 0;
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Get type of global variable, e,g.: "class TDirectory*" -> "TDirectory".
113/// Result needs to be used or copied immediately.
114
115const char *TGlobal::GetTypeName() const
116{
117 if (!fInfo) return nullptr;
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Get full type description of global variable, e,g.: "class TDirectory*".
123
124const char *TGlobal::GetFullTypeName() const
125{
126 if (!fInfo) return nullptr;
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// Return true if this global object is pointing to a currently
132/// loaded global. If a global is unloaded after the TGlobal
133/// is created, the TGlobal will be set to be invalid.
134
136{
137 // Register the transaction when checking the validity of the object.
139 DeclId_t newId = gInterpreter->GetDataMember(nullptr, fName);
140 if (newId) {
141 DataMemberInfo_t *info = gInterpreter->DataMemberInfo_Factory(newId, nullptr);
142 Update(info);
143 }
144 return newId != nullptr;
145 }
146 return fInfo != nullptr;
147}
148
149////////////////////////////////////////////////////////////////////////////////
150/// Get property description word. For meaning of bits see EProperty.
151
153{
154 if (!fInfo) return 0;
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Update the TFunction to reflect the new info.
160///
161/// This can be used to implement unloading (info == 0) and then reloading
162/// (info being the 'new' decl address).
163
164Bool_t TGlobal::Update(DataMemberInfo_t *info)
165{
167 fInfo = info;
168 if (fInfo) {
171 }
172 return kTRUE;
173}
174
175
176////////////////////////////////////////////////////////////////////////////////
177/// Constructor
178
179TGlobalMappedFunction::TGlobalMappedFunction(const char *name, const char *type, GlobalFunc_t funcPtr)
180 : fFuncPtr(funcPtr)
181{
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Returns list collected globals
187/// Used to storeTGlobalMappedFunctions from other libs, before gROOT was initialized
188
190{
191 // Used to storeTGlobalMappedFunctions from other libs, before gROOT was initialized
192 static TList fEarlyRegisteredGlobals;
193 // For thread-safe setting of SetOwner(kTRUE).
194 static bool earlyRegisteredGlobalsSetOwner
195 = (fEarlyRegisteredGlobals.SetOwner(kTRUE), true);
196 (void) earlyRegisteredGlobalsSetOwner; // silence unused var
197
198 return fEarlyRegisteredGlobals;
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Add to GetEarlyRegisteredGlobals() if gROOT is not yet initialized; add to
203/// gROOT->GetListOfGlobals() otherwise.
204
206{
207 // Use "gCling" as synonym for "gROOT is initialized"
208 if (gCling) {
209 gROOT->GetListOfGlobals()->Add(gmf);
210 } else {
212 }
213}
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
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:406
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:205
TGlobalMappedFunction(const char *name, const char *type, GlobalFunc_t funcPtr)
Constructor.
Definition TGlobal.cxx:179
static TList & GetEarlyRegisteredGlobals()
Returns list collected globals Used to storeTGlobalMappedFunctions from other libs,...
Definition TGlobal.cxx:189
Global variables class (global variables are obtained from CINT).
Definition TGlobal.h:28
virtual DeclId_t GetDeclId() const
Definition TGlobal.cxx:97
virtual Int_t GetArrayDim() const
Return number of array dimensions.
Definition TGlobal.cxx:89
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:115
virtual ~TGlobal()
TGlobal dtor deletes adopted CINT DataMemberInfo object.
Definition TGlobal.cxx:73
DataMemberInfo_t * fInfo
Definition TGlobal.h:31
virtual bool Update(DataMemberInfo_t *info)
Update the TFunction to reflect the new info.
Definition TGlobal.cxx:164
virtual Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Definition TGlobal.cxx:105
virtual Bool_t IsValid()
Return true if this global object is pointing to a currently loaded global.
Definition TGlobal.cxx:135
TGlobal & operator=(const TGlobal &)
Assignment operator.
Definition TGlobal.cxx:53
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
Definition TGlobal.cxx:152
virtual void * GetAddress() const
Return address of global.
Definition TGlobal.cxx:81
virtual const char * GetFullTypeName() const
Get full type description of global variable, e,g.: "class TDirectory*".
Definition TGlobal.cxx:124
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
void Add(TObject *obj) override
Definition TList.h:81
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
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