Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JROOT::JRootClass Struct Reference

Auxiliary class to manage access to base classes and data members of ROOT class. More...

#include <JRootClass.hh>

Inheritance diagram for JROOT::JRootClass:
JLANG::JEquals< JFirst_t, JSecond_t > JROOT::JRootAddressableClass< char * > JROOT::JRootAddressableClass< const char * > JROOT::JRootAddressableClass< JPointer_t > JROOT::JRootReadableClass JROOT::JRootWritableClass JROOT::JBranchClass

Public Member Functions

template<class JType_t >
 JRootClass (const JType< JType_t > &type)
 Constructor.
 
template<class JType_t , class JClass_t >
 JRootClass (JType_t JClass_t::*pd)
 Constructor.
 
 JRootClass (TDictionary *dictionary, int offset=0)
 Constructor.
 
TDictionary * getDictionary () const
 Get dictionary.
 
int getOffset () const
 Get offset of this class with respect to parent class.
 
TClass * getClass () const
 Get class.
 
const char * getTypename () const
 Get type name.
 
bool is_valid () const
 Check validity of this class.
 
bool equals (const JRootClass &object) const
 Test equality of ROOT classes.
 
JRootClass find (const char *const name, const bool option=true) const
 Find base class or data member with given name within current class.
 
JRootClass get (const TDataMember &object) const
 Get ROOT class of given data member.
 
JRootClass get (const TBaseClass &object) const
 Get ROOT class of given base class.
 
void print (std::ostream &out) const
 Print ROOT class information.
 

Protected Member Functions

 JRootClass ()
 Default constructor.
 
void print (std::ostream &out, const std::string &prefix) const
 Print ROOT class information.
 

Static Protected Member Functions

static void print (std::ostream &out, const std::string &name, const std::string &type)
 Print ROOT class information.
 

Protected Attributes

TDictionary * dictionary
 pointer to ROOT dictionary
 
int offset
 offset with respect to data structure [B]
 

Detailed Description

Auxiliary class to manage access to base classes and data members of ROOT class.

Definition at line 41 of file JRootClass.hh.

Constructor & Destructor Documentation

◆ JRootClass() [1/4]

template<class JType_t >
JROOT::JRootClass::JRootClass ( const JType< JType_t > & type)
inline

Constructor.

Parameters
typedata type

Definition at line 50 of file JRootClass.hh.

50 :
51 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
52 offset(0)
53 {}
TDictionary * dictionary
pointer to ROOT dictionary
int offset
offset with respect to data structure [B]

◆ JRootClass() [2/4]

template<class JType_t , class JClass_t >
JROOT::JRootClass::JRootClass ( JType_t JClass_t::* pd)
inline

Constructor.

Parameters
pdpointer to C++ data member

Definition at line 62 of file JRootClass.hh.

62 :
63 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
64 offset((char*) &(((JClass_t*) NULL)->*pd) - (char*) NULL)
65 {}

◆ JRootClass() [3/4]

JROOT::JRootClass::JRootClass ( TDictionary * dictionary,
int offset = 0 )
inline

Constructor.

Parameters
dictionarypointer to dictionary
offsetoffset

Definition at line 74 of file JRootClass.hh.

75 :
78 {}

◆ JRootClass() [4/4]

JROOT::JRootClass::JRootClass ( )
inlineprotected

Default constructor.

Definition at line 247 of file JRootClass.hh.

247 :
248 dictionary(NULL),
249 offset(0)
250 {}

Member Function Documentation

◆ getDictionary()

TDictionary * JROOT::JRootClass::getDictionary ( ) const
inline

Get dictionary.

Returns
pointer to dictionary

Definition at line 86 of file JRootClass.hh.

87 {
88 return dictionary;
89 }

◆ getOffset()

int JROOT::JRootClass::getOffset ( ) const
inline

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 97 of file JRootClass.hh.

98 {
99 return offset;
100 }

◆ getClass()

TClass * JROOT::JRootClass::getClass ( ) const
inline

Get class.

Returns
pointer to class

Definition at line 108 of file JRootClass.hh.

109 {
110 return dynamic_cast<TClass*>(dictionary);
111 }

◆ getTypename()

const char * JROOT::JRootClass::getTypename ( ) const
inline

Get type name.

Returns
type name

Definition at line 119 of file JRootClass.hh.

120 {
121 if (dictionary != NULL)
122 return dictionary->GetName();
123 else
124 return NULL;
125 }

◆ is_valid()

bool JROOT::JRootClass::is_valid ( ) const
inline

Check validity of this class.

Returns
true if valid class; else false

Definition at line 133 of file JRootClass.hh.

134 {
135 return (this->getDictionary() != NULL && JRoot::is_class(this->getTypename()));
136 }
TDictionary * getDictionary() const
Get dictionary.
Definition JRootClass.hh:86
const char * getTypename() const
Get type name.
static bool is_class(const char *const name)
Check name of class against internal ROOT class names.
Definition JRoot.hh:30

