Logo ROOT  
Reference Guide
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
44
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 class?
96 if (auto *clRet = TClass::GetClass(name, true))
97 return clRet;
98 }
99 }
100 return ret;
101 }
102
103 return TClass::GetClass(name, true);
104}
105
106TDictionary* TDictionary::GetDictionary(const std::type_info &typeinfo)
107{
108 // Retrieve the type (class, fundamental type, typedef etc)
109 // with typeid typeinfo. Returned object is either a TClass or TDataType.
110 // Returns 0 if the type is unknown.
111
112 EDataType datatype = TDataType::GetType(typeinfo);
113 TDictionary* ret = TDataType::GetDataType(datatype);
114 if (ret) return ret;
115
116 return TClass::GetClass(typeinfo, true);
117}
118
120{
121 // Return true if there were any transactions that could have changed the
122 // state of the object.
123 ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
124 if (currentTransaction == fUpdatingTransactionCount) {
125 return false;
126 }
127 fUpdatingTransactionCount = currentTransaction;
128 return true;
129}
bool Bool_t
Definition: RtypesCore.h:63
#define ClassImp(name)
Definition: Rtypes.h:364
EDataType
Definition: TDataType.h:28
#define gInterpreter
Definition: TInterpreter.h:560
#define gROOT
Definition: TROOT.h:404
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:2955
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.
Definition: TDataType.cxx:443
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...
Definition: TDictionary.h:167
TDictAttributeMap * fAttributeMap
Definition: TDictionary.h:170
ULong64_t fUpdatingTransactionCount
Definition: TDictionary.h:171
Bool_t UpdateInterpreterStateMarker()
the Cling ID of the transaction that last updated the object
TDictionary & operator=(const TDictionary &other)
Definition: TDictionary.cxx:62
static TDictionary * GetDictionary(const char *name)
Retrieve the type (class, fundamental type, typedef etc) named "name".
Definition: TDictionary.cxx:89
void CreateAttributeMap()
Definition: TDictionary.cxx:75
virtual ~TDictionary()
Definition: TDictionary.cxx:56
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:146
unsigned long long ULong64_t
Definition: cpp_cppyy.h:14
static const std::string name("name")