Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TBaseClass.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Fons Rademakers 08/02/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#include "TBaseClass.h"
13#include "TBuffer.h"
14#include "TClass.h"
15#include "TInterpreter.h"
16#include <climits>
17
18#include "TVirtualMutex.h" // For R__LOCKGUARD
19
20/** \class TBaseClass
21Each class (see TClass) has a linked list of its base class(es).
22This class describes one single base class.
23The base class info is obtained via the CINT api.
24 see class TCling.
25
26The base class information is used a.o. in to find all inherited methods.
27*/
28
29
30
31////////////////////////////////////////////////////////////////////////////////
32/// Default TBaseClass ctor. TBaseClasses are constructed in TClass
33/// via a call to TCling::CreateListOfBaseClasses().
34
35TBaseClass::TBaseClass(BaseClassInfo_t *info, TClass *cl) :
36 TDictionary(), fInfo(info), fClass(cl), fDelta(INT_MAX),
37 fProperty(-1), fSTLType(-1)
38{
39 if (fInfo) SetName(gCling->BaseClassInfo_FullName(fInfo));
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// TBaseClass dtor deletes adopted CINT BaseClassInfo object.
44
46{
47 gCling->BaseClassInfo_Delete(fInfo);
48}
49
50////////////////////////////////////////////////////////////////////////////////
51/// Called by the browser, to browse a baseclass.
52
54{
56 if (c) c->Browse(b);
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Get pointer to the base class TClass.
61
63{
64 if (!fClassPtr) {
65 if (fInfo) fClassPtr = TClass::GetClass(gCling->BaseClassInfo_ClassInfo(fInfo),load);
66 else fClassPtr = TClass::GetClass(fName, load);
67 }
68 return fClassPtr;
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Get offset from "this" to part of base class.
73
75{
76 // Initialized to INT_MAX to signal that it's unset; -1 is a valid value
77 // meaning "cannot calculate base offset".
78 if (fDelta == INT_MAX) {
81 fDelta = -1;
82 else if (fInfo)
83 fDelta = (Int_t)gCling->BaseClassInfo_Offset(fInfo);
84 }
85 return fDelta;
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Get base class description (comment).
90
91const char *TBaseClass::GetTitle() const
92{
93 TClass *c = ((TBaseClass *)this)->GetClassPointer();
94 return c ? c->GetTitle() : "";
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Return which type (if any) of STL container the data member is.
99
101{
102 // fSTLType is -1 if not yet evaluated.
103 // fSTLType is -2 if no fInfo was available.
104
105 if (fSTLType < 0) {
106 if (!fInfo) {
107 fSTLType = -2;
108 } else {
109 const char *type = gCling->BaseClassInfo_TmpltName(fInfo);
110 if (!type) fSTLType = ROOT::kNotSTL;
111 else if (!strcmp(type, "vector")) fSTLType = ROOT::kSTLvector;
112 else if (!strcmp(type, "list")) fSTLType = ROOT::kSTLlist;
113 else if (!strcmp(type, "forward_list")) fSTLType = ROOT::kSTLforwardlist;
114 else if (!strcmp(type, "deque")) fSTLType = ROOT::kSTLdeque;
115 else if (!strcmp(type, "map")) fSTLType = ROOT::kSTLmap;
116 else if (!strcmp(type, "multimap")) fSTLType = ROOT::kSTLmultimap;
117 else if (!strcmp(type, "set")) fSTLType = ROOT::kSTLset;
118 else if (!strcmp(type, "multiset")) fSTLType = ROOT::kSTLmultiset;
119 else if (!strcmp(type, "unordered_set")) fSTLType = ROOT::kSTLunorderedset;
120 else if (!strcmp(type, "unordered_multiset")) fSTLType = ROOT::kSTLunorderedmultiset;
121 else if (!strcmp(type, "unordered_map")) fSTLType = ROOT::kSTLunorderedmap;
122 else if (!strcmp(type, "unordered_multimap")) fSTLType = ROOT::kSTLunorderedmultimap;
123 else fSTLType = ROOT::kNotSTL;
124 }
125 }
126 if (fSTLType == -2) return ROOT::kNotSTL;
127 return (ROOT::ESTLType) fSTLType;
128}
129
130////////////////////////////////////////////////////////////////////////////////
131/// Get property description word. For meaning of bits see EProperty.
132
134{
135 if (fProperty == -1 && fInfo) {
137 fProperty = gCling->BaseClassInfo_Property(fInfo);
138 }
139 return fProperty;
140}
141
142////////////////////////////////////////////////////////////////////////////////
143/// Stream an object of TBaseClass. Triggers the calculation of the
144/// cache variables to store them.
145
147 if (b.IsReading()) {
148 b.ReadClassBuffer(Class(), this);
149 } else {
150 // Writing.
151 // Calculate cache properties first.
152 GetDelta();
153 Property();
155 b.WriteClassBuffer(Class(), this);
156 }
157}
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
@ kIsVirtualBase
Definition TDictionary.h:89
externTInterpreter * gCling
externTVirtualMutex * gInterpreterMutex
#define R__LOCKGUARD(mutex)
Int_t GetDelta()
Get offset from "this" to part of base class.
ROOT::ESTLType IsSTLContainer()
Return which type (if any) of STL container the data member is.
void Browse(TBrowser *b) override
Called by the browser, to browse a baseclass.
void Streamer(TBuffer &) override
Stream an object of TBaseClass.
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
virtual ~TBaseClass()
TBaseClass dtor deletes adopted CINT BaseClassInfo object.
TBaseClass(const TBaseClass &)=delete
static TClass * Class()
TClassRef fClassPtr
Definition TBaseClass.h:50
AtomicInt_t fDelta
Definition TBaseClass.h:52
TClass * fClass
!pointer to parent class
Definition TBaseClass.h:51
Int_t fSTLType
Definition TBaseClass.h:54
AtomicInt_t fProperty
Definition TBaseClass.h:53
BaseClassInfo_t * fInfo
!pointer to CINT base class info
Definition TBaseClass.h:49
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
const char * GetTitle() const override
Get base class description (comment).
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2994
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
ESTLType
Definition ESTLType.h:28
@ kSTLmap
Definition ESTLType.h:33
@ kSTLunorderedmultiset
Definition ESTLType.h:43
@ kSTLset
Definition ESTLType.h:35
@ kSTLmultiset
Definition ESTLType.h:36
@ kSTLdeque
Definition ESTLType.h:32
@ kSTLvector
Definition ESTLType.h:30
@ kSTLunorderedmultimap
Definition ESTLType.h:45
@ kSTLunorderedset
Definition ESTLType.h:42
@ kSTLlist
Definition ESTLType.h:31
@ kSTLforwardlist
Definition ESTLType.h:41
@ kSTLunorderedmap
Definition ESTLType.h:44
@ kNotSTL
Definition ESTLType.h:29
@ kSTLmultimap
Definition ESTLType.h:34