Logo ROOT   6.12/07
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 
14 This class defines an abstract interface that must be implemented
15 by all classes that contain dictionary information.
16 
17 The dictionary is defined by the following classes:
18 ~~~ {.cpp}
19 TDataType (typedef definitions)
20 TGlobal (global variables)
21 TGlobalFunc (global functions)
22 TClass (classes)
23  TBaseClass (base classes)
24  TDataMember (class datamembers)
25  TMethod (class methods)
26  TMethodArg (method arguments)
27 ~~~
28 All the above classes implement the TDictionary abstract interface.
29 Note: the indentation shows aggregation not inheritance.
30 ~~~ {.cpp}
31 TMethodCall (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()) : 0 ),
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.
65  TNamed::operator=(dict);
66 
67  delete fAttributeMap;
68  fAttributeMap = 0;
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 
85 {
86  // Retrieve the type (class, fundamental type, typedef etc)
87  // named "name". Returned object is either a TClass or TDataType.
88  // Returns 0 if the type is unknown.
89 
90  TDictionary* ret = (TDictionary*)gROOT->GetListOfTypes()->FindObject(name);
91  if (ret) return ret;
92 
93  return TClass::GetClass(name, true);
94 }
95 
96 TDictionary* TDictionary::GetDictionary(const std::type_info &typeinfo)
97 {
98  // Retrieve the type (class, fundamental type, typedef etc)
99  // with typeid typeinfo. Returned object is either a TClass or TDataType.
100  // Returns 0 if the type is unknown.
101 
102  EDataType datatype = TDataType::GetType(typeinfo);
103  TDictionary* ret = TDataType::GetDataType(datatype);
104  if (ret) return ret;
105 
106  return TClass::GetClass(typeinfo, true);
107 }
108 
110 {
111  // Return true if there were any transactions that could have changed the
112  // state of the object.
113  ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
114  if (currentTransaction == fUpdatingTransactionCount) {
115  return false;
116  }
117  fUpdatingTransactionCount = currentTransaction;
118  return true;
119 }
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
Definition: TDataType.cxx:440
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)
Definition: TDictionary.cxx:84
#define gROOT
Definition: TROOT.h:402
bool Bool_t
Definition: RtypesCore.h:59
#define gInterpreter
Definition: TInterpreter.h:526
void CreateAttributeMap()
Definition: TDictionary.cxx:75
ULong64_t fUpdatingTransactionCount
Definition: TDictionary.h:162
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual ~TDictionary()
Definition: TDictionary.cxx:56
Int_t GetType() const
Definition: TDataType.h:68
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
This class defines an abstract interface that must be implemented by all classes that contain diction...
Definition: TDictionary.h:158
TDictAttributeMap * fAttributeMap
Definition: TDictionary.h:161
#define ClassImp(name)
Definition: Rtypes.h:359
The ROOT object has a list of properties which are stored and retrieved using TDictAttributeMap.
unsigned long long ULong64_t
Definition: RtypesCore.h:70
EDataType
Definition: TDataType.h:28
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:2887
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:144
char name[80]
Definition: TGX11.cxx:109