Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TDictionary.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Fons Rademakers 20/06/96
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 TDictionary
13
14This class defines an abstract interface that must be implemented
15by all classes that contain dictionary information.
16
17The dictionary is defined by the following classes:
18~~~ {.cpp}
19TDataType (typedef definitions)
20TGlobal (global variables)
21TGlobalFunc (global functions)
22TClass (classes)
23 TBaseClass (base classes)
24 TDataMember (class datamembers)
25 TMethod (class methods)
26 TMethodArg (method arguments)
27~~~
28All the above classes implement the TDictionary abstract interface.
29Note: the indentation shows aggregation not inheritance.
30~~~ {.cpp}
31TMethodCall (method call environment)
32~~~
33\image html base_tdictionary.png
34*/
35
36#include "TDictionary.h"
37#include "TClass.h"
38#include "TClassEdit.h"
39#include "TDataType.h"
40#include "TDictAttributeMap.h"
41#include "TInterpreter.h"
42#include "TROOT.h"
43#include "TEnum.h"
44
45
47
49 TNamed(dict),
50 fAttributeMap(dict.fAttributeMap ?
51 ((TDictAttributeMap*)dict.fAttributeMap->Clone()) : nullptr ),
52 fUpdatingTransactionCount(0)
53{
54 // Copy constructor, cloning fAttributeMap.
55}
56
58{
59 // Destruct a TDictionary, delete the attribute map.
60 delete fAttributeMap;
61}
62
64{
65 // Assignment op, cloning fAttributeMap.
67
68 delete fAttributeMap;
69 fAttributeMap = nullptr;
70 if (dict.fAttributeMap)
72
73 return *this;
74}
75
77{
78 //Create a TDictAttributeMap for a TClass to be able to add attribute pairs
79 //key-value to the TClass.
80
81 if (!fAttributeMap)
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Retrieve the type (class, fundamental type, typedef etc)
87/// named "name". Returned object is either a TClass or TDataType.
88/// Returns `nullptr` if the type is unknown.
89
91{
92 // Start with typedef, the query is way faster than TClass::GetClass().
93 if (auto* ret = (TDictionary*)gROOT->GetListOfTypes()->FindObject(name)) {
94 if (auto *dtRet = dynamic_cast<TDataType*>(ret)) {
95 if (dtRet->GetType() <= 0) {
96 // Not a numeric type. Is it a known enum?
97 if (auto e = TEnum::GetEnum(name))
98 return e;
99 // Not a numeric type. Is it a known class?
100 if (auto *clRet = TClass::GetClass(name, true))
101 return clRet;
102 }
103 }
104 return ret;
105 }
106
107 return TClass::GetClass(name, true);
108}
109
110TDictionary* TDictionary::GetDictionary(const std::type_info &typeinfo)
111{
112 // Retrieve the type (class, fundamental type, typedef etc)
113 // with typeid typeinfo. Returned object is either a TClass or TDataType.
114 // Returns 0 if the type is unknown.
115
116 EDataType datatype = TDataType::GetType(typeinfo);
117 if (TDictionary* ret = TDataType::GetDataType(datatype))
118 return ret;
119 if (auto e = TEnum::GetEnum(typeinfo))
120 return e;
121 return TClass::GetClass(typeinfo, true);
122}
123
125{
126 // Return true if there were any transactions that could have changed the
127 // state of the object.
128 ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
129 if (currentTransaction == fUpdatingTransactionCount) {
130 return false;
131 }
132 fUpdatingTransactionCount = currentTransaction;
133 return true;
134}
#define e(i)
Definition RSha256.hxx:103
unsigned long long ULong64_t
Definition RtypesCore.h:70
#define ClassImp(name)
Definition Rtypes.h:382
EDataType
Definition TDataType.h:28
char name[80]
Definition TGX11.cxx:110
#define gInterpreter
#define gROOT
Definition TROOT.h:406
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:3035
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
Int_t GetType() const
Definition TDataType.h:68
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
The ROOT object has a list of properties which are stored and retrieved using TDictAttributeMap.
This class defines an abstract interface that must be implemented by all classes that contain diction...
TDictAttributeMap * fAttributeMap
ULong64_t fUpdatingTransactionCount
Bool_t UpdateInterpreterStateMarker()
the Cling ID of the transaction that last updated the object
TDictionary & operator=(const TDictionary &other)
static TDictionary * GetDictionary(const char *name)
Retrieve the type (class, fundamental type, typedef etc) named "name".
void CreateAttributeMap()
virtual ~TDictionary()
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition TEnum.cxx:175
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:51
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:241