Logo ROOT   6.08/07
Reference Guide
TListOfDataMembers.h
Go to the documentation of this file.
1 // @(#)root/cont
2 // Author: Philippe Canal Aug 2013
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, 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 #ifndef ROOT_TListOfDataMembers
13 #define ROOT_TListOfDataMembers
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TListOfDataMembers //
18 // //
19 // A collection of TDataMember objects designed for fast access given a //
20 // DeclId_t and for keep track of TDataMember that were described //
21 // unloaded member. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_THastList
26 #include "THashList.h"
27 #endif
28 
29 #ifndef ROOT_TDictionary
30 #include "TDictionary.h"
31 #endif
32 
33 class TExMap;
34 class TDataMember;
35 
37 {
38 private:
39  TClass *fClass; //! Context of this list. Not owned.
40 
41  TExMap *fIds; //! Map from DeclId_t to TDataMember*
42  THashList *fUnloaded; //! Holder of TDataMember for unloaded DataMembers.
43  Bool_t fIsLoaded; //! Mark whether Load was executed.
44  ULong64_t fLastLoadMarker; //! Represent interpreter state when we last did a full load.
45 
46  TListOfDataMembers(const TListOfDataMembers&); // not implemented
47  TListOfDataMembers& operator=(const TListOfDataMembers&); // not implemented
48 
49  void MapObject(TObject *obj);
50  void UnmapObject(TObject *obj);
51 
52 public:
54 
55  TListOfDataMembers(TClass *cl = 0);
56  // construct from a generic collection of data members objects
57  template<class DataMemberList>
58  TListOfDataMembers(DataMemberList & dmlist) :
59  fClass(0),fIds(0),fUnloaded(0),
60  fIsLoaded(kTRUE), fLastLoadMarker(0)
61  {
62  for (auto * dataMember : dmlist)
63  Add(dataMember);
64  }
65 
67 
68  virtual void Clear(Option_t *option);
69  virtual void Delete(Option_t *option="");
70 
72  virtual TObject *FindObject(const char *name) const;
73 
74  TDictionary *Find(DeclId_t id) const;
75  TDictionary *Get(DeclId_t id);
76  TDictionary *Get(DataMemberInfo_t *info, bool skipChecks=kFALSE);
77 
78  Bool_t IsLoaded() const { return fIsLoaded; }
79  void AddFirst(TObject *obj);
80  void AddFirst(TObject *obj, Option_t *opt);
81  void AddLast(TObject *obj);
82  void AddLast(TObject *obj, Option_t *opt);
83  void AddAt(TObject *obj, Int_t idx);
84  void AddAfter(const TObject *after, TObject *obj);
85  void AddAfter(TObjLink *after, TObject *obj);
86  void AddBefore(const TObject *before, TObject *obj);
87  void AddBefore(TObjLink *before, TObject *obj);
88 
89  TClass *GetClass() const { return fClass; }
90  void SetClass(TClass* cl) { fClass = cl; }
91  void Update(TDictionary *member);
92 
93  void RecursiveRemove(TObject *obj);
94  TObject *Remove(TObject *obj);
95  TObject *Remove(TObjLink *lnk);
96 
97  void Load();
98  void Unload();
99  void Unload(TDictionary *member);
100 
101  ClassDef(TListOfDataMembers,2); // List of TDataMembers for a class
102 };
103 
104 #endif // ROOT_TListOfDataMembers
void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
void AddAt(TObject *obj, Int_t idx)
Insert object at location idx in the list.
const char Option_t
Definition: RtypesCore.h:62
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:33
THashList * fUnloaded
Map from DeclId_t to TDataMember*.
TListOfDataMembers & operator=(const TListOfDataMembers &)
ULong64_t fLastLoadMarker
Mark whether Load was executed.
int Int_t
Definition: RtypesCore.h:41
virtual void Clear(Option_t *option)
Remove all objects from the list.
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void Load()
Load all the DataMembers known to the interpreter for the scope &#39;fClass&#39; into this collection...
void AddLast(TObject *obj)
Add object at the end of the list.
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:213
void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
const void * DeclId_t
Definition: TDictionary.h:209
virtual TObject * FindObject(const char *name) const
Specialize FindObject to do search for the a data member just by name or create it if its not already...
void UnmapObject(TObject *obj)
Remove a pair<id, object> from the map of data members and their ids.
#define ClassDef(name, id)
Definition: Rtypes.h:254
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
void AddAfter(const TObject *after, TObject *obj)
Insert object after object after in the list.
TClass * GetClass() const
void SetClass(TClass *cl)
~TListOfDataMembers()
Destructor.
TExMap * fIds
Context of this list. Not owned.
This class defines an abstract interface that must be implemented by all classes that contain diction...
Definition: TDictionary.h:162
void Update(TDictionary *member)
Move the member or data member to the expect set of list.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
void MapObject(TObject *obj)
Add a pair<id, object> to the map of data members and their ids.
TListOfDataMembers(const TListOfDataMembers &)
Represent interpreter state when we last did a full load.
TDictionary::DeclId_t DeclId_t
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual void Delete(Option_t *option="")
Delete all TDataMember object files.
Mother of all ROOT objects.
Definition: TObject.h:37
void Unload()
Mark &#39;all func&#39; as being unloaded.
virtual void Add(TObject *obj)
Definition: TList.h:81
Bool_t IsLoaded() const
TListOfDataMembers(DataMemberList &dmlist)
void AddFirst(TObject *obj)
Add object at the beginning of the list.
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
TObject * Remove(TObject *obj)
Remove object from the list.
Bool_t fIsLoaded
Holder of TDataMember for unloaded DataMembers.
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:35
TDictionary * Get(DeclId_t id)
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...