Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JRoot.hh
Go to the documentation of this file.
1#ifndef __JROOT__JROOT__
2#define __JROOT__JROOT__
3
4#include <cstring>
5#include <typeinfo>
6
7#include <TDictionary.h>
8#include <TClass.h>
9#include <TObject.h>
10#include <TDataMember.h>
11#include <TBaseClass.h>
12#include <TList.h>
13
14/**
15 * \author mdejong
16 */
17
18namespace JROOT {}
19namespace JPP { using namespace JROOT; }
20
21namespace JROOT {
22
23 struct JRoot {
24 /**
25 * Check name of class against internal ROOT class names.
26 *
27 * \param name name of class
28 * \return true if name of class corresponds to genuine class; else false
29 */
30 static inline bool is_class(const char* const name)
31 {
32 return (name != NULL &&
33 strcmp(name, TClass ::Class()->GetName()) != 0 &&
34 strcmp(name, TObject::Class()->GetName()) != 0 &&
35 strcmp(name, "This") != 0 &&
36 strcmp(name, "_Rb_tree_node_base") != 0 &&
37 strcmp(name, "fgIsA") != 0 &&
38 strcmp(name, "atomic<TClass*>") != 0);
39 }
40
41
42 /**
43 * Check base class against internal ROOT class names.
44 *
45 * \param object base class
46 * \return true if valid class; else false
47 */
48 static inline bool is_class(const TBaseClass& object)
49 {
50 return is_class(object.GetName());
51 }
52
53
54 /**
55 * Check data member against internal ROOT class names.
56 *
57 * \param object data member
58 * \return true if valid class; else false
59 */
60 static inline bool is_class(const TDataMember& object)
61 {
62 return is_class(object.GetTypeName());
63 }
64
65
66 /**
67 * Check if base class is STL container.
68 *
69 * \param object base class
70 * \return true if STL container; else false
71 */
72 static inline bool is_STLcontainer(const TBaseClass& object)
73 {
74 return (const_cast<TBaseClass&>(object).IsSTLContainer() != ROOT::kNotSTL);
75 }
76
77
78 /**
79 * Check if data member is STL container.
80 *
81 * \param object data member
82 * \return true if STL container; else false
83 */
84 static inline bool is_STLcontainer(const TDataMember& object)
85 {
86 return (const_cast<TDataMember&>(object).IsSTLContainer() != ROOT::kNotSTL);
87 }
88
89
90 /**
91 * Check if data member is STL string.
92 *
93 * \param object data member
94 * \return true if STL string; else false
95 */
96 static inline bool is_STLstring(const TDataMember& object)
97 {
98 return (strcmp(object.GetFullTypeName(), "string") == 0 ||
99 strcmp(object.GetFullTypeName(), "const string") == 0);
100 }
101
102
103 /**
104 * Check if data member is static.
105 *
106 * \param object data member
107 * \return true if static; else false
108 */
109 static inline bool is_static(const TDataMember& object)
110 {
111 return (object.Property() & kIsStatic);
112 }
113
114
115 /**
116 * Check if name is one of TObject own data members
117 * (fBits or fUniqueID, for ROOT <= 6.30.04 at least).
118 *
119 * \param name name
120 * \return true if TObect data member; else false
121 */
122 static inline bool is_tobject_member(const char* name)
123 {
124 static TClass* o_class = TClass::GetClass<TObject>();
125
126 return o_class->GetListOfRealData()->FindObject(name) != nullptr;
127 }
128
129
130 /**
131 * Get ROOT typename for given template class.
132 *
133 * This method uses the TDictionary class to get the name of the given class.
134 *
135 * \return type name
136 */
137 template<class T>
138 static inline const char* getTypename()
139 {
140 static const TDictionary* pDictionary = TDictionary::GetDictionary(typeid(T));
141
142 if (pDictionary != NULL)
143 return pDictionary->GetName();
144 else
145 return NULL;
146 }
147 };
148}
149
150#endif
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
static bool is_class(const TBaseClass &object)
Check base class against internal ROOT class names.
Definition JRoot.hh:48
static bool is_class(const char *const name)
Check name of class against internal ROOT class names.
Definition JRoot.hh:30
static bool is_static(const TDataMember &object)
Check if data member is static.
Definition JRoot.hh:109
static bool is_STLcontainer(const TDataMember &object)
Check if data member is STL container.
Definition JRoot.hh:84
static bool is_STLcontainer(const TBaseClass &object)
Check if base class is STL container.
Definition JRoot.hh:72
static bool is_tobject_member(const char *name)
Check if name is one of TObject own data members (fBits or fUniqueID, for ROOT <= 6....
Definition JRoot.hh:122
static const char * getTypename()
Get ROOT typename for given template class.
Definition JRoot.hh:138
static bool is_class(const TDataMember &object)
Check data member against internal ROOT class names.
Definition JRoot.hh:60
static bool is_STLstring(const TDataMember &object)
Check if data member is STL string.
Definition JRoot.hh:96