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
46
48 TNamed(dict),
49 fAttributeMap(dict.fAttributeMap ?
50 ((TDictAttributeMap*)dict.fAttributeMap->Clone()) : nullptr ),
51 fUpdatingTransactionCount(0)
52{
53 // Copy constructor, cloning fAttributeMap.
54}
55
57{
58 // Destruct a TDictionary, delete the attribute map.
59 delete fAttributeMap;
60}
61
63{
64 // Assignment op, cloning fAttributeMap.
66
67 delete fAttributeMap;
68 fAttributeMap = nullptr;
69 if (dict.fAttributeMap)
71
72 return *this;
73}
74
76{
77 //Create a TDictAttributeMap for a TClass to be able to add attribute pairs
78 //key-value to the TClass.
79
80 if (!fAttributeMap)
82}
83
84////////////////////////////////////////////////////////////////////////////////
85/// Retrieve the type (class, fundamental type, typedef etc)
86/// named "name". Returned object is either a TClass or TDataType.
87/// Returns `nullptr` if the type is unknown.
88
90{
91 // Start with typedef, the query is way faster than TClass::GetClass().
92 if (auto* ret = (TDictionary*)gROOT->GetListOfTypes()->FindObject(name)) {
93 if (auto *dtRet = dynamic_cast<TDataType*>(ret)) {
94 if (dtRet->GetType() <= 0) {
95 // Not a numeric type. Is it a known enum?
96 if (auto e = TEnum::GetEnum(name))
97 return e;
98 // Not a numeric type. Is it a known class?
99 if (auto *clRet = TClass::GetClass(name, true))
100 return clRet;
101 }
102 }
103 return ret;
104 }
105
106 return TClass::GetClass(name, true);
107}
108
110{
111 // Retrieve the type (class, fundamental type, typedef etc)
112 // with typeid typeinfo. Returned object is either a TClass or TDataType.
113 // Returns 0 if the type is unknown.
114
117 return ret;
118 if (auto e = TEnum::GetEnum(typeinfo))
119 return e;
120 return TClass::GetClass(typeinfo, true);
121}
122
124{
125 // Return true if there were any transactions that could have changed the
126 // state of the object.
127 ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
129 return false;
130 }
132 return true;
133}
#define e(i)
Definition RSha256.hxx:103
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
EDataType
Definition TDataType.h:28
char name[80]
Definition TGX11.cxx:110
#define gInterpreter
#define gROOT
Definition TROOT.h:411
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:2973
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:181
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:50
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:242