From bce0f53594c57d7490b749c9e26144f32219a83b Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Wed, 22 Jan 2014 15:31:23 +0100 Subject: [PATCH 1/2] Change from TClassAttributeMap to TDictAttributeMap. --- core/base/src/TSystem.cxx | 2 +- core/meta/inc/LinkDef.h | 2 +- core/meta/inc/TClass.h | 10 ------- ...lassAttributeMap.h => TDictAttributeMap.h} | 16 ++++++------ core/meta/inc/TDictionary.h | 20 +++++++++++--- core/meta/src/TClass.cxx | 26 ++++--------------- ...AttributeMap.cxx => TDictAttributeMap.cxx} | 26 +++++++++---------- core/meta/src/TDictionary.cxx | 16 ++++++++++++ core/metautils/src/TMetaUtils.cxx | 2 +- core/utils/src/rootcling.cxx | 2 +- 10 files changed, 62 insertions(+), 60 deletions(-) rename core/meta/inc/{TClassAttributeMap.h => TDictAttributeMap.h} (81%) rename core/meta/src/{TClassAttributeMap.cxx => TDictAttributeMap.cxx} (81%) diff --git a/core/base/src/TSystem.cxx b/core/base/src/TSystem.cxx index 483e3af6d3398..ee28fdfc15e65 100644 --- a/core/base/src/TSystem.cxx +++ b/core/base/src/TSystem.cxx @@ -2542,7 +2542,7 @@ static void R__WriteDependencyFile(const TString &build_loc, const TString &depf #endif { const char *dictHeaders[] = { "RVersion.h", "RConfig.h", "TClass.h", - "TClassAttributeMap.h","TInterpreter.h","TROOT.h","TBuffer.h", + "TDictAttributeMap.h","TInterpreter.h","TROOT.h","TBuffer.h", "TMemberInspector.h","TError.h","RtypesImp.h","TIsAProxy.h", "TFileMergeInfo.h","TCollectionProxyInfo.h"}; diff --git a/core/meta/inc/LinkDef.h b/core/meta/inc/LinkDef.h index 3a5e6b5e72cc8..91c2e779a78b1 100644 --- a/core/meta/inc/LinkDef.h +++ b/core/meta/inc/LinkDef.h @@ -21,7 +21,7 @@ #pragma link C++ class TClass; #pragma link C++ class TClassStreamer+; #pragma link C++ class TMemberStreamer+; -#pragma link C++ class TClassAttributeMap+; +#pragma link C++ class TDictAttributeMap+; #pragma link C++ class TClassRef+; #pragma link C++ class TClassGenerator+; #pragma link C++ class TDataMember; diff --git a/core/meta/inc/TClass.h b/core/meta/inc/TClass.h index 24742915e642f..0791b0ad1738f 100644 --- a/core/meta/inc/TClass.h +++ b/core/meta/inc/TClass.h @@ -41,7 +41,6 @@ class TBaseClass; class TBrowser; class TDataMember; -class TClassAttributeMap; class TClassRef; class TCling; class TMethod; @@ -148,7 +147,6 @@ friend class ROOT::TGenericClassInfo; TClassRef *fRefStart; //!List of references to this object TVirtualRefProxy *fRefProxy; //!Pointer to reference proxy if this class represents a reference ROOT::TSchemaRuleSet *fSchemaRules; //! Schema evolution rules - TClassAttributeMap *fAttributeMap; //pointer to a class attribute map typedef void (TClass::*StreamerImpl_t)(void *obj, TBuffer &b, const TClass *onfile_class) const; mutable StreamerImpl_t fStreamerImpl;//! Pointer to the function implementing the right streaming behavior for the class represented by this object. @@ -399,14 +397,6 @@ friend class ROOT::TGenericClassInfo; void *DynamicCast(const TClass *base, void *obj, Bool_t up = kTRUE); const void *DynamicCast(const TClass *base, const void *obj, Bool_t up = kTRUE); Bool_t IsFolder(void *obj) const; - void CreateAttributeMap(); - TClassAttributeMap *GetAttributeMap() const - { - //Get the TClassAttributeMap pointer to be able to add attribute - //pairs key-value to the TClass. - - return fAttributeMap; - } inline void Streamer(void *obj, TBuffer &b, const TClass *onfile_class = 0) const { diff --git a/core/meta/inc/TClassAttributeMap.h b/core/meta/inc/TDictAttributeMap.h similarity index 81% rename from core/meta/inc/TClassAttributeMap.h rename to core/meta/inc/TDictAttributeMap.h index ad506e05d7657..d9888922849a2 100644 --- a/core/meta/inc/TClassAttributeMap.h +++ b/core/meta/inc/TDictAttributeMap.h @@ -9,13 +9,13 @@ * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ -#ifndef ROOT_TClassAttributeMap -#define ROOT_TClassAttributeMap +#ifndef ROOT_TDictAttributeMap +#define ROOT_TDictAttributeMap ////////////////////////////////////////////////////////////////////////// // // -// TClassAttributeMap // +// TDictAttributeMap // // // // Dictionary of attributes of a TClass. // // // @@ -30,12 +30,12 @@ #endif -class TClassAttributeMap : public TObject +class TDictAttributeMap : public TObject { public: - TClassAttributeMap(); - virtual ~TClassAttributeMap(); + TDictAttributeMap(); + virtual ~TDictAttributeMap(); void AddProperty(const char* key, const char* value); Bool_t HasKey(const char* key) const; @@ -49,8 +49,8 @@ class TClassAttributeMap : public TObject THashTable fStringProperty; //all properties of String type - ClassDef(TClassAttributeMap,1) // Container for name/value pairs of TClass attributes + ClassDef(TDictAttributeMap,1) // Container for name/value pairs of TDictionary attributes }; -#endif // ROOT_TClassAttributeMap +#endif // ROOT_TDictAttributeMap diff --git a/core/meta/inc/TDictionary.h b/core/meta/inc/TDictionary.h index 9b1079409a66c..2e2b9c8875eca 100644 --- a/core/meta/inc/TDictionary.h +++ b/core/meta/inc/TDictionary.h @@ -63,6 +63,7 @@ class MethodArgInfo_t; class MethodArgInfo_t; class TypeInfo_t; class TypedefInfo_t; +class TDictAttributeMap; enum EProperty { kIsClass = 0x00000001, @@ -160,11 +161,22 @@ namespace ROOT { class TDictionary : public TNamed { -public: - TDictionary() { } - TDictionary(const char* name): TNamed(name, "") { } - virtual ~TDictionary() { } +private: + TDictAttributeMap *fAttributeMap; //pointer to a class attribute map +public: + TDictionary(): fAttributeMap(0) { } + TDictionary(const char* name): TNamed(name, ""), fAttributeMap(0) { } + virtual ~TDictionary(); + + void CreateAttributeMap(); + TDictAttributeMap *GetAttributeMap() const + { + //Get the TDictAttributeMap pointer to be able to add attribute + //pairs key-value to the TClass. + + return fAttributeMap; + } virtual Long_t Property() const = 0; static TDictionary* GetDictionary(const char* name); static TDictionary* GetDictionary(const type_info &typeinfo); diff --git a/core/meta/src/TClass.cxx b/core/meta/src/TClass.cxx index 3af2f777d874f..3612f3c29d24a 100644 --- a/core/meta/src/TClass.cxx +++ b/core/meta/src/TClass.cxx @@ -30,7 +30,6 @@ #include "TBaseClass.h" #include "TBrowser.h" #include "TBuffer.h" -#include "TClassAttributeMap.h" #include "TClassGenerator.h" #include "TClassEdit.h" #include "TClassMenuItem.h" @@ -822,14 +821,13 @@ TClass::TClass() : fCanSplit(-1), fProperty(0),fVersionUsed(kFALSE), fIsOffsetStreamerSet(kFALSE), fOffsetStreamer(0), fStreamerType(TClass::kDefault), fCurrentInfo(0), fRefStart(0), fRefProxy(0), - fSchemaRules(0), fAttributeMap(0), fStreamerImpl(&TClass::StreamerDefault) + fSchemaRules(0), fStreamerImpl(&TClass::StreamerDefault) { // Default ctor. R__LOCKGUARD2(gInterpreterMutex); fDeclFileLine = -2; // -2 for standalone TClass (checked in dtor) - fAttributeMap = 0; } //______________________________________________________________________________ @@ -848,7 +846,7 @@ TClass::TClass(const char *name, Bool_t silent) : fCanSplit(-1), fProperty(0),fVersionUsed(kFALSE), fIsOffsetStreamerSet(kFALSE), fOffsetStreamer(0), fStreamerType(TClass::kDefault), fCurrentInfo(0), fRefStart(0), fRefProxy(0), - fSchemaRules(0), fAttributeMap(0), fStreamerImpl(&TClass::StreamerDefault) + fSchemaRules(0), fStreamerImpl(&TClass::StreamerDefault) { // Create a TClass object. This object contains the full dictionary // of a class. It has list to baseclasses, datamembers and methods. @@ -897,7 +895,7 @@ TClass::TClass(ClassInfo_t *classInfo, Version_t cversion, fCanSplit(-1), fProperty(0),fVersionUsed(kFALSE), fIsOffsetStreamerSet(kFALSE), fOffsetStreamer(0), fStreamerType(TClass::kDefault), fCurrentInfo(0), fRefStart(0), fRefProxy(0), - fSchemaRules(0), fAttributeMap(0), fStreamerImpl(&TClass::StreamerDefault) + fSchemaRules(0), fStreamerImpl(&TClass::StreamerDefault) { // Create a TClass object. This object contains the full dictionary // of a class. It has list to baseclasses, datamembers and methods. @@ -952,7 +950,7 @@ TClass::TClass(const char *name, Version_t cversion, fCanSplit(-1), fProperty(0),fVersionUsed(kFALSE), fIsOffsetStreamerSet(kFALSE), fOffsetStreamer(0), fStreamerType(TClass::kDefault), fCurrentInfo(0), fRefStart(0), fRefProxy(0), - fSchemaRules(0), fAttributeMap(0), fStreamerImpl(&TClass::StreamerDefault) + fSchemaRules(0), fStreamerImpl(&TClass::StreamerDefault) { // Create a TClass object. This object contains the full dictionary // of a class. It has list to baseclasses, datamembers and methods. @@ -981,7 +979,7 @@ TClass::TClass(const char *name, Version_t cversion, fCanSplit(-1), fProperty(0),fVersionUsed(kFALSE), fIsOffsetStreamerSet(kFALSE), fOffsetStreamer(0), fStreamerType(TClass::kDefault), fCurrentInfo(0), fRefStart(0), fRefProxy(0), - fSchemaRules(0), fAttributeMap(0), fStreamerImpl(&TClass::StreamerDefault) + fSchemaRules(0), fStreamerImpl(&TClass::StreamerDefault) { // Create a TClass object. This object contains the full dictionary // of a class. It has list to baseclasses, datamembers and methods. @@ -1280,7 +1278,6 @@ TClass::TClass(const TClass& cl) : fRefStart(cl.fRefStart), fRefProxy(cl.fRefProxy), fSchemaRules(cl.fSchemaRules), - fAttributeMap(cl.fAttributeMap ? (TClassAttributeMap*)cl.fAttributeMap->Clone() : 0 ), fStreamerImpl(cl.fStreamerImpl) { //copy constructor @@ -1388,8 +1385,6 @@ TClass::~TClass() } delete fConversionStreamerInfo; } - - delete fAttributeMap; } //------------------------------------------------------------------------------ @@ -2094,17 +2089,6 @@ void TClass::CopyCollectionProxy(const TVirtualCollectionProxy &orig) fCollectionProxy = orig.Generate(); } - -//______________________________________________________________________________ -void TClass::CreateAttributeMap() -{ - //Create a TClassAttributeMap for a TClass to be able to add attribute pairs - //key-value to the TClass. - - if (!fAttributeMap) - fAttributeMap = new TClassAttributeMap; -} - //______________________________________________________________________________ void TClass::Draw(Option_t *option) { diff --git a/core/meta/src/TClassAttributeMap.cxx b/core/meta/src/TDictAttributeMap.cxx similarity index 81% rename from core/meta/src/TClassAttributeMap.cxx rename to core/meta/src/TDictAttributeMap.cxx index f2156e7a6f4f5..1813e0f2795a5 100644 --- a/core/meta/src/TClassAttributeMap.cxx +++ b/core/meta/src/TDictAttributeMap.cxx @@ -12,37 +12,37 @@ ////////////////////////////////////////////////////////////////////////// // // // The ROOT oject has a list of properties which are stored and // -// retrieved using TClassAttributeMap. // -// TClassAttributeMap maps the property keys of the object to their // +// retrieved using TDictAttributeMap. // +// TDictAttributeMap maps the property keys of the object to their // // values. // // // ////////////////////////////////////////////////////////////////////////// -#include "TClassAttributeMap.h" +#include "TDictAttributeMap.h" #include "THashTable.h" #include "TNamed.h" #include "TParameter.h" -ClassImp(TClassAttributeMap) +ClassImp(TDictAttributeMap) //_____________________________________________________________________________ -TClassAttributeMap::TClassAttributeMap() +TDictAttributeMap::TDictAttributeMap() { //Default constructor. fStringProperty.SetOwner(kTRUE); } //_____________________________________________________________________________ -TClassAttributeMap::~TClassAttributeMap() +TDictAttributeMap::~TDictAttributeMap() { //Default destructor. } //_____________________________________________________________________________ -void TClassAttributeMap::AddProperty(const char* key, const char* value) +void TDictAttributeMap::AddProperty(const char* key, const char* value) { - //Add a property with a String value to the TClassAttributeMap. + //Add a property with a String value to the TDictAttributeMap. //Parameters: key and char* value of the property. //Add the property pair name - Int value to the hash table. @@ -50,7 +50,7 @@ void TClassAttributeMap::AddProperty(const char* key, const char* value) } //_____________________________________________________________________________ -Bool_t TClassAttributeMap::HasKey(const char* key) const +Bool_t TDictAttributeMap::HasKey(const char* key) const { //Check whether the class has a property using the key. @@ -61,7 +61,7 @@ Bool_t TClassAttributeMap::HasKey(const char* key) const } //_____________________________________________________________________________ -const char* TClassAttributeMap::GetPropertyAsString(const char* key) const +const char* TDictAttributeMap::GetPropertyAsString(const char* key) const { //Access the value of a String property using the key. @@ -77,7 +77,7 @@ const char* TClassAttributeMap::GetPropertyAsString(const char* key) const } //_____________________________________________________________________________ -TString TClassAttributeMap::RemovePropertyString(const char* key) +TString TDictAttributeMap::RemovePropertyString(const char* key) { //Remove a String property from the attribute map specified by the key. //Returns the TString property removed or NULL if the property does not exist. @@ -90,7 +90,7 @@ TString TClassAttributeMap::RemovePropertyString(const char* key) return TString(0); } -Bool_t TClassAttributeMap::RemoveProperty(const char* key) +Bool_t TDictAttributeMap::RemoveProperty(const char* key) { //Remove a property from the attribute map specified by the key. //Returns true if property exists and was removed, false if property @@ -104,7 +104,7 @@ Bool_t TClassAttributeMap::RemoveProperty(const char* key) } //_____________________________________________________________________________ -void TClassAttributeMap::Clear(Option_t* /*option = ""*/) +void TDictAttributeMap::Clear(Option_t* /*option = ""*/) { //Deletes all the properties of the class. diff --git a/core/meta/src/TDictionary.cxx b/core/meta/src/TDictionary.cxx index e6534eaf223f4..625d3218bff62 100644 --- a/core/meta/src/TDictionary.cxx +++ b/core/meta/src/TDictionary.cxx @@ -42,10 +42,26 @@ #include "TClass.h" #include "TClassEdit.h" #include "TDataType.h" +#include "TDictAttributeMap.h" #include "TROOT.h" ClassImp(TDictionary) +TDictionary::~TDictionary() { + if(fAttributeMap) { + delete fAttributeMap; + } +} + +void TDictionary::CreateAttributeMap() +{ + //Create a TDictAttributeMap for a TClass to be able to add attribute pairs + //key-value to the TClass. + + if (!fAttributeMap) + fAttributeMap = new TDictAttributeMap; +} + TDictionary* TDictionary::GetDictionary(const char* name) { // Retrieve the type (class, fundamental type, typedef etc) diff --git a/core/metautils/src/TMetaUtils.cxx b/core/metautils/src/TMetaUtils.cxx index 1f40cf5c1aff4..39a9cc4ad2535 100644 --- a/core/metautils/src/TMetaUtils.cxx +++ b/core/metautils/src/TMetaUtils.cxx @@ -1598,7 +1598,7 @@ void ROOT::TMetaUtils::WriteClassInit(std::ostream& finalString, // 4) We fill the map (in the gen code) if (!attrMapExtracted){ manipString+=" theClass->CreateAttributeMap();\n"; - manipString+=" TClassAttributeMap* attrMap( theClass->GetAttributeMap() );\n"; + manipString+=" TDictAttributeMap* attrMap( theClass->GetAttributeMap() );\n"; attrMapExtracted=true; } diff --git a/core/utils/src/rootcling.cxx b/core/utils/src/rootcling.cxx index fd3074a815d7e..bf1ca08d97fca 100644 --- a/core/utils/src/rootcling.cxx +++ b/core/utils/src/rootcling.cxx @@ -2975,7 +2975,7 @@ void CreateDictHeader(std::ostream& dictStream, const std::string& main_dictname << "#define G__DICTIONARY\n" << "#include \"RConfig.h\"\n" << "#include \"TClass.h\"\n" - << "#include \"TClassAttributeMap.h\"\n" + << "#include \"TDictAttributeMap.h\"\n" << "#include \"TInterpreter.h\"\n" << "#include \"TROOT.h\"\n" << "#include \"TBuffer.h\"\n" From 19b6beca83fd10cf3396bc54a853ac700ade5805 Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Wed, 22 Jan 2014 17:58:06 +0100 Subject: [PATCH 2/2] TDictionary copy constructor. --- core/meta/inc/TDictionary.h | 1 + core/meta/src/TDictionary.cxx | 3 +++ 2 files changed, 4 insertions(+) diff --git a/core/meta/inc/TDictionary.h b/core/meta/inc/TDictionary.h index 2e2b9c8875eca..42768707d54db 100644 --- a/core/meta/inc/TDictionary.h +++ b/core/meta/inc/TDictionary.h @@ -167,6 +167,7 @@ class TDictionary : public TNamed { public: TDictionary(): fAttributeMap(0) { } TDictionary(const char* name): TNamed(name, ""), fAttributeMap(0) { } + TDictionary(const TDictionary& dict); virtual ~TDictionary(); void CreateAttributeMap(); diff --git a/core/meta/src/TDictionary.cxx b/core/meta/src/TDictionary.cxx index 625d3218bff62..61b0c65c4122a 100644 --- a/core/meta/src/TDictionary.cxx +++ b/core/meta/src/TDictionary.cxx @@ -47,6 +47,9 @@ ClassImp(TDictionary) +TDictionary::TDictionary(const TDictionary& dict): + fAttributeMap(dict.fAttributeMap ? ((TDictAttributeMap*)dict.fAttributeMap->Clone()) : 0 ) { } + TDictionary::~TDictionary() { if(fAttributeMap) { delete fAttributeMap;