Jpp test-rotations-old
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 42 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 51 of file JRootClass.hh.

51 :
52 dictionary(TDictionary::GetDictionary(typeid(JType_t))),
53 offset(0)
54 {}
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 63 of file JRootClass.hh.

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

◆ JRootClass() [3/4]

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

Constructor.

Parameters
dictionarypointer to dictionary
offsetoffset

Definition at line 75 of file JRootClass.hh.

76 :
79 {}

◆ JRootClass() [4/4]

JROOT::JRootClass::JRootClass ( )
inlineprotected

Default constructor.

Definition at line 248 of file JRootClass.hh.

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

Member Function Documentation

◆ getDictionary()

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

Get dictionary.

Returns
pointer to dictionary

Definition at line 87 of file JRootClass.hh.

88 {
89 return dictionary;
90 }

◆ getOffset()

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

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 98 of file JRootClass.hh.

99 {
100 return offset;
101 }

◆ getClass()

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

Get class.

Returns
pointer to class

Definition at line 109 of file JRootClass.hh.

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

◆ getTypename()

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

Get type name.

Returns
type name

Definition at line 120 of file JRootClass.hh.

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

◆ is_valid()

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

Check validity of this class.

Returns
true if valid class; else false

Definition at line 134 of file JRootClass.hh.

135 {
136 return (this->getDictionary() != NULL && JRoot::is_class(this->getTypename()));
137 }
TDictionary * getDictionary() const
Get dictionary.
Definition JRootClass.hh:87
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 146 of file JRootClass.hh.

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

◆ 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 161 of file JRootClass.hh.

162 {
163 if (name != NULL && strlen(name) != 0) {
164
165 if (strcmp(getTypename(), name) == 0) {
166 return *this;
167 }
168
169 if (this->getClass() != NULL) {
170
171 // check for data members
172
173 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
174 if (( option && strcmp (p->GetName(), name) == 0) ||
175 (!option && strcasecmp(p->GetName(), name) == 0)) {
176 return this->get(*p);
177 }
178 }
179
180 // check for base classes
181
182 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
183
184 if (JRoot::is_class(*p) && !JRoot::is_STLcontainer(*p)) {
185
186 JRootClass rcs = this->get(*p);
187
188 rcs = rcs.find(name, option);
189
190 if (rcs.is_valid()) {
191 return rcs;
192 }
193 }
194 }
195 }
196 }
197
198 return JRootClass(); // invalid value
199 }
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 208 of file JRootClass.hh.

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

◆ 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 221 of file JRootClass.hh.

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

◆ print() [1/3]

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

Print ROOT class information.

Parameters
outoutput stream

Definition at line 233 of file JRootClass.hh.

234 {
235 print(out, getTypename());
236 }
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 260 of file JRootClass.hh.

261 {
262 if (this->is_valid()) {
263
264 print(out, prefix, this->getTypename());
265
266 if (this->getClass() != NULL) {
267
268 for (TIter next(this->getClass()->GetListOfBases()); const TBaseClass *p = (const TBaseClass*) next(); ) {
269 if (!JRoot::is_STLcontainer(*p))
270 this->get(*p).print(out, prefix + "::" + p->GetName());
271 else
272 print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
273 }
274
275 for (TIter next(this->getClass()->GetListOfDataMembers(kFALSE)); const TDataMember *p = (const TDataMember*) next(); ) {
277 this->get(*p).print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName());
278 else
279 print(out, prefix + (JRoot::is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
280 }
281 }
282 }
283 }
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 293 of file JRootClass.hh.

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

Member Data Documentation

◆ dictionary

TDictionary* JROOT::JRootClass::dictionary
protected

pointer to ROOT dictionary

Definition at line 241 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protected

offset with respect to data structure [B]

Definition at line 242 of file JRootClass.hh.


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