CMS 3D CMS Logo

TypeWithDict.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_TypeWithDict_h
2 #define FWCore_Utilities_TypeWithDict_h
3 
4 /*----------------------------------------------------------------------
5 
6 TypeWithDict: A unique identifier for a C++ type, with the dictionary information
7 
8 The identifier is unique within an entire program, but can not be
9 persisted across invocations of the program.
10 
11 ----------------------------------------------------------------------*/
14 
15 #include "TBaseClass.h"
16 #include "TClass.h"
17 #include "TDataMember.h"
18 #include "TDataType.h"
19 #include "TEnum.h"
20 #include "TMethod.h"
21 #include "TMethodArg.h"
22 
23 #include <iosfwd>
24 #include <string>
25 #include <typeinfo>
26 #include <vector>
27 
28 namespace edm {
29 
30  class FunctionWithDict;
31  class MemberWithDict;
32  class ObjectWithDict;
33 
34  class TypeBases;
35  class TypeDataMembers;
36  class TypeFunctionMembers;
37 
38  class TypeWithDict {
39  friend class TypeBases;
40  friend class TypeDataMembers;
41  friend class TypeFunctionMembers;
42  friend bool operator==(TypeWithDict const&, std::type_info const&);
43  typedef enum {} dummyType; // Tag for valid type, but no type_info information
44  typedef dummyType** invalidType; // Tag for invalid type
45  private:
46  std::type_info const* ti_;
47  TClass* class_;
48  TEnum* enum_;
49  TDataType* dataType_;
51  long property_;
52 
53  public:
54  static TypeWithDict byName(std::string const& name);
55  static TypeWithDict byTypeInfo(std::type_info const& ti);
56 
57  private:
58  static TypeWithDict byName(std::string const& name, long property);
59 
60  public:
61  TypeWithDict();
62  TypeWithDict(TypeWithDict const&);
63  explicit TypeWithDict(TClass* type);
64  explicit TypeWithDict(TEnum* type);
65  explicit TypeWithDict(std::type_info const&);
66  explicit TypeWithDict(TMethodArg* arg);
67 
68  private:
69  explicit TypeWithDict(std::type_info const&, long property);
70  explicit TypeWithDict(TClass* type, long property);
71  explicit TypeWithDict(TEnum* type, long property);
72  explicit TypeWithDict(TMethodArg* arg, long property);
73 
74  public:
77  explicit operator bool() const;
78  bool invalidTypeInfo() const;
79  std::type_info const& typeInfo() const;
80  //Do not check is 'invalidTypeInfo()' would return true
81  std::type_info const& unvalidatedTypeInfo() const { return *ti_; }
82  TClass* getClass() const;
83  TEnum* getEnum() const;
84  TDataType* getDataType() const;
85  long getProperty() const;
86  bool isClass() const;
87  bool isConst() const;
88  bool isArray() const;
89  bool isEnum() const;
90  bool isFundamental() const;
91  bool isPointer() const;
92  bool isReference() const;
93  bool isTemplateInstance() const;
94  bool isTypedef() const;
95  bool isVirtual() const;
96  std::string qualifiedName() const;
97  std::string cppName() const;
98  std::string unscopedName() const;
99  std::string name() const;
100  std::string userClassName() const;
102  std::string templateName() const;
103  size_t size() const;
104  size_t arrayLength() const;
105  size_t arrayDimension() const;
106  size_t maximumIndex(size_t dim) const;
107  size_t dataMemberSize() const;
108  size_t functionMemberSize() const;
110  // Note: Used only by FWCore/Modules/src/EventContentAnalyzer.cc
112  // Note: Used only by Fireworks/Core/src/FWModelContextMenuHandler.cc:262
113  //FunctionWithDict functionMemberByName(std::string const& name, TypeWithDict const& signature, int mods, TypeMemberQuery memberQuery) const;
114  // Note: Used only by CondFormats/PhysicsToolsObjects/src/MVAComputer.cc
115  FunctionWithDict functionMemberByName(std::string const& name, std::string const& proto, bool isConst) const;
116  TypeWithDict nestedType(char const*) const;
117  TypeWithDict nestedType(std::string const&) const;
118  TypeWithDict finalType() const;
119  TypeWithDict toType() const;
120  void print(std::ostream& os) const;
121  bool hasBase(std::string const&) const;
122  bool hasBase(TypeWithDict const& basety) const;
123  int getBaseClassOffset(TypeWithDict const& baseClass) const;
124  TypeWithDict templateArgumentAt(size_t index) const;
125  void const* pointerToBaseType(void const* ptr, TypeWithDict const& derivedType) const;
126  void const* pointerToContainedType(void const* ptr, TypeWithDict const& derivedType) const;
127  int stringToEnumValue(std::string const&) const;
128  void* allocate() const;
129  void deallocate(void* address) const;
130  ObjectWithDict construct() const;
131  void destruct(void* address, bool dealloc = true) const;
132  };
133 
134  // A related free function
135  bool hasDictionary(std::type_info const&);
136 
137  inline bool operator<(TypeWithDict const& a, TypeWithDict const& b) { return a.name() < b.name(); }
138 
139  bool operator==(TypeWithDict const& a, TypeWithDict const& b);
140 
141  inline bool operator!=(TypeWithDict const& a, TypeWithDict const& b) { return !(a == b); }
142 
143  bool operator==(TypeWithDict const& a, std::type_info const& b);
144 
145  inline bool operator!=(TypeWithDict const& a, std::type_info const& b) { return !(a == b); }
146 
147  inline bool operator==(std::type_info const& a, TypeWithDict const& b) { return b == a; }
148 
149  inline bool operator!=(std::type_info const& a, TypeWithDict const& b) { return !(b == a); }
150 
151  std::ostream& operator<<(std::ostream& os, TypeWithDict const& id);
152 
153  class TypeBases {
154  private:
155  TClass* class_;
156 
157  public:
158  explicit TypeBases(TypeWithDict const&);
161  size_t size() const;
162  };
163 
165  private:
166  TClass* class_;
167 
168  public:
169  explicit TypeDataMembers(TypeWithDict const&);
172  size_t size() const;
173  };
174 
176  private:
177  TClass* class_;
178 
179  public:
180  explicit TypeFunctionMembers(TypeWithDict const&);
182  IterWithDict<TMethod> end() const;
183  size_t size() const;
184  };
185 
186 } // namespace edm
187 
191 
192 #endif // FWCore_Utilities_TypeWithDict_h
bool isConst() const
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:92
size_t functionMemberSize() const
type
Definition: HCALResponse.h:21
bool isEnum() const
void print(std::ostream &os) const
dummyType ** invalidType
Definition: TypeWithDict.h:44
size_t maximumIndex(size_t dim) const
TypeWithDict finalType() const
bool isTypedef() const
long getProperty() const
void const * pointerToBaseType(void const *ptr, TypeWithDict const &derivedType) const
TypeWithDict & operator=(TypeWithDict const &)
TDataType * dataType_
Definition: TypeWithDict.h:49
friend class TypeFunctionMembers
Definition: TypeWithDict.h:41
std::string qualifiedName() const
TypeWithDict nestedType(char const *) const
A arg
Definition: Factorize.h:38
bool hasBase(std::string const &) const
TypeWithDict toType() const
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
bool invalidTypeInfo() const
std::string unscopedName() const
TypeWithDict templateArgumentAt(size_t index) const
MemberWithDict dataMemberByName(std::string const &) const
friend class TypeBases
Definition: TypeWithDict.h:39
size_t arrayDimension() const
bool isArray() const
std::string templateName() const
bool isTemplateInstance() const
size_t dataMemberSize() const
TClass * getClass() const
std::string name() const
std::type_info const * ti_
Definition: TypeWithDict.h:46
std::string cppName() const
bool isVirtual() const
void const * pointerToContainedType(void const *ptr, TypeWithDict const &derivedType) const
bool isClass() const
friend bool operator==(TypeWithDict const &, std::type_info const &)
bool isFundamental() const
std::type_info const & typeInfo() const
#define end
Definition: vmac.h:39
int stringToEnumValue(std::string const &) const
FunctionWithDict functionMemberByName(std::string const &) const
std::string friendlyClassName() const
void deallocate(void *address) const
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
TDataType * getDataType() const
std::type_info const & unvalidatedTypeInfo() const
Definition: TypeWithDict.h:81
static TypeWithDict byTypeInfo(std::type_info const &ti)
Definition: TypeWithDict.cc:62
bool isReference() const
TypeWithDict & stripConstRef()
value_ptr< std::vector< size_t > > arrayDimensions_
Definition: TypeWithDict.h:50
void destruct(void *address, bool dealloc=true) const
double b
Definition: hdecay.h:120
std::string userClassName() const
TEnum * getEnum() const
size_t size() const
int getBaseClassOffset(TypeWithDict const &baseClass) const
#define begin
Definition: vmac.h:32
HLT enums.
double a
Definition: hdecay.h:121
friend class TypeDataMembers
Definition: TypeWithDict.h:40
bool hasDictionary(std::type_info const &)
ObjectWithDict construct() const
bool isPointer() const
size_t arrayLength() const
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
void * allocate() const
TClass * class_
Definition: TypeWithDict.h:155