Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change from TClassAttributeMap to TDictAttributeMap. #41

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/base/src/TSystem.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"};

Expand Down
2 changes: 1 addition & 1 deletion core/meta/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions core/meta/inc/TClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
class TBaseClass;
class TBrowser;
class TDataMember;
class TClassAttributeMap;
class TClassRef;
class TCling;
class TMethod;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. //
// //
Expand All @@ -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;
Expand All @@ -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

21 changes: 17 additions & 4 deletions core/meta/inc/TDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class MethodArgInfo_t;
class MethodArgInfo_t;
class TypeInfo_t;
class TypedefInfo_t;
class TDictAttributeMap;

enum EProperty {
kIsClass = 0x00000001,
Expand Down Expand Up @@ -160,11 +161,23 @@ 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) { }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add TDictionary(const TDictionary& dict)? Else we break TClass(const TClass& cl). It should do what TClass(const TClass& cl) did to fAttributeMap:

fAttributeMap(cl.fAttributeMap ? (TClassAttributeMap*)cl.fAttributeMap->Clone() : 0 )

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

TDictionary(const char* name): TNamed(name, ""), fAttributeMap(0) { }
TDictionary(const TDictionary& dict);
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);
Expand Down
26 changes: 5 additions & 21 deletions core/meta/src/TClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

//______________________________________________________________________________
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1388,8 +1385,6 @@ TClass::~TClass()
}
delete fConversionStreamerInfo;
}

delete fAttributeMap;
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,45 @@
//////////////////////////////////////////////////////////////////////////
// //
// 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.
fStringProperty.Add(new TNamed(key, 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.
Expand All @@ -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.

Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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.

Expand Down
19 changes: 19 additions & 0 deletions core/meta/src/TDictionary.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,29 @@
#include "TClass.h"
#include "TClassEdit.h"
#include "TDataType.h"
#include "TDictAttributeMap.h"
#include "TROOT.h"

ClassImp(TDictionary)

TDictionary::TDictionary(const TDictionary& dict):
fAttributeMap(dict.fAttributeMap ? ((TDictAttributeMap*)dict.fAttributeMap->Clone()) : 0 ) { }

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)
Expand Down
2 changes: 1 addition & 1 deletion core/metautils/src/TMetaUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion core/utils/src/rootcling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down