Logo ROOT  
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 #include "THashList.h"
26 
27 #include "TDictionary.h"
28 
29 class TExMap;
30 class TDataMember;
31 
33 {
34 private:
35  TClass *fClass = nullptr; //! Context of this list. Not owned.
36 
37  TExMap *fIds = nullptr; //! Map from DeclId_t to TDataMember*
38  THashList *fUnloaded = nullptr; //! Holder of TDataMember for unloaded DataMembers.
39  ULong64_t fLastLoadMarker = 0; //! Represent interpreter state when we last did a full load.
40  std::atomic<bool> fIsLoaded{kFALSE}; //! Mark whether Load was executed.
41 
42  TDictionary::EMemberSelection fSelection = TDictionary::EMemberSelection::kNoUsingDecls; //! Whether the list should contain regular data members or only using decls or both.
43 
46 
47  void MapObject(TObject *obj);
48  void UnmapObject(TObject *obj);
49 
50 public:
52 
53  /// Constructor, possibly for all members of a class (or globals).
54  /// Include (or not) the scope's using declarations of variables.
56  fClass(cl), fSelection(selection) {}
57 
58  /// Construct from a generic collection of data members objects
59  template<class DataMemberList>
60  TListOfDataMembers(DataMemberList & dmlist) :
62  {
63  for (auto * dataMember : dmlist)
64  Add(dataMember);
65  }
66 
68 
69  virtual void Clear(Option_t *option);
70  virtual void Delete(Option_t *option="");
71 
73  virtual TObject *FindObject(const char *name) const;
74 
75  TDictionary *Find(DeclId_t id) const;
77  TDictionary *Get(DataMemberInfo_t *info, bool skipChecks=kFALSE);
78 
79  Bool_t IsLoaded() const { return fIsLoaded; }
80  void AddFirst(TObject *obj);
81  void AddFirst(TObject *obj, Option_t *opt);
82  void AddLast(TObject *obj);
83  void AddLast(TObject *obj, Option_t *opt);
84  void AddAt(TObject *obj, Int_t idx);
85  void AddAfter(const TObject *after, TObject *obj);
86  void AddAfter(TObjLink *after, TObject *obj);
87  void AddBefore(const TObject *before, TObject *obj);
88  void AddBefore(TObjLink *before, TObject *obj);
89 
90  TClass *GetClass() const { return fClass; }
91  void SetClass(TClass* cl) { fClass = cl; }
92  void Update(TDictionary *member);
93 
94  void RecursiveRemove(TObject *obj);
95  TObject *Remove(TObject *obj);
96  TObject *Remove(TObjLink *lnk);
97 
98  void Load();
99  void Unload();
100  void Unload(TDictionary *member);
101 
102  ClassDef(TListOfDataMembers,2); // List of TDataMembers for a class
103 };
104 
105 #endif // ROOT_TListOfDataMembers
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TListOfDataMembers::operator=
TListOfDataMembers & operator=(const TListOfDataMembers &)=delete
TListOfDataMembers::AddAt
void AddAt(TObject *obj, Int_t idx)
Insert object at location idx in the list.
Definition: TListOfDataMembers.cxx:114
Option_t
const char Option_t
Definition: RtypesCore.h:66
TListOfDataMembers::Clear
virtual void Clear(Option_t *option)
Remove all objects from the list.
Definition: TListOfDataMembers.cxx:160
TListOfDataMembers::AddBefore
void AddBefore(const TObject *before, TObject *obj)
Insert object before object before in the list.
Definition: TListOfDataMembers.cxx:141
TListOfDataMembers::fUnloaded
THashList * fUnloaded
Map from DeclId_t to TDataMember*.
Definition: TListOfDataMembers.h:38
TListOfDataMembers::fClass
TClass * fClass
Definition: TListOfDataMembers.h:35
TListOfDataMembers::FindObject
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
Int_t
int Int_t
Definition: RtypesCore.h:45
TDataMember
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
TListOfDataMembers::DeclId_t
TDictionary::DeclId_t DeclId_t
Definition: TListOfDataMembers.h:51
TListOfDataMembers::Delete
virtual void Delete(Option_t *option="")
Delete all TDataMember object files.
Definition: TListOfDataMembers.cxx:171
TListOfDataMembers::fSelection
TDictionary::EMemberSelection fSelection
Mark whether Load was executed.
Definition: TListOfDataMembers.h:42
bool
TDictionary.h
TListOfDataMembers::AddLast
void AddLast(TObject *obj)
Add object at the end of the list.
Definition: TListOfDataMembers.cxx:92
TListOfDataMembers::Unload
void Unload()
Mark 'all func' as being unloaded.
Definition: TListOfDataMembers.cxx:542
TListOfDataMembers::UnmapObject
void UnmapObject(TObject *obj)
Remove a pair<id, object> from the map of data members and their ids.
Definition: TListOfDataMembers.cxx:322
TListOfDataMembers
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
Definition: TListOfDataMembers.h:33
TListOfDataMembers::RecursiveRemove
void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TListOfDataMembers.cxx:353
TListOfDataMembers::AddFirst
void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition: TListOfDataMembers.cxx:70
TListOfDataMembers::Find
TDictionary * Find(DeclId_t id) const
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
Definition: TListOfDataMembers.cxx:205
THashList
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
TListOfDataMembers::fLastLoadMarker
ULong64_t fLastLoadMarker
Holder of TDataMember for unloaded DataMembers.
Definition: TListOfDataMembers.h:39
THashList::FindObject
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
TListOfDataMembers::IsLoaded
Bool_t IsLoaded() const
Definition: TListOfDataMembers.h:79
TDictionary::DeclId_t
const void * DeclId_t
Definition: TDictionary.h:223
TDictionary::EMemberSelection::kNoUsingDecls
@ kNoUsingDecls
TListOfDataMembers::GetClass
TClass * GetClass() const
Definition: TListOfDataMembers.h:90
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TListOfDataMembers::MapObject
void MapObject(TObject *obj)
Add a pair<id, object> to the map of data members and their ids.
Definition: TListOfDataMembers.cxx:50
TListOfDataMembers::TListOfDataMembers
TListOfDataMembers(const TListOfDataMembers &)=delete
Whether the list should contain regular data members or only using decls or both.
TListOfDataMembers::fIds
TExMap * fIds
Context of this list. Not owned.
Definition: TListOfDataMembers.h:37
TListOfDataMembers::AddAfter
void AddAfter(const TObject *after, TObject *obj)
Insert object after object after in the list.
Definition: TListOfDataMembers.cxx:123
TDictionary
This class defines an abstract interface that must be implemented by all classes that contain diction...
Definition: TDictionary.h:167
THashList.h
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
TListOfDataMembers::Load
void Load()
Load all the DataMembers known to the interpreter for the scope 'fClass' into this collection.
Definition: TListOfDataMembers.cxx:399
TListOfDataMembers::TListOfDataMembers
TListOfDataMembers(TClass *cl, TDictionary::EMemberSelection selection)
Constructor, possibly for all members of a class (or globals).
Definition: TListOfDataMembers.h:55
TListOfDataMembers::Remove
TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TListOfDataMembers.cxx:366
TListOfDataMembers::Get
TDictionary * Get(DeclId_t id)
Return (after creating it if necessary) the TDataMember describing the data member corresponding to t...
Definition: TListOfDataMembers.cxx:216
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TDictionary::EMemberSelection
EMemberSelection
Kinds of members to include in lists.
Definition: TDictionary.h:215
name
char name[80]
Definition: TGX11.cxx:110
TExMap
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
TListOfDataMembers::~TListOfDataMembers
~TListOfDataMembers()
Destructor.
Definition: TListOfDataMembers.cxx:39
TListOfDataMembers::Update
void Update(TDictionary *member)
Move the member or data member to the expect set of list.
Definition: TListOfDataMembers.cxx:497
TListOfDataMembers::SetClass
void SetClass(TClass *cl)
Definition: TListOfDataMembers.h:91
TListOfDataMembers::TListOfDataMembers
TListOfDataMembers(DataMemberList &dmlist)
Construct from a generic collection of data members objects.
Definition: TListOfDataMembers.h:60
TListOfDataMembers::fIsLoaded
std::atomic< bool > fIsLoaded
Represent interpreter state when we last did a full load.
Definition: TListOfDataMembers.h:40