ROOT  6.06/09
Reference Guide
TClassTable.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Fons Rademakers 11/08/95
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 #ifndef ROOT_TClassTable
13 #define ROOT_TClassTable
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TClassTable //
19 // //
20 // This class registers for all classes their name, id and dictionary //
21 // function in a hash table. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_TObject
26 #include "TObject.h"
27 #endif
28 #ifndef ROOT_TString
29 #include "TString.h"
30 #endif
31 
32 class TProtoClass;
33 
34 namespace ROOT {
35  class TClassAlt;
36  class TClassRec;
37  class TMapTypeToClassRec;
38 }
39 
40 class TClassTable : public TObject {
41 
42 friend void ROOT::ResetClassVersion(TClass*, const char*, Short_t);
43 friend class TROOT;
44 
45 private:
46  typedef ROOT::TMapTypeToClassRec IdMap_t;
47 
48  static ROOT::TClassAlt **fgAlternate;
49  static ROOT::TClassRec **fgTable;
50  static ROOT::TClassRec **fgSortedTable;
51  static IdMap_t *fgIdMap;
52  static UInt_t fgSize;
53  static UInt_t fgTally;
54  static Bool_t fgSorted;
55  static UInt_t fgCursor;
56 
57  TClassTable();
58 
59  static ROOT::TClassRec *FindElementImpl(const char *cname, Bool_t insert);
60  static ROOT::TClassRec *FindElement(const char *cname, Bool_t insert=kFALSE);
61  static void SortTable();
62 
63 public:
64  // bits that can be set in pragmabits
65  enum {
66  kNoStreamer = 0x01, kNoInputOperator = 0x02, kAutoStreamer = 0x04,
68  };
69 
70  ~TClassTable();
71 
72  static void Add(const char *cname, Version_t id,
73  const type_info &info, DictFuncPtr_t dict,
74  Int_t pragmabits);
75  static void Add(TProtoClass *protoClass);
76  static void AddAlternate(const char *normname, const char *alternate);
77  static char *At(UInt_t index);
78  int Classes();
79  static Bool_t Check(const char *cname, std::string &normname);
80  static Version_t GetID(const char *cname);
81  static Int_t GetPragmaBits(const char *name);
82  static DictFuncPtr_t GetDict(const char *cname);
83  static DictFuncPtr_t GetDict(const type_info& info);
84  static DictFuncPtr_t GetDictNorm(const char *cname);
85  static TProtoClass *GetProto(const char *cname);
86  static TProtoClass *GetProtoNorm(const char *cname);
87  static void Init();
88  static char *Next();
89  void Print(Option_t *option="") const;
90  static void PrintTable();
91  static void Remove(const char *cname);
92  static void Terminate();
93 
94  ClassDef(TClassTable,0) //Table of known classes
95 };
96 
98 
99 namespace ROOT {
100  extern void AddClass(const char *cname, Version_t id, DictFuncPtr_t dict,
101  Int_t pragmabits);
102  extern void RemoveClass(const char *cname);
103 }
104 
105 #endif
static ROOT::TClassRec ** fgSortedTable
Definition: TClassTable.h:50
ROOT top level object description.
Definition: TROOT.h:80
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
short Version_t
Definition: RtypesCore.h:61
static Bool_t Check(const char *cname, std::string &normname)
R__EXTERN TClassTable * gClassTable
Definition: TClassTable.h:97
const char Option_t
Definition: RtypesCore.h:62
static Version_t GetID(const char *cname)
Returns the ID of a class.
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
static void SortTable()
Sort the class table by ascending class ID's.
static TProtoClass * GetProto(const char *cname)
Given the class name returns the TClassProto object for the class.
Persistent version of a TClass.
Definition: TProtoClass.h:37
ROOT::TMapTypeToClassRec IdMap_t
Definition: TClassTable.h:46
void AddClass(const char *cname, Version_t id, const type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Global function called by the ctor of a class's init class (see the ClassImp macro).
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
This class registers for all classes their name, id and dictionary function in a hash table...
Definition: TClassTable.h:40
TClassTable()
TClassTable is a singleton (i.e. only one can exist per application).
static void Init()
#define ClassDef(name, id)
Definition: Rtypes.h:254
static void Add(const char *cname, Version_t id, const type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Add a class to the class table (this is a static function).
static ROOT::TClassRec ** fgTable
Definition: TClassTable.h:49
TClass *(* DictFuncPtr_t)()
Definition: Rtypes.h:75
void ResetClassVersion(TClass *, const char *, Short_t)
Global function to update the version number.
void RemoveClass(const char *cname)
Global function called by the dtor of a class's init class (see the ClassImp macro).
static void AddAlternate(const char *normname, const char *alternate)
static UInt_t fgTally
Definition: TClassTable.h:53
static void Remove(const char *cname)
Remove a class from the class table.
unsigned int UInt_t
Definition: RtypesCore.h:42
short Short_t
Definition: RtypesCore.h:35
static Int_t GetPragmaBits(const char *name)
Returns the pragma bits as specified in the LinkDef.h file.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
static UInt_t fgSize
Definition: TClassTable.h:52
static void Terminate()
Deletes the class table (this static class function calls the dtor).
static IdMap_t * fgIdMap
Definition: TClassTable.h:51
static ROOT::TClassRec * FindElement(const char *cname, Bool_t insert=kFALSE)
Find a class by name in the class table (using hash of name).
static char * Next()
Returns next class from sorted class table.
~TClassTable()
TClassTable singleton is deleted in Terminate().
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
static UInt_t fgCursor
Definition: TClassTable.h:55
void Print(Option_t *option="") const
Print the class table.
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
#define R__EXTERN
Definition: DllImport.h:27
static void PrintTable()
Print the class table.
static ROOT::TClassRec * FindElementImpl(const char *cname, Bool_t insert)
Find a class by name in the class table (using hash of name).
static Bool_t fgSorted
Definition: TClassTable.h:54
static char * At(UInt_t index)
Returns class at index from sorted class table.
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name)...
static ROOT::TClassAlt ** fgAlternate
Definition: TClassTable.h:48