◆ equals()

bool JROOT::JRootClass::equals ( const JRootClass & object) const
inline

Test equality of ROOT classes.

Parameters
objectROOT class
Returns
true if both ROOT classes are same type; else false

Definition at line 145 of file JRootClass.hh.

146 {
147 return (this-> getTypename() != NULL &&
148 object.getTypename() != NULL &&
149 strcmp(this->getTypename(), object.getTypename()) == 0);
150 }

◆ find()

JRootClass JROOT::JRootClass::find ( const char *const name,
const bool option = true ) const
inline

Find base class or data member with given name within current class.

Parameters
namename of base class or data member
optioncase insensitive
Returns
ROOT class

Definition at line 160 of file JRootClass.hh.

161 {
162 if (name != NULL && strlen(name) != 0) {
163
164 if (strcmp(getTypename(), name) == 0) {
165 return *this;
166 }
167
168 if (this->getClass() != NULL) {
169
170 // check for data members
171
172 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
173 if (( option && strcmp (p->GetName(), name) == 0) ||
174 (!option && strcasecmp(p->GetName(), name) == 0)) {
175 return this->get(*p);
176 }
177 }
178
179 // check for base classes
180
181 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
182
183 if (JRoot::is_class(*p) && !JRoot::is_STLcontainer(*p)) {
184
185 JRootClass rcs = this->get(*p);
186
187 rcs = rcs.find(name, option);
188
189 if (rcs.is_valid()) {
190 return rcs;
191 }
192 }
193 }
194 }
195 }
196
197 return JRootClass(); // invalid value
198 }
JRootClass()
Default constructor.
TClass * getClass() const
Get class.
JRootClass get(const TDataMember &object) const
Get ROOT class of given data member.
static bool is_STLcontainer(const TBaseClass &object)
Check if base class is STL container.
Definition JRoot.hh:72

◆ get() [1/2]

JRootClass JROOT::JRootClass::get ( const TDataMember & object) const
inline

Get ROOT class of given data member.

Parameters
objectdata member
Returns
ROOT class

Definition at line 207 of file JRootClass.hh.

208 {
209 return JRootClass(TDictionary::GetDictionary(object.GetTypeName()),
210 this->getOffset() + object.GetOffset());
211 }
int getOffset() const
Get offset of this class with respect to parent class.
Definition JRootClass.hh:97

◆ get() [2/2]

JRootClass JROOT::JRootClass::get ( const TBaseClass & object) const
inline

Get ROOT class of given base class.

Parameters
objectbase class
Returns
ROOT class

Definition at line 220 of file JRootClass.hh.

221 {
222 return JRootClass(TDictionary::GetDictionary(object.GetName()),
223 this->getOffset() + const_cast<TBaseClass&>(object).GetDelta());
224 }

◆ print() [1/3]

void JROOT::JRootClass::print ( std::ostream & out) const
inline

Print ROOT class information.

Parameters
outoutput stream

Definition at line 232 of file JRootClass.hh.

233 {
234 print(out, getTypename());
235 }
void print(std::ostream &out) const
Print ROOT class information.

◆ print() [2/3]

void JROOT::JRootClass::print ( std::ostream & out,
const std::string & prefix ) const
inlineprotected

Print ROOT class information.

Parameters
outoutput stream
prefixprefix

Definition at line 259 of file JRootClass.hh.

260 {
261 if (this->is_valid()) {
262
263 print(out, prefix, this->getTypename());
264
265 if (this->getClass() != NULL) {
266
267 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
268 if (!JRoot::is_STLcontainer(*p))
269 this->get(*p).print(out, prefix + "::" + p->GetName());
270 else
271 print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
272 }
273
274 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
276 this->get(*p).print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName());
277 else
278 print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
279 }
280 }
281 }
282 }
bool is_valid() const
Check validity of this class.
static bool is_static(const TDataMember &object)
Check if data member is static.
Definition JRoot.hh:109
static bool is_STLstring(const TDataMember &object)
Check if data member is STL string.
Definition JRoot.hh:96

◆ print() [3/3]

static void JROOT::JRootClass::print ( std::ostream & out,
const std::string & name,
const std::string & type )
inlinestaticprotected

Print ROOT class information.

Parameters
outoutput stream
namename
typetype

Definition at line 292 of file JRootClass.hh.

293 {
294 using namespace std;
295
296 out << name << " " << '(' << type << ')' << endl;
297 }

Member Data Documentation

◆ dictionary

TDictionary* JROOT::JRootClass::dictionary
protected

pointer to ROOT dictionary

Definition at line 240 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protected

offset with respect to data structure [B]

Definition at line 241 of file JRootClass.hh.


The documentation for this struct was generated from the following file: