Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JROOT::JRootReadableClass Struct Reference

ROOT class for reading object. More...

#include <JRootClass.hh>

Inheritance diagram for JROOT::JRootReadableClass:
JROOT::JRootAddressableClass< char * > JROOT::JRootClass JROOT::JAddress< char * > JLANG::JEquals< JFirst_t, JSecond_t >

Public Types

typedef JAddress< char * > JAddress_t
 
typedef JAddress_t::pointer_type pointer_type
 

Public Member Functions

template<class T >
 JRootReadableClass (T &object)
 Constructor.
 
 JRootReadableClass (const JRootAddressableClass< char * > &rc)
 Copy constructor.
 
template<class T >
 operator const T & () const
 Type conversion operator.
 
template<class T >
 operator T& ()
 Type conversion operator.
 
pointer_type getAddress () const
 Get address.
 
bool is_valid () const
 Check validity of this addressable class.
 
JRootAddressableClass find (const char *const name) const
 Find addressable base class or data member with given name within current class.
 
JRootClass find (const char *const name, const bool option=true) const
 Find base class or data member with given name within current class.
 
JRootAddressableClass get (const TDataMember &data_member) const
 Get addressable class of given data member.
 
JRootAddressableClass get (const TBaseClass &base_class) const
 Get addressable class of given base class.
 
JRootAddressableClass operator[] (const char *const name) const
 Find addressable base class or data member with given name within current class.
 
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 equals (const JRootClass &object) const
 Test equality of ROOT classes.
 
void print (std::ostream &out) const
 Print ROOT class information.
 

Static Public Member Functions

static bool is_class (const char *const name)
 Check name of class against ROOT classes.
 
static bool is_class (const TBaseClass &base_class)
 Check base class against ROOT class names.
 
static bool is_class (const TDataMember &data_member)
 Check data member against ROOT class names.
 
static bool is_STLcontainer (const TBaseClass &base_class)
 Check if base class is STL container.
 
static bool is_STLcontainer (const TDataMember &data_member)
 Check if data member is STL container.
 
static bool is_STLstring (const TDataMember &data_member)
 Check if data member is STL string.
 
static bool is_static (const TDataMember &data_member)
 Check if data member is static.
 
static bool is_tobject_member (const char *name)
 Check if name is one of TObject own data members (fBits or fUniqueID, for Root <= 6.30.04 at least)
 

Public Attributes

pointer_type address
 

Protected Member Functions

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

ROOT class for reading object.

Definition at line 542 of file JRootClass.hh.

Member Typedef Documentation

◆ JAddress_t

JAddress<char *> JROOT::JRootAddressableClass< char * >::JAddress_t
inherited

Definition at line 440 of file JRootClass.hh.

◆ pointer_type

JAddress_t::pointer_type JROOT::JRootAddressableClass< char * >::pointer_type
inherited

Definition at line 441 of file JRootClass.hh.

Constructor & Destructor Documentation

◆ JRootReadableClass() [1/2]

template<class T >
JROOT::JRootReadableClass::JRootReadableClass ( T & object)
inline

Constructor.

Parameters
objecttemplate object

Definition at line 551 of file JRootClass.hh.

551 :
552 JRootAddressableClass<char *>(object)
553 {}

◆ JRootReadableClass() [2/2]

JROOT::JRootReadableClass::JRootReadableClass ( const JRootAddressableClass< char * > & rc)
inline

Copy constructor.

Parameters
rcROOT addressable class

Definition at line 561 of file JRootClass.hh.

561 :
562 JRootAddressableClass<char *>(rc)
563 {}

Member Function Documentation

◆ operator const T &()

template<class T >
JROOT::JRootReadableClass::operator const T & ( ) const
inline

Type conversion operator.

Returns
value

Definition at line 572 of file JRootClass.hh.

573 {
574 if (static_cast<const JRootClass&>(*this) == JRootClass(JType<T>())) {
575 return * (const T*) this->getAddress();
576 } else {
577 THROW(JCastException, "JRootReadableClass::operator const T&");
578 }
579 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JRootClass()
Default constructor.

◆ operator T&()

template<class T >
JROOT::JRootReadableClass::operator T& ( )
inline

Type conversion operator.

Returns
value

Definition at line 588 of file JRootClass.hh.

589 {
590 if (static_cast<const JRootClass&>(*this) == JRootClass(JType<T>())) {
591 return * (T*) this->getAddress();
592 } else {
593 THROW(JCastException, "JRootReadableClass::operator T&");
594 }
595 }

◆ getAddress()

pointer_type JROOT::JRootAddressableClass< char * >::getAddress ( ) const
inlineinherited

Get address.

Returns
pointer to object

Definition at line 460 of file JRootClass.hh.

461 {
462 return this->address + getOffset();
463 }
int getOffset() const
Get offset of this class with respect to parent class.

◆ is_valid()

bool JROOT::JRootAddressableClass< char * >::is_valid ( ) const
inlineinherited

Check validity of this addressable class.

Returns
true if valid addressable class; else false

Definition at line 471 of file JRootClass.hh.

472 {
473 return (JRootClass::is_valid() && this->address != NULL);
474 }
bool is_valid() const
Check validity of this class.

◆ find() [1/2]

JRootAddressableClass JROOT::JRootAddressableClass< char * >::find ( const char *const name) const
inlineinherited

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

Parameters
namename of base class or data member
Returns
ROOT addressable class

Definition at line 483 of file JRootClass.hh.

484 {
486 }
JRootClass find(const char *const name, const bool option=true) const
Find base class or data member with given name within current class.

◆ find() [2/2]

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

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

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

Definition at line 246 of file JRootClass.hh.

247 {
248 if (name != NULL && strlen(name) != 0) {
249
250 if (strcmp(getTypename(), name) == 0) {
251 return *this;
252 }
253
254 if (this->getClass() != NULL) {
255
256 // check for data member
257
258 for (std::unique_ptr<TIterator> i(this->getClass()->GetListOfDataMembers(kFALSE)->MakeIterator()); const TDataMember* p = (const TDataMember*) i->Next(); ) {
259 if (( option && strcmp (p->GetName(), name) == 0) ||
260 (!option && strcasecmp(p->GetName(), name) == 0)) {
261 return this->get(*p);
262 }
263 }
264
265 // check for base classes
266
267 for (std::unique_ptr<TIterator> i(this->getClass()->GetListOfBases()->MakeIterator()); TBaseClass* p = (TBaseClass*) i->Next(); ) {
268
269 if (is_class(*p) && !is_STLcontainer(*p)) {
270
271 JRootClass rcs = this->get(*p);
272
273 rcs = rcs.find(name);
274
275 if (rcs.is_valid()) {
276 return rcs;
277 }
278 }
279 }
280 }
281 }
282
283 return JRootClass(); // invalid value
284 }
const char * getTypename() const
Get type name.
JRootClass get(const TDataMember &data_member) const
Get ROOT class of given data member.
static bool is_STLcontainer(const TBaseClass &base_class)
Check if base class is STL container.
Definition JRootClass.hh:91
TClass * getClass() const
Get class.
static bool is_class(const char *const name)
Check name of class against ROOT classes.
Definition JRootClass.hh:50

◆ get() [1/2]

JRootAddressableClass JROOT::JRootAddressableClass< char * >::get ( const TDataMember & data_member) const
inlineinherited

Get addressable class of given data member.

Parameters
data_memberdata member
Returns
ROOT addressable class

Definition at line 495 of file JRootClass.hh.

496 {
497 return JRootAddressableClass(JRootClass::get(data_member), this->address);
498 }

◆ get() [2/2]

JRootAddressableClass JROOT::JRootAddressableClass< char * >::get ( const TBaseClass & base_class) const
inlineinherited

Get addressable class of given base class.

Parameters
base_classbase class
Returns
ROOT addressable class

Definition at line 507 of file JRootClass.hh.

508 {
509 return JRootAddressableClass(JRootClass::get(base_class), this->address);
510 }

◆ operator[]()

JRootAddressableClass JROOT::JRootAddressableClass< char * >::operator[] ( const char *const name) const
inlineinherited

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

Parameters
namename of base class or data member
Returns
ROOT addressable class

Definition at line 519 of file JRootClass.hh.

520 {
521 return this->find(name);
522 }
JRootAddressableClass find(const char *const name) const

◆ is_class() [1/3]

static bool JROOT::JRootClass::is_class ( const char *const name)
inlinestaticinherited

Check name of class against ROOT classes.

Parameters
namename of class
Returns
true if name of class corresponds to genuine class; else false

Definition at line 50 of file JRootClass.hh.

51 {
52 return (name != NULL &&
53 strcmp(name, TClass ::Class()->GetName()) != 0 &&
54 strcmp(name, TObject::Class()->GetName()) != 0 &&
55 strcmp(name, "_Rb_tree_node_base") != 0 &&
56 strcmp(name, "fgIsA") != 0 &&
57 strcmp(name, "atomic<TClass*>") != 0);
58 }

◆ is_class() [2/3]

static bool JROOT::JRootClass::is_class ( const TBaseClass & base_class)
inlinestaticinherited

Check base class against ROOT class names.

Parameters
base_classbase class
Returns
true if valid class name; else false

Definition at line 67 of file JRootClass.hh.

68 {
69 return is_class(base_class.GetName());
70 }

◆ is_class() [3/3]

static bool JROOT::JRootClass::is_class ( const TDataMember & data_member)
inlinestaticinherited

Check data member against ROOT class names.

Parameters
data_memberdata member
Returns
true if valid class name; else false

Definition at line 79 of file JRootClass.hh.

80 {
81 return is_class(data_member.GetTypeName());
82 }

◆ is_STLcontainer() [1/2]

static bool JROOT::JRootClass::is_STLcontainer ( const TBaseClass & base_class)
inlinestaticinherited

Check if base class is STL container.

Parameters
base_classbase class
Returns
true if STL congtainer; else false

Definition at line 91 of file JRootClass.hh.

92 {
93 return (const_cast<TBaseClass&>(base_class).IsSTLContainer() != ROOT::kNotSTL);
94 }

◆ is_STLcontainer() [2/2]

static bool JROOT::JRootClass::is_STLcontainer ( const TDataMember & data_member)
inlinestaticinherited

Check if data member is STL container.

Parameters
data_memberdata member
Returns
true if STL congtainer; else false

Definition at line 103 of file JRootClass.hh.

104 {
105 return (const_cast<TDataMember&>(data_member).IsSTLContainer() != ROOT::kNotSTL);
106 }

◆ is_STLstring()

static bool JROOT::JRootClass::is_STLstring ( const TDataMember & data_member)
inlinestaticinherited

Check if data member is STL string.

Parameters
data_memberdata member
Returns
true if STL string; else false

Definition at line 115 of file JRootClass.hh.

116 {
117 return (strcmp(data_member.GetFullTypeName(), "string") == 0 ||
118 strcmp(data_member.GetFullTypeName(), "const string") == 0);
119 }

◆ is_static()

static bool JROOT::JRootClass::is_static ( const TDataMember & data_member)
inlinestaticinherited

Check if data member is static.

Parameters
data_memberdata member
Returns
true if static; else false

Definition at line 128 of file JRootClass.hh.

129 {
130 return (data_member.Property() & kIsStatic);
131 }

◆ is_tobject_member()

static bool JROOT::JRootClass::is_tobject_member ( const char * name)
inlinestaticinherited

Check if name is one of TObject own data members (fBits or fUniqueID, for Root <= 6.30.04 at least)

Definition at line 138 of file JRootClass.hh.

139 {
140 TClass* o_class = TClass::GetClass<TObject>();
141 return o_class->GetListOfRealData()->FindObject(name) != nullptr;
142 }

◆ getDictionary()

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

Get dictionary.

Returns
pointer to dictionary

Definition at line 172 of file JRootClass.hh.

173 {
174 return dictionary;
175 }
TDictionary * dictionary
pointer to ROOT dictionary

◆ getOffset()

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

Get offset of this class with respect to parent class.

Returns
offset

Definition at line 183 of file JRootClass.hh.

184 {
185 return offset;
186 }
int offset
offset with respect to data structure [B]

◆ getClass()

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

Get class.

Returns
pointer to class

Definition at line 194 of file JRootClass.hh.

195 {
196 return dynamic_cast<TClass*>(dictionary);
197 }

◆ getTypename()

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

Get type name.

Returns
type name

Definition at line 205 of file JRootClass.hh.

206 {
207 if (dictionary != NULL)
208 return dictionary->GetName();
209 else
210 return NULL;
211 }

◆ equals()

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

Test equality of ROOT classes.

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

Definition at line 231 of file JRootClass.hh.

232 {
233 return (this-> getTypename() != NULL &&
234 object.getTypename() != NULL &&
235 strcmp(this->getTypename(), object.getTypename()) == 0);
236 }

◆ print() [1/3]

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

Print ROOT class information.

Parameters
outoutput stream

Definition at line 318 of file JRootClass.hh.

319 {
320 print(out, getTypename());
321 }
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
inlineprotectedinherited

Print ROOT class information.

Parameters
outoutput stream
prefixprefix

Definition at line 358 of file JRootClass.hh.

359 {
360 if (this->is_valid()) {
361
362 print(out, prefix, this->getTypename());
363
364 if (this->getClass() != NULL) {
365
366 if (this->getClass()->GetListOfBases() != NULL) {
367
368 for (std::unique_ptr<TIterator> i(this->getClass()->GetListOfBases()->MakeIterator()); const TBaseClass* p = (const TBaseClass*) i->Next(); ) {
369 if (!is_STLcontainer(*p))
370 this->get(*p).print(out, prefix + "::" + p->GetName());
371 else
372 print(out, prefix + "::" + p->GetName(), this->get(*p).getTypename());
373 }
374 }
375
376 if (this->getClass()->GetListOfDataMembers(kFALSE) != NULL) {
377
378 for (std::unique_ptr<TIterator> i(this->getClass()->GetListOfDataMembers(kFALSE)->MakeIterator()); const TDataMember* p = (const TDataMember*) i->Next(); ) {
379 if (!is_STLstring(*p) && !is_STLcontainer(*p))
380 this->get(*p).print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName());
381 else
382 print(out, prefix + (is_static(*p) ? "::" : ".") + p->GetName(), this->get(*p).getTypename());
383 }
384 }
385 }
386 }
387 }
static bool is_static(const TDataMember &data_member)
Check if data member is static.
static bool is_STLstring(const TDataMember &data_member)
Check if data member is STL string.

◆ print() [3/3]

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

Print ROOT class information.

Parameters
outoutput stream
namename
typetype

Definition at line 397 of file JRootClass.hh.

398 {
399 using namespace std;
400
401 out << name << " " << '(' << type << ')' << endl;
402 }

Member Data Documentation

◆ dictionary

TDictionary* JROOT::JRootClass::dictionary
protectedinherited

pointer to ROOT dictionary

Definition at line 326 of file JRootClass.hh.

◆ offset

int JROOT::JRootClass::offset
protectedinherited

offset with respect to data structure [B]

Definition at line 327 of file JRootClass.hh.

◆ address

pointer_type JROOT::JAddress< char * >::address
inherited

Definition at line 426 of file JRootClass.hh.


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